diff options
Diffstat (limited to 'ipc/util.h')
-rw-r--r-- | ipc/util.h | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/ipc/util.h b/ipc/util.h index b6a6a88f3002..f2f5036f2eed 100644 --- a/ipc/util.h +++ b/ipc/util.h | |||
@@ -47,6 +47,13 @@ static inline void msg_exit_ns(struct ipc_namespace *ns) { } | |||
47 | static inline void shm_exit_ns(struct ipc_namespace *ns) { } | 47 | static inline void shm_exit_ns(struct ipc_namespace *ns) { } |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | struct ipc_rcu { | ||
51 | struct rcu_head rcu; | ||
52 | atomic_t refcount; | ||
53 | } ____cacheline_aligned_in_smp; | ||
54 | |||
55 | #define ipc_rcu_to_struct(p) ((void *)(p+1)) | ||
56 | |||
50 | /* | 57 | /* |
51 | * Structure that holds the parameters needed by the ipc operations | 58 | * Structure that holds the parameters needed by the ipc operations |
52 | * (see after) | 59 | * (see after) |
@@ -94,10 +101,10 @@ void __init ipc_init_proc_interface(const char *path, const char *header, | |||
94 | #define ipcid_to_idx(id) ((id) % SEQ_MULTIPLIER) | 101 | #define ipcid_to_idx(id) ((id) % SEQ_MULTIPLIER) |
95 | #define ipcid_to_seqx(id) ((id) / SEQ_MULTIPLIER) | 102 | #define ipcid_to_seqx(id) ((id) / SEQ_MULTIPLIER) |
96 | 103 | ||
97 | /* must be called with ids->rw_mutex acquired for writing */ | 104 | /* must be called with ids->rwsem acquired for writing */ |
98 | int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int); | 105 | int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int); |
99 | 106 | ||
100 | /* must be called with ids->rw_mutex acquired for reading */ | 107 | /* must be called with ids->rwsem acquired for reading */ |
101 | int ipc_get_maxid(struct ipc_ids *); | 108 | int ipc_get_maxid(struct ipc_ids *); |
102 | 109 | ||
103 | /* must be called with both locks acquired. */ | 110 | /* must be called with both locks acquired. */ |
@@ -120,7 +127,8 @@ void ipc_free(void* ptr, int size); | |||
120 | */ | 127 | */ |
121 | void* ipc_rcu_alloc(int size); | 128 | void* ipc_rcu_alloc(int size); |
122 | int ipc_rcu_getref(void *ptr); | 129 | int ipc_rcu_getref(void *ptr); |
123 | void ipc_rcu_putref(void *ptr); | 130 | void ipc_rcu_putref(void *ptr, void (*func)(struct rcu_head *head)); |
131 | void ipc_rcu_free(struct rcu_head *head); | ||
124 | 132 | ||
125 | struct kern_ipc_perm *ipc_lock(struct ipc_ids *, int); | 133 | struct kern_ipc_perm *ipc_lock(struct ipc_ids *, int); |
126 | struct kern_ipc_perm *ipc_obtain_object(struct ipc_ids *ids, int id); | 134 | struct kern_ipc_perm *ipc_obtain_object(struct ipc_ids *ids, int id); |
@@ -131,9 +139,6 @@ int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out); | |||
131 | struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns, | 139 | struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns, |
132 | struct ipc_ids *ids, int id, int cmd, | 140 | struct ipc_ids *ids, int id, int cmd, |
133 | struct ipc64_perm *perm, int extra_perm); | 141 | struct ipc64_perm *perm, int extra_perm); |
134 | struct kern_ipc_perm *ipcctl_pre_down(struct ipc_namespace *ns, | ||
135 | struct ipc_ids *ids, int id, int cmd, | ||
136 | struct ipc64_perm *perm, int extra_perm); | ||
137 | 142 | ||
138 | #ifndef CONFIG_ARCH_WANT_IPC_PARSE_VERSION | 143 | #ifndef CONFIG_ARCH_WANT_IPC_PARSE_VERSION |
139 | /* On IA-64, we always use the "64-bit version" of the IPC structures. */ | 144 | /* On IA-64, we always use the "64-bit version" of the IPC structures. */ |
@@ -174,19 +179,12 @@ static inline void ipc_assert_locked_object(struct kern_ipc_perm *perm) | |||
174 | assert_spin_locked(&perm->lock); | 179 | assert_spin_locked(&perm->lock); |
175 | } | 180 | } |
176 | 181 | ||
177 | static inline void ipc_lock_by_ptr(struct kern_ipc_perm *perm) | ||
178 | { | ||
179 | rcu_read_lock(); | ||
180 | ipc_lock_object(perm); | ||
181 | } | ||
182 | |||
183 | static inline void ipc_unlock(struct kern_ipc_perm *perm) | 182 | static inline void ipc_unlock(struct kern_ipc_perm *perm) |
184 | { | 183 | { |
185 | ipc_unlock_object(perm); | 184 | ipc_unlock_object(perm); |
186 | rcu_read_unlock(); | 185 | rcu_read_unlock(); |
187 | } | 186 | } |
188 | 187 | ||
189 | struct kern_ipc_perm *ipc_lock_check(struct ipc_ids *ids, int id); | ||
190 | struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id); | 188 | struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id); |
191 | int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, | 189 | int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, |
192 | struct ipc_ops *ops, struct ipc_params *params); | 190 | struct ipc_ops *ops, struct ipc_params *params); |