diff options
author | Pierre Peiffer <pierre.peiffer@bull.net> | 2008-02-08 15:18:57 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 20:22:26 +0300 |
commit | 01b8b07a5d77d22e609267dcae74d15e3e9c5f13 (patch) | |
tree | dd53c51f75de9511da7fdf283c73080d6c2552a8 /ipc/msg.c | |
parent | ed2ddbf88c0ddeeae4c78bb306a116dfd867c55c (diff) | |
download | linux-01b8b07a5d77d22e609267dcae74d15e3e9c5f13.tar.xz |
IPC: consolidate sem_exit_ns(), msg_exit_ns() and shm_exit_ns()
sem_exit_ns(), msg_exit_ns() and shm_exit_ns() are all called when an
ipc_namespace is released to free all ipcs of each type. But in fact, they
do the same thing: they loop around all ipcs to free them individually by
calling a specific routine.
This patch proposes to consolidate this by introducing a common function,
free_ipcs(), that do the job. The specific routine to call on each
individual ipcs is passed as parameter. For this, these ipc-specific
'free' routines are reworked to take a generic 'struct ipc_perm' as
parameter.
Signed-off-by: Pierre Peiffer <pierre.peiffer@bull.net>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Nadia Derbey <Nadia.Derbey@bull.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc/msg.c')
-rw-r--r-- | ipc/msg.c | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/ipc/msg.c b/ipc/msg.c index ab0c38b29533..46585a05473e 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -72,7 +72,7 @@ struct msg_sender { #define msg_unlock(msq) ipc_unlock(&(msq)->q_perm) #define msg_buildid(id, seq) ipc_buildid(id, seq) -static void freeque(struct ipc_namespace *, struct msg_queue *); +static void freeque(struct ipc_namespace *, struct kern_ipc_perm *); static int newque(struct ipc_namespace *, struct ipc_params *); #ifdef CONFIG_PROC_FS static int sysvipc_msg_proc_show(struct seq_file *s, void *it); @@ -91,26 +91,7 @@ void msg_init_ns(struct ipc_namespace *ns) #ifdef CONFIG_IPC_NS void msg_exit_ns(struct ipc_namespace *ns) { - struct msg_queue *msq; - struct kern_ipc_perm *perm; - int next_id; - int total, in_use; - - down_write(&msg_ids(ns).rw_mutex); - - in_use = msg_ids(ns).in_use; - - for (total = 0, next_id = 0; total < in_use; next_id++) { - perm = idr_find(&msg_ids(ns).ipcs_idr, next_id); - if (perm == NULL) - continue; - ipc_lock_by_ptr(perm); - msq = container_of(perm, struct msg_queue, q_perm); - freeque(ns, msq); - total++; - } - - up_write(&msg_ids(ns).rw_mutex); + free_ipcs(ns, &msg_ids(ns), freeque); } #endif @@ -274,9 +255,10 @@ static void expunge_all(struct msg_queue *msq, int res) * msg_ids.rw_mutex (writer) and the spinlock for this message queue are held * before freeque() is called. msg_ids.rw_mutex remains locked on exit. */ -static void freeque(struct ipc_namespace *ns, struct msg_queue *msq) +static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) { struct list_head *tmp; + struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); expunge_all(msq, -EIDRM); ss_wakeup(&msq->q_senders, 1); @@ -582,7 +564,7 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf) break; } case IPC_RMID: - freeque(ns, msq); + freeque(ns, &msq->q_perm); break; } err = 0; |