aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/util.h
diff options
context:
space:
mode:
authorNadia Derbey <Nadia.Derbey@bull.net>2007-10-19 02:40:48 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:44 -0400
commit7ca7e564e049d8b350ec9d958ff25eaa24226352 (patch)
treee3c1397dc898dbd7c685c6a052425e7346eb79d1 /ipc/util.h
parentd2b20b11547cefc89d6c81937e81afaf3c62808b (diff)
ipc: store ipcs into IDRs
This patch introduces ipcs storage into IDRs. The main changes are: . This ipc_ids structure is changed: the entries array is changed into a root idr structure. . The grow_ary() routine is removed: it is not needed anymore when adding an ipc structure, since we are now using the IDR facility. . The ipc_rmid() routine interface is changed: . there is no need for this routine to return the pointer passed in as argument: it is now declared as a void . since the id is now part of the kern_ipc_perm structure, no need to have it as an argument to the routine Signed-off-by: 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/util.h')
-rw-r--r--ipc/util.h32
1 files changed, 8 insertions, 24 deletions
diff --git a/ipc/util.h b/ipc/util.h
index 333e891bcaca..c9063267d4f8 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -10,6 +10,8 @@
10#ifndef _IPC_UTIL_H 10#ifndef _IPC_UTIL_H
11#define _IPC_UTIL_H 11#define _IPC_UTIL_H
12 12
13#include <linux/idr.h>
14
13#define USHRT_MAX 0xffff 15#define USHRT_MAX 0xffff
14#define SEQ_MULTIPLIER (IPCMNI) 16#define SEQ_MULTIPLIER (IPCMNI)
15 17
@@ -25,24 +27,17 @@ void sem_exit_ns(struct ipc_namespace *ns);
25void msg_exit_ns(struct ipc_namespace *ns); 27void msg_exit_ns(struct ipc_namespace *ns);
26void shm_exit_ns(struct ipc_namespace *ns); 28void shm_exit_ns(struct ipc_namespace *ns);
27 29
28struct ipc_id_ary {
29 int size;
30 struct kern_ipc_perm *p[0];
31};
32
33struct ipc_ids { 30struct ipc_ids {
34 int in_use; 31 int in_use;
35 int max_id;
36 unsigned short seq; 32 unsigned short seq;
37 unsigned short seq_max; 33 unsigned short seq_max;
38 struct mutex mutex; 34 struct mutex mutex;
39 struct ipc_id_ary nullentry; 35 struct idr ipcs_idr;
40 struct ipc_id_ary* entries;
41}; 36};
42 37
43struct seq_file; 38struct seq_file;
44 39
45void ipc_init_ids(struct ipc_ids *ids, int size); 40void ipc_init_ids(struct ipc_ids *);
46#ifdef CONFIG_PROC_FS 41#ifdef CONFIG_PROC_FS
47void __init ipc_init_proc_interface(const char *path, const char *header, 42void __init ipc_init_proc_interface(const char *path, const char *header,
48 int ids, int (*show)(struct seq_file *, void *)); 43 int ids, int (*show)(struct seq_file *, void *));
@@ -55,11 +50,12 @@ void __init ipc_init_proc_interface(const char *path, const char *header,
55#define IPC_SHM_IDS 2 50#define IPC_SHM_IDS 2
56 51
57/* must be called with ids->mutex acquired.*/ 52/* must be called with ids->mutex acquired.*/
58int ipc_findkey(struct ipc_ids* ids, key_t key); 53struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key);
59int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size); 54int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int);
55int ipc_get_maxid(struct ipc_ids *);
60 56
61/* must be called with both locks acquired. */ 57/* must be called with both locks acquired. */
62struct kern_ipc_perm* ipc_rmid(struct ipc_ids* ids, int id); 58void ipc_rmid(struct ipc_ids *, struct kern_ipc_perm *);
63 59
64int ipcperms (struct kern_ipc_perm *ipcp, short flg); 60int ipcperms (struct kern_ipc_perm *ipcp, short flg);
65 61
@@ -79,18 +75,6 @@ void* ipc_rcu_alloc(int size);
79void ipc_rcu_getref(void *ptr); 75void ipc_rcu_getref(void *ptr);
80void ipc_rcu_putref(void *ptr); 76void ipc_rcu_putref(void *ptr);
81 77
82static inline void __ipc_fini_ids(struct ipc_ids *ids,
83 struct ipc_id_ary *entries)
84{
85 if (entries != &ids->nullentry)
86 ipc_rcu_putref(entries);
87}
88
89static inline void ipc_fini_ids(struct ipc_ids *ids)
90{
91 __ipc_fini_ids(ids, ids->entries);
92}
93
94struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id); 78struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id);
95struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id); 79struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id);
96void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp); 80void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp);