diff options
author | Yoshihisa Abe <yoshiabe@cs.cmu.edu> | 2010-10-25 02:03:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-25 11:02:40 -0400 |
commit | da47c19e5c746829042933c8f945a71e2b62d6fc (patch) | |
tree | 54110db260f57c01745e1ace343ec72b7eec6c69 /fs/coda/upcall.c | |
parent | f7cc02b8715618e179242ba9cc10bdc5146ae565 (diff) |
Coda: replace BKL with mutex
Replace the BKL with a mutex to protect the venus_comm structure which
binds the mountpoint with the character device and holds the upcall
queues.
Signed-off-by: Yoshihisa Abe <yoshiabe@cs.cmu.edu>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/coda/upcall.c')
-rw-r--r-- | fs/coda/upcall.c | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index 4c258cb5266d..c3563cab9758 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
28 | #include <linux/string.h> | 28 | #include <linux/string.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/smp_lock.h> | 30 | #include <linux/mutex.h> |
31 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
32 | #include <linux/vmalloc.h> | 32 | #include <linux/vmalloc.h> |
33 | #include <linux/vfs.h> | 33 | #include <linux/vfs.h> |
@@ -607,7 +607,8 @@ static void coda_unblock_signals(sigset_t *old) | |||
607 | (r)->uc_opcode != CODA_RELEASE) || \ | 607 | (r)->uc_opcode != CODA_RELEASE) || \ |
608 | (r)->uc_flags & CODA_REQ_READ)) | 608 | (r)->uc_flags & CODA_REQ_READ)) |
609 | 609 | ||
610 | static inline void coda_waitfor_upcall(struct upc_req *req) | 610 | static inline void coda_waitfor_upcall(struct venus_comm *vcp, |
611 | struct upc_req *req) | ||
611 | { | 612 | { |
612 | DECLARE_WAITQUEUE(wait, current); | 613 | DECLARE_WAITQUEUE(wait, current); |
613 | unsigned long timeout = jiffies + coda_timeout * HZ; | 614 | unsigned long timeout = jiffies + coda_timeout * HZ; |
@@ -640,10 +641,12 @@ static inline void coda_waitfor_upcall(struct upc_req *req) | |||
640 | break; | 641 | break; |
641 | } | 642 | } |
642 | 643 | ||
644 | mutex_unlock(&vcp->vc_mutex); | ||
643 | if (blocked) | 645 | if (blocked) |
644 | schedule_timeout(HZ); | 646 | schedule_timeout(HZ); |
645 | else | 647 | else |
646 | schedule(); | 648 | schedule(); |
649 | mutex_lock(&vcp->vc_mutex); | ||
647 | } | 650 | } |
648 | if (blocked) | 651 | if (blocked) |
649 | coda_unblock_signals(&old); | 652 | coda_unblock_signals(&old); |
@@ -671,7 +674,7 @@ static int coda_upcall(struct venus_comm *vcp, | |||
671 | struct upc_req *req = NULL, *sig_req; | 674 | struct upc_req *req = NULL, *sig_req; |
672 | int error; | 675 | int error; |
673 | 676 | ||
674 | lock_kernel(); | 677 | mutex_lock(&vcp->vc_mutex); |
675 | 678 | ||
676 | if (!vcp->vc_inuse) { | 679 | if (!vcp->vc_inuse) { |
677 | printk(KERN_NOTICE "coda: Venus dead, not sending upcall\n"); | 680 | printk(KERN_NOTICE "coda: Venus dead, not sending upcall\n"); |
@@ -711,7 +714,7 @@ static int coda_upcall(struct venus_comm *vcp, | |||
711 | * ENODEV. */ | 714 | * ENODEV. */ |
712 | 715 | ||
713 | /* Go to sleep. Wake up on signals only after the timeout. */ | 716 | /* Go to sleep. Wake up on signals only after the timeout. */ |
714 | coda_waitfor_upcall(req); | 717 | coda_waitfor_upcall(vcp, req); |
715 | 718 | ||
716 | /* Op went through, interrupt or not... */ | 719 | /* Op went through, interrupt or not... */ |
717 | if (req->uc_flags & CODA_REQ_WRITE) { | 720 | if (req->uc_flags & CODA_REQ_WRITE) { |
@@ -765,7 +768,7 @@ static int coda_upcall(struct venus_comm *vcp, | |||
765 | 768 | ||
766 | exit: | 769 | exit: |
767 | kfree(req); | 770 | kfree(req); |
768 | unlock_kernel(); | 771 | mutex_unlock(&vcp->vc_mutex); |
769 | return error; | 772 | return error; |
770 | } | 773 | } |
771 | 774 | ||
@@ -806,11 +809,11 @@ exit: | |||
806 | int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out) | 809 | int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out) |
807 | { | 810 | { |
808 | struct inode *inode = NULL; | 811 | struct inode *inode = NULL; |
809 | struct CodaFid *fid, *newfid; | 812 | struct CodaFid *fid = NULL, *newfid; |
810 | struct super_block *sb; | 813 | struct super_block *sb; |
811 | 814 | ||
812 | /* Handle invalidation requests. */ | 815 | /* Handle invalidation requests. */ |
813 | lock_kernel(); | 816 | mutex_lock(&vcp->vc_mutex); |
814 | sb = vcp->vc_sb; | 817 | sb = vcp->vc_sb; |
815 | if (!sb || !sb->s_root) | 818 | if (!sb || !sb->s_root) |
816 | goto unlock_out; | 819 | goto unlock_out; |
@@ -829,47 +832,53 @@ int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out) | |||
829 | 832 | ||
830 | case CODA_ZAPDIR: | 833 | case CODA_ZAPDIR: |
831 | fid = &out->coda_zapdir.CodaFid; | 834 | fid = &out->coda_zapdir.CodaFid; |
832 | inode = coda_fid_to_inode(fid, sb); | ||
833 | if (inode) { | ||
834 | coda_flag_inode_children(inode, C_PURGE); | ||
835 | coda_flag_inode(inode, C_VATTR); | ||
836 | } | ||
837 | break; | 835 | break; |
838 | 836 | ||
839 | case CODA_ZAPFILE: | 837 | case CODA_ZAPFILE: |
840 | fid = &out->coda_zapfile.CodaFid; | 838 | fid = &out->coda_zapfile.CodaFid; |
841 | inode = coda_fid_to_inode(fid, sb); | ||
842 | if (inode) | ||
843 | coda_flag_inode(inode, C_VATTR); | ||
844 | break; | 839 | break; |
845 | 840 | ||
846 | case CODA_PURGEFID: | 841 | case CODA_PURGEFID: |
847 | fid = &out->coda_purgefid.CodaFid; | 842 | fid = &out->coda_purgefid.CodaFid; |
848 | inode = coda_fid_to_inode(fid, sb); | ||
849 | if (inode) { | ||
850 | coda_flag_inode_children(inode, C_PURGE); | ||
851 | |||
852 | /* catch the dentries later if some are still busy */ | ||
853 | coda_flag_inode(inode, C_PURGE); | ||
854 | d_prune_aliases(inode); | ||
855 | |||
856 | } | ||
857 | break; | 843 | break; |
858 | 844 | ||
859 | case CODA_REPLACE: | 845 | case CODA_REPLACE: |
860 | fid = &out->coda_replace.OldFid; | 846 | fid = &out->coda_replace.OldFid; |
861 | newfid = &out->coda_replace.NewFid; | ||
862 | inode = coda_fid_to_inode(fid, sb); | ||
863 | if (inode) | ||
864 | coda_replace_fid(inode, fid, newfid); | ||
865 | break; | 847 | break; |
866 | } | 848 | } |
849 | if (fid) | ||
850 | inode = coda_fid_to_inode(fid, sb); | ||
867 | 851 | ||
868 | unlock_out: | 852 | unlock_out: |
869 | unlock_kernel(); | 853 | mutex_unlock(&vcp->vc_mutex); |
854 | |||
855 | if (!inode) | ||
856 | return 0; | ||
857 | |||
858 | switch (opcode) { | ||
859 | case CODA_ZAPDIR: | ||
860 | coda_flag_inode_children(inode, C_PURGE); | ||
861 | coda_flag_inode(inode, C_VATTR); | ||
862 | break; | ||
863 | |||
864 | case CODA_ZAPFILE: | ||
865 | coda_flag_inode(inode, C_VATTR); | ||
866 | break; | ||
867 | |||
868 | case CODA_PURGEFID: | ||
869 | coda_flag_inode_children(inode, C_PURGE); | ||
870 | 870 | ||
871 | if (inode) | 871 | /* catch the dentries later if some are still busy */ |
872 | iput(inode); | 872 | coda_flag_inode(inode, C_PURGE); |
873 | d_prune_aliases(inode); | ||
874 | break; | ||
875 | |||
876 | case CODA_REPLACE: | ||
877 | newfid = &out->coda_replace.NewFid; | ||
878 | coda_replace_fid(inode, fid, newfid); | ||
879 | break; | ||
880 | } | ||
881 | iput(inode); | ||
873 | return 0; | 882 | return 0; |
874 | } | 883 | } |
875 | 884 | ||