fuse: Protect ff->reserved_req via corresponding fi->lock
authorKirill Tkhai <ktkhai@virtuozzo.com>
Fri, 9 Nov 2018 10:33:32 +0000 (13:33 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 13 Feb 2019 12:15:14 +0000 (13:15 +0100)
This is rather natural action after previous patches, and it just decreases
load of fc->lock.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/dev.c
fs/fuse/fuse_i.h

index ed9318d4e7dc2a45abab412c90192f79a1e98d57..5a7309427e0e77d11f949bd1e00db01c64e18ca9 100644 (file)
@@ -251,17 +251,18 @@ static struct fuse_req *get_reserved_req(struct fuse_conn *fc,
                                         struct file *file)
 {
        struct fuse_req *req = NULL;
+       struct fuse_inode *fi = get_fuse_inode(file_inode(file));
        struct fuse_file *ff = file->private_data;
 
        do {
                wait_event(fc->reserved_req_waitq, ff->reserved_req);
-               spin_lock(&fc->lock);
+               spin_lock(&fi->lock);
                if (ff->reserved_req) {
                        req = ff->reserved_req;
                        ff->reserved_req = NULL;
                        req->stolen_file = get_file(file);
                }
-               spin_unlock(&fc->lock);
+               spin_unlock(&fi->lock);
        } while (!req);
 
        return req;
@@ -273,16 +274,17 @@ static struct fuse_req *get_reserved_req(struct fuse_conn *fc,
 static void put_reserved_req(struct fuse_conn *fc, struct fuse_req *req)
 {
        struct file *file = req->stolen_file;
+       struct fuse_inode *fi = get_fuse_inode(file_inode(file));
        struct fuse_file *ff = file->private_data;
 
        WARN_ON(req->max_pages);
-       spin_lock(&fc->lock);
+       spin_lock(&fi->lock);
        memset(req, 0, sizeof(*req));
        fuse_request_init(req, NULL, NULL, 0);
        BUG_ON(ff->reserved_req);
        ff->reserved_req = req;
        wake_up_all(&fc->reserved_req_waitq);
-       spin_unlock(&fc->lock);
+       spin_unlock(&fi->lock);
        fput(file);
 }
 
index 1c610b65b1bfbd54b5b079c3dccbc2d05f2fd93d..4fdd098e422d756363e86ca8420c7dde22b46563 100644 (file)
@@ -166,7 +166,10 @@ struct fuse_file {
        /** Fuse connection for this file */
        struct fuse_conn *fc;
 
-       /** Request reserved for flush and release */
+       /*
+        * Request reserved for flush and release.
+        * Modified under relative fuse_inode::lock.
+        */
        struct fuse_req *reserved_req;
 
        /** Kernel file handle guaranteed to be unique */