aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/util.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <davidlohr.bueso@hp.com>2013-09-11 17:26:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:59:42 -0400
commitd9a605e40b1376eb02b067d7690580255a0df68f (patch)
treeb21254f7172ae8db6faffd9b7941d579fa421478 /ipc/util.c
parentc2c737a0461e61a34676bd0bd1bc1a70a1b4e396 (diff)
ipc: rename ids->rw_mutex
Since in some situations the lock can be shared for readers, we shouldn't be calling it a mutex, rename it to rwsem. Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> Cc: Rik van Riel <riel@redhat.com> Cc: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc/util.c')
-rw-r--r--ipc/util.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/ipc/util.c b/ipc/util.c
index 2c8a93b380ba..9a1d779a20e2 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -119,7 +119,7 @@ __initcall(ipc_init);
119 119
120void ipc_init_ids(struct ipc_ids *ids) 120void ipc_init_ids(struct ipc_ids *ids)
121{ 121{
122 init_rwsem(&ids->rw_mutex); 122 init_rwsem(&ids->rwsem);
123 123
124 ids->in_use = 0; 124 ids->in_use = 0;
125 ids->seq = 0; 125 ids->seq = 0;
@@ -174,7 +174,7 @@ void __init ipc_init_proc_interface(const char *path, const char *header,
174 * @ids: Identifier set 174 * @ids: Identifier set
175 * @key: The key to find 175 * @key: The key to find
176 * 176 *
177 * Requires ipc_ids.rw_mutex locked. 177 * Requires ipc_ids.rwsem locked.
178 * Returns the LOCKED pointer to the ipc structure if found or NULL 178 * Returns the LOCKED pointer to the ipc structure if found or NULL
179 * if not. 179 * if not.
180 * If key is found ipc points to the owning ipc structure 180 * If key is found ipc points to the owning ipc structure
@@ -208,7 +208,7 @@ static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key)
208 * ipc_get_maxid - get the last assigned id 208 * ipc_get_maxid - get the last assigned id
209 * @ids: IPC identifier set 209 * @ids: IPC identifier set
210 * 210 *
211 * Called with ipc_ids.rw_mutex held. 211 * Called with ipc_ids.rwsem held.
212 */ 212 */
213 213
214int ipc_get_maxid(struct ipc_ids *ids) 214int ipc_get_maxid(struct ipc_ids *ids)
@@ -246,7 +246,7 @@ int ipc_get_maxid(struct ipc_ids *ids)
246 * is returned. The 'new' entry is returned in a locked state on success. 246 * is returned. The 'new' entry is returned in a locked state on success.
247 * On failure the entry is not locked and a negative err-code is returned. 247 * On failure the entry is not locked and a negative err-code is returned.
248 * 248 *
249 * Called with writer ipc_ids.rw_mutex held. 249 * Called with writer ipc_ids.rwsem held.
250 */ 250 */
251int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size) 251int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
252{ 252{
@@ -312,9 +312,9 @@ static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids,
312{ 312{
313 int err; 313 int err;
314 314
315 down_write(&ids->rw_mutex); 315 down_write(&ids->rwsem);
316 err = ops->getnew(ns, params); 316 err = ops->getnew(ns, params);
317 up_write(&ids->rw_mutex); 317 up_write(&ids->rwsem);
318 return err; 318 return err;
319} 319}
320 320
@@ -331,7 +331,7 @@ static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids,
331 * 331 *
332 * On success, the IPC id is returned. 332 * On success, the IPC id is returned.
333 * 333 *
334 * It is called with ipc_ids.rw_mutex and ipcp->lock held. 334 * It is called with ipc_ids.rwsem and ipcp->lock held.
335 */ 335 */
336static int ipc_check_perms(struct ipc_namespace *ns, 336static int ipc_check_perms(struct ipc_namespace *ns,
337 struct kern_ipc_perm *ipcp, 337 struct kern_ipc_perm *ipcp,
@@ -376,7 +376,7 @@ static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
376 * Take the lock as a writer since we are potentially going to add 376 * Take the lock as a writer since we are potentially going to add
377 * a new entry + read locks are not "upgradable" 377 * a new entry + read locks are not "upgradable"
378 */ 378 */
379 down_write(&ids->rw_mutex); 379 down_write(&ids->rwsem);
380 ipcp = ipc_findkey(ids, params->key); 380 ipcp = ipc_findkey(ids, params->key);
381 if (ipcp == NULL) { 381 if (ipcp == NULL) {
382 /* key not used */ 382 /* key not used */
@@ -402,7 +402,7 @@ static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
402 } 402 }
403 ipc_unlock(ipcp); 403 ipc_unlock(ipcp);
404 } 404 }
405 up_write(&ids->rw_mutex); 405 up_write(&ids->rwsem);
406 406
407 return err; 407 return err;
408} 408}
@@ -413,7 +413,7 @@ static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
413 * @ids: IPC identifier set 413 * @ids: IPC identifier set
414 * @ipcp: ipc perm structure containing the identifier to remove 414 * @ipcp: ipc perm structure containing the identifier to remove
415 * 415 *
416 * ipc_ids.rw_mutex (as a writer) and the spinlock for this ID are held 416 * ipc_ids.rwsem (as a writer) and the spinlock for this ID are held
417 * before this function is called, and remain locked on the exit. 417 * before this function is called, and remain locked on the exit.
418 */ 418 */
419 419
@@ -621,7 +621,7 @@ struct kern_ipc_perm *ipc_obtain_object(struct ipc_ids *ids, int id)
621} 621}
622 622
623/** 623/**
624 * ipc_lock - Lock an ipc structure without rw_mutex held 624 * ipc_lock - Lock an ipc structure without rwsem held
625 * @ids: IPC identifier set 625 * @ids: IPC identifier set
626 * @id: ipc id to look for 626 * @id: ipc id to look for
627 * 627 *
@@ -748,7 +748,7 @@ int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out)
748 * - performs some audit and permission check, depending on the given cmd 748 * - performs some audit and permission check, depending on the given cmd
749 * - returns a pointer to the ipc object or otherwise, the corresponding error. 749 * - returns a pointer to the ipc object or otherwise, the corresponding error.
750 * 750 *
751 * Call holding the both the rw_mutex and the rcu read lock. 751 * Call holding the both the rwsem and the rcu read lock.
752 */ 752 */
753struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns, 753struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns,
754 struct ipc_ids *ids, int id, int cmd, 754 struct ipc_ids *ids, int id, int cmd,
@@ -868,7 +868,7 @@ static void *sysvipc_proc_start(struct seq_file *s, loff_t *pos)
868 * Take the lock - this will be released by the corresponding 868 * Take the lock - this will be released by the corresponding
869 * call to stop(). 869 * call to stop().
870 */ 870 */
871 down_read(&ids->rw_mutex); 871 down_read(&ids->rwsem);
872 872
873 /* pos < 0 is invalid */ 873 /* pos < 0 is invalid */
874 if (*pos < 0) 874 if (*pos < 0)
@@ -895,7 +895,7 @@ static void sysvipc_proc_stop(struct seq_file *s, void *it)
895 895
896 ids = &iter->ns->ids[iface->ids]; 896 ids = &iter->ns->ids[iface->ids];
897 /* Release the lock we took in start() */ 897 /* Release the lock we took in start() */
898 up_read(&ids->rw_mutex); 898 up_read(&ids->rwsem);
899} 899}
900 900
901static int sysvipc_proc_show(struct seq_file *s, void *it) 901static int sysvipc_proc_show(struct seq_file *s, void *it)