Skip to content

Commit 614b84c

Browse files
Serge E. Hallyntorvalds
authored andcommitted
namespaces: mqueue ns: move mqueue_mnt into struct ipc_namespace
Move mqueue vfsmount plus a few tunables into the ipc_namespace struct. The CONFIG_IPC_NS boolean and the ipc_namespace struct will serve both the posix message queue namespaces and the SYSV ipc namespaces. The sysctl code will be fixed separately in patch 3. After just this patch, making a change to posix mqueue tunables always changes the values in the initial ipc namespace. Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 909e6d9 commit 614b84c

7 files changed

Lines changed: 145 additions & 71 deletions

File tree

‎include/linux/ipc_namespace.h‎

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,55 @@ struct ipc_namespace {
4444
int shm_tot;
4545

4646
struct notifier_block ipcns_nb;
47+
48+
/* The kern_mount of the mqueuefs sb. We take a ref on it */
49+
struct vfsmount *mq_mnt;
50+
51+
/* # queues in this ns, protected by mq_lock */
52+
unsigned int mq_queues_count;
53+
54+
/* next fields are set through sysctl */
55+
unsigned int mq_queues_max; /* initialized to DFLT_QUEUESMAX */
56+
unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */
57+
unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */
58+
4759
};
4860

4961
extern struct ipc_namespace init_ipc_ns;
5062
extern atomic_t nr_ipc_ns;
5163

52-
#ifdef CONFIG_SYSVIPC
64+
#if defined(CONFIG_POSIX_MQUEUE) || defined(CONFIG_SYSVIPC)
5365
#define INIT_IPC_NS(ns) .ns = &init_ipc_ns,
66+
#else
67+
#define INIT_IPC_NS(ns)
68+
#endif
5469

70+
#ifdef CONFIG_SYSVIPC
5571
extern int register_ipcns_notifier(struct ipc_namespace *);
5672
extern int cond_register_ipcns_notifier(struct ipc_namespace *);
5773
extern void unregister_ipcns_notifier(struct ipc_namespace *);
5874
extern int ipcns_notify(unsigned long);
59-
6075
#else /* CONFIG_SYSVIPC */
61-
#define INIT_IPC_NS(ns)
76+
static inline int register_ipcns_notifier(struct ipc_namespace *ns)
77+
{ return 0; }
78+
static inline int cond_register_ipcns_notifier(struct ipc_namespace *ns)
79+
{ return 0; }
80+
static inline void unregister_ipcns_notifier(struct ipc_namespace *ns) { }
81+
static inline int ipcns_notify(unsigned long l) { return 0; }
6282
#endif /* CONFIG_SYSVIPC */
6383

64-
#if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS)
84+
#ifdef CONFIG_POSIX_MQUEUE
85+
extern void mq_init_ns(struct ipc_namespace *ns);
86+
/* default values */
87+
#define DFLT_QUEUESMAX 256 /* max number of message queues */
88+
#define DFLT_MSGMAX 10 /* max number of messages in each queue */
89+
#define HARD_MSGMAX (131072/sizeof(void *))
90+
#define DFLT_MSGSIZEMAX 8192 /* max message size */
91+
#else
92+
#define mq_init_ns(ns) ((void) 0)
93+
#endif
94+
95+
#if defined(CONFIG_IPC_NS)
6596
extern void free_ipc_ns(struct kref *kref);
6697
extern struct ipc_namespace *copy_ipcs(unsigned long flags,
6798
struct ipc_namespace *ns);

‎init/Kconfig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,10 @@ config UTS_NS
670670

671671
config IPC_NS
672672
bool "IPC namespace"
673-
depends on NAMESPACES && SYSVIPC
673+
depends on NAMESPACES && (SYSVIPC || POSIX_MQUEUE)
674674
help
675675
In this namespace tasks work with IPC ids which correspond to
676-
different IPC objects in different namespaces
676+
different IPC objects in different namespaces.
677677

678678
config USER_NS
679679
bool "User namespace (EXPERIMENTAL)"

0 commit comments

Comments
 (0)