diff options
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r-- | net/sunrpc/cache.c | 17 |
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 | ||
534 | static DEFINE_SPINLOCK(queue_lock); | 535 | static DEFINE_SPINLOCK(queue_lock); |
535 | static DECLARE_MUTEX(queue_io_sem); | 536 | static DEFINE_MUTEX(queue_io_mutex); |
536 | 537 | ||
537 | struct cache_queue { | 538 | struct 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 | ||
628 | static char write_buf[8192]; /* protected by queue_io_sem */ | 629 | static char write_buf[8192]; /* protected by queue_io_mutex */ |
629 | 630 | ||
630 | static ssize_t | 631 | static ssize_t |
631 | cache_write(struct file *filp, const char __user *buf, size_t count, | 632 | cache_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 | ||