]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blame - include/linux/ipc_namespace.h
ipc: invoke the ipcns notifier chain as a work item
[mirror_ubuntu-kernels.git] / include / linux / ipc_namespace.h
CommitLineData
ae5e1b22
PE
1#ifndef __IPC_NAMESPACE_H__
2#define __IPC_NAMESPACE_H__
3
4#include <linux/err.h>
ed2ddbf8
PP
5#include <linux/idr.h>
6#include <linux/rwsem.h>
b6b337ad
ND
7#ifdef CONFIG_MEMORY_HOTPLUG
8#include <linux/notifier.h>
9#endif /* CONFIG_MEMORY_HOTPLUG */
10
11/*
12 * ipc namespace events
13 */
14#define IPCNS_MEMCHANGED 0x00000001 /* Notify lowmem size changed */
15
16#define IPCNS_CALLBACK_PRI 0
17
ed2ddbf8
PP
18
19struct ipc_ids {
20 int in_use;
21 unsigned short seq;
22 unsigned short seq_max;
23 struct rw_semaphore rw_mutex;
24 struct idr ipcs_idr;
25};
ae5e1b22 26
ae5e1b22
PE
27struct ipc_namespace {
28 struct kref kref;
ed2ddbf8 29 struct ipc_ids ids[3];
ae5e1b22
PE
30
31 int sem_ctls[4];
32 int used_sems;
33
34 int msg_ctlmax;
35 int msg_ctlmnb;
36 int msg_ctlmni;
37 atomic_t msg_bytes;
38 atomic_t msg_hdrs;
39
40 size_t shm_ctlmax;
41 size_t shm_ctlall;
42 int shm_ctlmni;
43 int shm_tot;
b6b337ad
ND
44
45#ifdef CONFIG_MEMORY_HOTPLUG
46 struct notifier_block ipcns_nb;
47#endif
ae5e1b22
PE
48};
49
50extern struct ipc_namespace init_ipc_ns;
4d89dc6a 51extern atomic_t nr_ipc_ns;
ae5e1b22
PE
52
53#ifdef CONFIG_SYSVIPC
54#define INIT_IPC_NS(ns) .ns = &init_ipc_ns,
b6b337ad
ND
55
56#ifdef CONFIG_MEMORY_HOTPLUG
57
58extern int register_ipcns_notifier(struct ipc_namespace *);
59extern int unregister_ipcns_notifier(struct ipc_namespace *);
60extern int ipcns_notify(unsigned long);
61
62#else /* CONFIG_MEMORY_HOTPLUG */
63
64static inline int register_ipcns_notifier(struct ipc_namespace *ipcns)
65{
66 return 0;
67}
68static inline int unregister_ipcns_notifier(struct ipc_namespace *ipcns)
69{
70 return 0;
71}
72static inline int ipcns_notify(unsigned long ev)
73{
74 return 0;
75}
76
77#endif /* CONFIG_MEMORY_HOTPLUG */
78
79#else /* CONFIG_SYSVIPC */
ae5e1b22 80#define INIT_IPC_NS(ns)
b6b337ad 81#endif /* CONFIG_SYSVIPC */
ae5e1b22
PE
82
83#if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS)
84extern void free_ipc_ns(struct kref *kref);
85extern struct ipc_namespace *copy_ipcs(unsigned long flags,
01b8b07a
PP
86 struct ipc_namespace *ns);
87extern void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,
88 void (*free)(struct ipc_namespace *,
89 struct kern_ipc_perm *));
ae5e1b22
PE
90
91static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
92{
93 if (ns)
94 kref_get(&ns->kref);
95 return ns;
96}
97
98static inline void put_ipc_ns(struct ipc_namespace *ns)
99{
100 kref_put(&ns->kref, free_ipc_ns);
101}
102#else
103static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
104 struct ipc_namespace *ns)
105{
106 if (flags & CLONE_NEWIPC)
107 return ERR_PTR(-EINVAL);
108
109 return ns;
110}
111
112static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
113{
114 return ns;
115}
116
117static inline void put_ipc_ns(struct ipc_namespace *ns)
118{
119}
120#endif
121#endif