From b6b337ad1c1d6fe11b09b35d75464b84b3e11f07 Mon Sep 17 00:00:00 2001 From: Nadia Derbey Date: Tue, 29 Apr 2008 01:00:42 -0700 Subject: ipc: recompute msgmni on memory add / remove Introduce the registration of a callback routine that recomputes msg_ctlmni upon memory add / remove. A single notifier block is registered in the hotplug memory chain for all the ipc namespaces. Since the ipc namespaces are not linked together, they have their own notification chain: one notifier_block is defined per ipc namespace. Each time an ipc namespace is created (removed) it registers (unregisters) its notifier block in (from) the ipcns chain. The callback routine registered in the memory chain invokes the ipcns notifier chain with the IPCNS_LOWMEM event. Each callback routine registered in the ipcns namespace, in turn, recomputes msgmni for the owning namespace. Signed-off-by: Nadia Derbey Cc: Yasunori Goto Cc: Matt Helsley Cc: Mingming Cao Cc: Pierre Peiffer Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- ipc/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ipc/util.h') diff --git a/ipc/util.h b/ipc/util.h index f37d160c98f..0e3d79037a2 100644 --- a/ipc/util.h +++ b/ipc/util.h @@ -124,6 +124,8 @@ extern void free_msg(struct msg_msg *msg); extern struct msg_msg *load_msg(const void __user *src, int len); extern int store_msg(void __user *dest, struct msg_msg *msg, int len); +extern void recompute_msgmni(struct ipc_namespace *); + static inline int ipc_buildid(int id, int seq) { return SEQ_MULTIPLIER * seq + id; -- cgit v1.2.3 From 8f4a3809c18ff3107bdbb1fabe3f4e5d2a928321 Mon Sep 17 00:00:00 2001 From: Pierre Peiffer Date: Tue, 29 Apr 2008 01:00:51 -0700 Subject: IPC: introduce ipc_update_perm() The IPC_SET command performs the same permission setting for all IPCs. This patch introduces a common ipc_update_perm() function to update these permissions and makes use of it for all IPCs. Signed-off-by: Pierre Peiffer Acked-by: Serge Hallyn Cc: Nadia Derbey Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- ipc/util.h | 1 + 1 file changed, 1 insertion(+) (limited to 'ipc/util.h') diff --git a/ipc/util.h b/ipc/util.h index 0e3d79037a2..12966913ebc 100644 --- a/ipc/util.h +++ b/ipc/util.h @@ -112,6 +112,7 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *, int); void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out); void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out); +void ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out); #if defined(__ia64__) || defined(__x86_64__) || defined(__hppa__) || defined(__XTENSA__) /* On IA-64, we always use the "64-bit version" of the IPC structures. */ -- cgit v1.2.3 From a5f75e7f256f75759ec3d6dbef0ba932f1b397d2 Mon Sep 17 00:00:00 2001 From: Pierre Peiffer Date: Tue, 29 Apr 2008 01:00:54 -0700 Subject: IPC: consolidate all xxxctl_down() functions semctl_down(), msgctl_down() and shmctl_down() are used to handle the same set of commands for each kind of IPC. They all start to do the same job (they retrieve the ipc and do some permission checks) before handling the commands on their own. This patch proposes to consolidate this by moving these same pieces of code into one common function called ipcctl_pre_down(). It simplifies a little these xxxctl_down() functions and increases a little the maintainability. Signed-off-by: Pierre Peiffer Acked-by: Serge Hallyn Cc: Nadia Derbey Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- ipc/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ipc/util.h') diff --git a/ipc/util.h b/ipc/util.h index 12966913ebc..791c5c01271 100644 --- a/ipc/util.h +++ b/ipc/util.h @@ -113,6 +113,8 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *, int); void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out); void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out); void ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out); +struct kern_ipc_perm *ipcctl_pre_down(struct ipc_ids *ids, int id, int cmd, + struct ipc64_perm *perm, int extra_perm); #if defined(__ia64__) || defined(__x86_64__) || defined(__hppa__) || defined(__XTENSA__) /* On IA-64, we always use the "64-bit version" of the IPC structures. */ -- cgit v1.2.3 From 44f564a4bf6ac70f2a84806203045cf515bc9367 Mon Sep 17 00:00:00 2001 From: "Zhang, Yanmin" Date: Tue, 29 Apr 2008 01:00:55 -0700 Subject: ipc: add definitions of USHORT_MAX and others Add definitions of USHORT_MAX and others into kernel. ipc uses it and slub implementation might also use it. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Zhang Yanmin Reviewed-by: Christoph Lameter Cc: Nadia Derbey Cc: "Pierre Peiffer" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- ipc/util.h | 1 - 1 file changed, 1 deletion(-) (limited to 'ipc/util.h') diff --git a/ipc/util.h b/ipc/util.h index 791c5c01271..cdb966aebe0 100644 --- a/ipc/util.h +++ b/ipc/util.h @@ -12,7 +12,6 @@ #include -#define USHRT_MAX 0xffff #define SEQ_MULTIPLIER (IPCMNI) void sem_init (void); -- cgit v1.2.3