aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fuse/dev.c')
-rw-r--r--fs/fuse/dev.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 75c6e9166c39..c510533c6849 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -23,13 +23,11 @@ static kmem_cache_t *fuse_req_cachep;
23 23
24static struct fuse_conn *fuse_get_conn(struct file *file) 24static struct fuse_conn *fuse_get_conn(struct file *file)
25{ 25{
26 struct fuse_conn *fc; 26 /*
27 spin_lock(&fuse_lock); 27 * Lockless access is OK, because file->private data is set
28 fc = file->private_data; 28 * once during mount and is valid until the file is released.
29 if (fc && !fc->connected) 29 */
30 fc = NULL; 30 return file->private_data;
31 spin_unlock(&fuse_lock);
32 return fc;
33} 31}
34 32
35static void fuse_request_init(struct fuse_req *req) 33static void fuse_request_init(struct fuse_req *req)
@@ -607,19 +605,16 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
607 unsigned long nr_segs, loff_t *off) 605 unsigned long nr_segs, loff_t *off)
608{ 606{
609 int err; 607 int err;
610 struct fuse_conn *fc;
611 struct fuse_req *req; 608 struct fuse_req *req;
612 struct fuse_in *in; 609 struct fuse_in *in;
613 struct fuse_copy_state cs; 610 struct fuse_copy_state cs;
614 unsigned reqsize; 611 unsigned reqsize;
612 struct fuse_conn *fc = fuse_get_conn(file);
613 if (!fc)
614 return -EPERM;
615 615
616 restart: 616 restart:
617 spin_lock(&fuse_lock); 617 spin_lock(&fuse_lock);
618 fc = file->private_data;
619 err = -EPERM;
620 if (!fc)
621 goto err_unlock;
622
623 err = -EAGAIN; 618 err = -EAGAIN;
624 if ((file->f_flags & O_NONBLOCK) && fc->connected && 619 if ((file->f_flags & O_NONBLOCK) && fc->connected &&
625 list_empty(&fc->pending)) 620 list_empty(&fc->pending))
@@ -915,17 +910,13 @@ void fuse_abort_conn(struct fuse_conn *fc)
915 910
916static int fuse_dev_release(struct inode *inode, struct file *file) 911static int fuse_dev_release(struct inode *inode, struct file *file)
917{ 912{
918 struct fuse_conn *fc; 913 struct fuse_conn *fc = fuse_get_conn(file);
919
920 spin_lock(&fuse_lock);
921 fc = file->private_data;
922 if (fc) { 914 if (fc) {
915 spin_lock(&fuse_lock);
923 fc->connected = 0; 916 fc->connected = 0;
924 end_requests(fc, &fc->pending); 917 end_requests(fc, &fc->pending);
925 end_requests(fc, &fc->processing); 918 end_requests(fc, &fc->processing);
926 } 919 spin_unlock(&fuse_lock);
927 spin_unlock(&fuse_lock);
928 if (fc) {
929 fasync_helper(-1, file, 0, &fc->fasync); 920 fasync_helper(-1, file, 0, &fc->fasync);
930 kobject_put(&fc->kobj); 921 kobject_put(&fc->kobj);
931 } 922 }