aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-03-21 01:33:17 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-21 01:33:17 -0500
commit4a3e2f711a00a1feb72ae12fdc749da10179d185 (patch)
tree76ced9d3270dea4b864da71fa1d4415d2e3c8b11 /net/sunrpc/cache.c
parentd4ccd08cdfa8d34f4d25b62041343c52fc79385f (diff)
[NET] sem2mutex: net/
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r--net/sunrpc/cache.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index dcaa0c4453ff..0acccfeeb284 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -26,6 +26,7 @@
26#include <linux/proc_fs.h> 26#include <linux/proc_fs.h>
27#include <linux/net.h> 27#include <linux/net.h>
28#include <linux/workqueue.h> 28#include <linux/workqueue.h>
29#include <linux/mutex.h>
29#include <asm/ioctls.h> 30#include <asm/ioctls.h>
30#include <linux/sunrpc/types.h> 31#include <linux/sunrpc/types.h>
31#include <linux/sunrpc/cache.h> 32#include <linux/sunrpc/cache.h>
@@ -532,7 +533,7 @@ void cache_clean_deferred(void *owner)
532 */ 533 */
533 534
534static DEFINE_SPINLOCK(queue_lock); 535static DEFINE_SPINLOCK(queue_lock);
535static DECLARE_MUTEX(queue_io_sem); 536static DEFINE_MUTEX(queue_io_mutex);
536 537
537struct cache_queue { 538struct cache_queue {
538 struct list_head list; 539 struct list_head list;
@@ -561,7 +562,7 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
561 if (count == 0) 562 if (count == 0)
562 return 0; 563 return 0;
563 564
564 down(&queue_io_sem); /* protect against multiple concurrent 565 mutex_lock(&queue_io_mutex); /* protect against multiple concurrent
565 * readers on this file */ 566 * readers on this file */
566 again: 567 again:
567 spin_lock(&queue_lock); 568 spin_lock(&queue_lock);
@@ -574,7 +575,7 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
574 } 575 }
575 if (rp->q.list.next == &cd->queue) { 576 if (rp->q.list.next == &cd->queue) {
576 spin_unlock(&queue_lock); 577 spin_unlock(&queue_lock);
577 up(&queue_io_sem); 578 mutex_unlock(&queue_io_mutex);
578 BUG_ON(rp->offset); 579 BUG_ON(rp->offset);
579 return 0; 580 return 0;
580 } 581 }
@@ -621,11 +622,11 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
621 } 622 }
622 if (err == -EAGAIN) 623 if (err == -EAGAIN)
623 goto again; 624 goto again;
624 up(&queue_io_sem); 625 mutex_unlock(&queue_io_mutex);
625 return err ? err : count; 626 return err ? err : count;
626} 627}
627 628
628static char write_buf[8192]; /* protected by queue_io_sem */ 629static char write_buf[8192]; /* protected by queue_io_mutex */
629 630
630static ssize_t 631static ssize_t
631cache_write(struct file *filp, const char __user *buf, size_t count, 632cache_write(struct file *filp, const char __user *buf, size_t count,
@@ -639,10 +640,10 @@ cache_write(struct file *filp, const char __user *buf, size_t count,
639 if (count >= sizeof(write_buf)) 640 if (count >= sizeof(write_buf))
640 return -EINVAL; 641 return -EINVAL;
641 642
642 down(&queue_io_sem); 643 mutex_lock(&queue_io_mutex);
643 644
644 if (copy_from_user(write_buf, buf, count)) { 645 if (copy_from_user(write_buf, buf, count)) {
645 up(&queue_io_sem); 646 mutex_unlock(&queue_io_mutex);
646 return -EFAULT; 647 return -EFAULT;
647 } 648 }
648 write_buf[count] = '\0'; 649 write_buf[count] = '\0';
@@ -651,7 +652,7 @@ cache_write(struct file *filp, const char __user *buf, size_t count,
651 else 652 else
652 err = -EINVAL; 653 err = -EINVAL;
653 654
654 up(&queue_io_sem); 655 mutex_unlock(&queue_io_mutex);
655 return err ? err : count; 656 return err ? err : count;
656} 657}
657 658