diff options
author | Davidlohr Bueso <davidlohr.bueso@hp.com> | 2013-09-11 17:26:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:59:42 -0400 |
commit | d9a605e40b1376eb02b067d7690580255a0df68f (patch) | |
tree | b21254f7172ae8db6faffd9b7941d579fa421478 /ipc/msg.c | |
parent | c2c737a0461e61a34676bd0bd1bc1a70a1b4e396 (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/msg.c')
-rw-r--r-- | ipc/msg.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -172,7 +172,7 @@ static inline void msg_rmid(struct ipc_namespace *ns, struct msg_queue *s) | |||
172 | * @ns: namespace | 172 | * @ns: namespace |
173 | * @params: ptr to the structure that contains the key and msgflg | 173 | * @params: ptr to the structure that contains the key and msgflg |
174 | * | 174 | * |
175 | * Called with msg_ids.rw_mutex held (writer) | 175 | * Called with msg_ids.rwsem held (writer) |
176 | */ | 176 | */ |
177 | static int newque(struct ipc_namespace *ns, struct ipc_params *params) | 177 | static int newque(struct ipc_namespace *ns, struct ipc_params *params) |
178 | { | 178 | { |
@@ -259,8 +259,8 @@ static void expunge_all(struct msg_queue *msq, int res) | |||
259 | * removes the message queue from message queue ID IDR, and cleans up all the | 259 | * removes the message queue from message queue ID IDR, and cleans up all the |
260 | * messages associated with this queue. | 260 | * messages associated with this queue. |
261 | * | 261 | * |
262 | * msg_ids.rw_mutex (writer) and the spinlock for this message queue are held | 262 | * msg_ids.rwsem (writer) and the spinlock for this message queue are held |
263 | * before freeque() is called. msg_ids.rw_mutex remains locked on exit. | 263 | * before freeque() is called. msg_ids.rwsem remains locked on exit. |
264 | */ | 264 | */ |
265 | static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) | 265 | static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) |
266 | { | 266 | { |
@@ -282,7 +282,7 @@ static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) | |||
282 | } | 282 | } |
283 | 283 | ||
284 | /* | 284 | /* |
285 | * Called with msg_ids.rw_mutex and ipcp locked. | 285 | * Called with msg_ids.rwsem and ipcp locked. |
286 | */ | 286 | */ |
287 | static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg) | 287 | static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg) |
288 | { | 288 | { |
@@ -386,9 +386,9 @@ copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version) | |||
386 | } | 386 | } |
387 | 387 | ||
388 | /* | 388 | /* |
389 | * This function handles some msgctl commands which require the rw_mutex | 389 | * This function handles some msgctl commands which require the rwsem |
390 | * to be held in write mode. | 390 | * to be held in write mode. |
391 | * NOTE: no locks must be held, the rw_mutex is taken inside this function. | 391 | * NOTE: no locks must be held, the rwsem is taken inside this function. |
392 | */ | 392 | */ |
393 | static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, | 393 | static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, |
394 | struct msqid_ds __user *buf, int version) | 394 | struct msqid_ds __user *buf, int version) |
@@ -403,7 +403,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, | |||
403 | return -EFAULT; | 403 | return -EFAULT; |
404 | } | 404 | } |
405 | 405 | ||
406 | down_write(&msg_ids(ns).rw_mutex); | 406 | down_write(&msg_ids(ns).rwsem); |
407 | rcu_read_lock(); | 407 | rcu_read_lock(); |
408 | 408 | ||
409 | ipcp = ipcctl_pre_down_nolock(ns, &msg_ids(ns), msqid, cmd, | 409 | ipcp = ipcctl_pre_down_nolock(ns, &msg_ids(ns), msqid, cmd, |
@@ -459,7 +459,7 @@ out_unlock0: | |||
459 | out_unlock1: | 459 | out_unlock1: |
460 | rcu_read_unlock(); | 460 | rcu_read_unlock(); |
461 | out_up: | 461 | out_up: |
462 | up_write(&msg_ids(ns).rw_mutex); | 462 | up_write(&msg_ids(ns).rwsem); |
463 | return err; | 463 | return err; |
464 | } | 464 | } |
465 | 465 | ||
@@ -494,7 +494,7 @@ static int msgctl_nolock(struct ipc_namespace *ns, int msqid, | |||
494 | msginfo.msgmnb = ns->msg_ctlmnb; | 494 | msginfo.msgmnb = ns->msg_ctlmnb; |
495 | msginfo.msgssz = MSGSSZ; | 495 | msginfo.msgssz = MSGSSZ; |
496 | msginfo.msgseg = MSGSEG; | 496 | msginfo.msgseg = MSGSEG; |
497 | down_read(&msg_ids(ns).rw_mutex); | 497 | down_read(&msg_ids(ns).rwsem); |
498 | if (cmd == MSG_INFO) { | 498 | if (cmd == MSG_INFO) { |
499 | msginfo.msgpool = msg_ids(ns).in_use; | 499 | msginfo.msgpool = msg_ids(ns).in_use; |
500 | msginfo.msgmap = atomic_read(&ns->msg_hdrs); | 500 | msginfo.msgmap = atomic_read(&ns->msg_hdrs); |
@@ -505,7 +505,7 @@ static int msgctl_nolock(struct ipc_namespace *ns, int msqid, | |||
505 | msginfo.msgtql = MSGTQL; | 505 | msginfo.msgtql = MSGTQL; |
506 | } | 506 | } |
507 | max_id = ipc_get_maxid(&msg_ids(ns)); | 507 | max_id = ipc_get_maxid(&msg_ids(ns)); |
508 | up_read(&msg_ids(ns).rw_mutex); | 508 | up_read(&msg_ids(ns).rwsem); |
509 | if (copy_to_user(buf, &msginfo, sizeof(struct msginfo))) | 509 | if (copy_to_user(buf, &msginfo, sizeof(struct msginfo))) |
510 | return -EFAULT; | 510 | return -EFAULT; |
511 | return (max_id < 0) ? 0 : max_id; | 511 | return (max_id < 0) ? 0 : max_id; |