aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorNadia Derbey <Nadia.Derbey@bull.net>2008-04-29 04:00:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:13 -0400
commit6546bc4279241e8fa432de1bb63a4f6f791fd669 (patch)
tree308f5c1621b1019a44800622ffc468a372f09434 /ipc
parent91cfb2b4b57816de0c96de417b3238249f0b125f (diff)
ipc: re-enable msgmni automatic recomputing msgmni if set to negative
The enhancement as asked for by Yasunori: if msgmni is set to a negative value, register it back into the ipcns notifier chain. A new interface has been added to the notification mechanism: notifier_chain_cond_register() registers a notifier block only if not already registered. With that new interface we avoid taking care of the states changes in procfs. Signed-off-by: Nadia Derbey <Nadia.Derbey@bull.net> Cc: Yasunori Goto <y-goto@jp.fujitsu.com> Cc: Matt Helsley <matthltc@us.ibm.com> Cc: Mingming Cao <cmm@us.ibm.com> Cc: Pierre Peiffer <pierre.peiffer@bull.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_sysctl.c45
-rw-r--r--ipc/ipcns_notifier.c9
2 files changed, 44 insertions, 10 deletions
diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
index d12ff5cd2a0b..d3497465cc0a 100644
--- a/ipc/ipc_sysctl.c
+++ b/ipc/ipc_sysctl.c
@@ -15,6 +15,8 @@
15#include <linux/sysctl.h> 15#include <linux/sysctl.h>
16#include <linux/uaccess.h> 16#include <linux/uaccess.h>
17#include <linux/ipc_namespace.h> 17#include <linux/ipc_namespace.h>
18#include <linux/msg.h>
19#include "util.h"
18 20
19static void *get_ipc(ctl_table *table) 21static void *get_ipc(ctl_table *table)
20{ 22{
@@ -24,6 +26,27 @@ static void *get_ipc(ctl_table *table)
24 return which; 26 return which;
25} 27}
26 28
29/*
30 * Routine that is called when a tunable has successfully been changed by
31 * hand and it has a callback routine registered on the ipc namespace notifier
32 * chain: we don't want such tunables to be recomputed anymore upon memory
33 * add/remove or ipc namespace creation/removal.
34 * They can come back to a recomputable state by being set to a <0 value.
35 */
36static void tunable_set_callback(int val)
37{
38 if (val >= 0)
39 unregister_ipcns_notifier(current->nsproxy->ipc_ns);
40 else {
41 /*
42 * Re-enable automatic recomputing only if not already
43 * enabled.
44 */
45 recompute_msgmni(current->nsproxy->ipc_ns);
46 cond_register_ipcns_notifier(current->nsproxy->ipc_ns);
47 }
48}
49
27#ifdef CONFIG_PROC_FS 50#ifdef CONFIG_PROC_FS
28static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp, 51static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
29 void __user *buffer, size_t *lenp, loff_t *ppos) 52 void __user *buffer, size_t *lenp, loff_t *ppos)
@@ -38,17 +61,17 @@ static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
38static int proc_ipc_callback_dointvec(ctl_table *table, int write, 61static int proc_ipc_callback_dointvec(ctl_table *table, int write,
39 struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos) 62 struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
40{ 63{
64 struct ctl_table ipc_table;
41 size_t lenp_bef = *lenp; 65 size_t lenp_bef = *lenp;
42 int rc; 66 int rc;
43 67
44 rc = proc_ipc_dointvec(table, write, filp, buffer, lenp, ppos); 68 memcpy(&ipc_table, table, sizeof(ipc_table));
69 ipc_table.data = get_ipc(table);
70
71 rc = proc_dointvec(&ipc_table, write, filp, buffer, lenp, ppos);
45 72
46 if (write && !rc && lenp_bef == *lenp) 73 if (write && !rc && lenp_bef == *lenp)
47 /* 74 tunable_set_callback(*((int *)(ipc_table.data)));
48 * Tunable has successfully been changed from userland:
49 * disable its automatic recomputing.
50 */
51 unregister_ipcns_notifier(current->nsproxy->ipc_ns);
52 75
53 return rc; 76 return rc;
54} 77}
@@ -119,12 +142,14 @@ static int sysctl_ipc_registered_data(ctl_table *table, int __user *name,
119 rc = sysctl_ipc_data(table, name, nlen, oldval, oldlenp, newval, 142 rc = sysctl_ipc_data(table, name, nlen, oldval, oldlenp, newval,
120 newlen); 143 newlen);
121 144
122 if (newval && newlen && rc > 0) 145 if (newval && newlen && rc > 0) {
123 /* 146 /*
124 * Tunable has successfully been changed from userland: 147 * Tunable has successfully been changed from userland
125 * disable its automatic recomputing.
126 */ 148 */
127 unregister_ipcns_notifier(current->nsproxy->ipc_ns); 149 int *data = get_ipc(table);
150
151 tunable_set_callback(*data);
152 }
128 153
129 return rc; 154 return rc;
130} 155}
diff --git a/ipc/ipcns_notifier.c b/ipc/ipcns_notifier.c
index c7974609defc..70ff09183f7b 100644
--- a/ipc/ipcns_notifier.c
+++ b/ipc/ipcns_notifier.c
@@ -61,6 +61,15 @@ int register_ipcns_notifier(struct ipc_namespace *ns)
61 return blocking_notifier_chain_register(&ipcns_chain, &ns->ipcns_nb); 61 return blocking_notifier_chain_register(&ipcns_chain, &ns->ipcns_nb);
62} 62}
63 63
64int cond_register_ipcns_notifier(struct ipc_namespace *ns)
65{
66 memset(&ns->ipcns_nb, 0, sizeof(ns->ipcns_nb));
67 ns->ipcns_nb.notifier_call = ipcns_callback;
68 ns->ipcns_nb.priority = IPCNS_CALLBACK_PRI;
69 return blocking_notifier_chain_cond_register(&ipcns_chain,
70 &ns->ipcns_nb);
71}
72
64int unregister_ipcns_notifier(struct ipc_namespace *ns) 73int unregister_ipcns_notifier(struct ipc_namespace *ns)
65{ 74{
66 return blocking_notifier_chain_unregister(&ipcns_chain, 75 return blocking_notifier_chain_unregister(&ipcns_chain,