diff options
author | Nadia Derbey <Nadia.Derbey@bull.net> | 2007-10-19 02:40:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-19 14:53:44 -0400 |
commit | 7ca7e564e049d8b350ec9d958ff25eaa24226352 (patch) | |
tree | e3c1397dc898dbd7c685c6a052425e7346eb79d1 /ipc/util.h | |
parent | d2b20b11547cefc89d6c81937e81afaf3c62808b (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.h | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/ipc/util.h b/ipc/util.h index 333e891bcac..c9063267d4f 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); | |||
25 | void msg_exit_ns(struct ipc_namespace *ns); | 27 | void msg_exit_ns(struct ipc_namespace *ns); |
26 | void shm_exit_ns(struct ipc_namespace *ns); | 28 | void shm_exit_ns(struct ipc_namespace *ns); |
27 | 29 | ||
28 | struct ipc_id_ary { | ||
29 | int size; | ||
30 | struct kern_ipc_perm *p[0]; | ||
31 | }; | ||
32 | |||
33 | struct ipc_ids { | 30 | struct 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 | ||
43 | struct seq_file; | 38 | struct seq_file; |
44 | 39 | ||
45 | void ipc_init_ids(struct ipc_ids *ids, int size); | 40 | void ipc_init_ids(struct ipc_ids *); |
46 | #ifdef CONFIG_PROC_FS | 41 | #ifdef CONFIG_PROC_FS |
47 | void __init ipc_init_proc_interface(const char *path, const char *header, | 42 | void __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.*/ |
58 | int ipc_findkey(struct ipc_ids* ids, key_t key); | 53 | struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key); |
59 | int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size); | 54 | int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int); |
55 | int ipc_get_maxid(struct ipc_ids *); | ||
60 | 56 | ||
61 | /* must be called with both locks acquired. */ | 57 | /* must be called with both locks acquired. */ |
62 | struct kern_ipc_perm* ipc_rmid(struct ipc_ids* ids, int id); | 58 | void ipc_rmid(struct ipc_ids *, struct kern_ipc_perm *); |
63 | 59 | ||
64 | int ipcperms (struct kern_ipc_perm *ipcp, short flg); | 60 | int ipcperms (struct kern_ipc_perm *ipcp, short flg); |
65 | 61 | ||
@@ -79,18 +75,6 @@ void* ipc_rcu_alloc(int size); | |||
79 | void ipc_rcu_getref(void *ptr); | 75 | void ipc_rcu_getref(void *ptr); |
80 | void ipc_rcu_putref(void *ptr); | 76 | void ipc_rcu_putref(void *ptr); |
81 | 77 | ||
82 | static 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 | |||
89 | static inline void ipc_fini_ids(struct ipc_ids *ids) | ||
90 | { | ||
91 | __ipc_fini_ids(ids, ids->entries); | ||
92 | } | ||
93 | |||
94 | struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id); | 78 | struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id); |
95 | struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id); | 79 | struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id); |
96 | void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp); | 80 | void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp); |