[Devel] [PATCH 8/8] fuse: Protect ff->reserved_req via corresponding fi->lock

Kirill Tkhai ktkhai at virtuozzo.com
Wed Apr 3 18:37:43 MSK 2019


ms commit 6b675738ce90

This is rather natural action after previous patches, and it just decreases
load of fc->lock.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
Signed-off-by: Miklos Szeredi <mszeredi at redhat.com>
---
 fs/fuse/dev.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 1355f4a0a8e4..d10e7edd8711 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -238,16 +238,17 @@ static struct fuse_req *get_reserved_req(struct fuse_conn *fc,
 {
 	struct fuse_req *req = NULL;
 	struct fuse_file *ff = file->private_data;
+	struct fuse_inode *fi = get_fuse_inode(file_inode(file));
 
 	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;
@@ -260,13 +261,14 @@ static void put_reserved_req(struct fuse_conn *fc, struct fuse_req *req)
 {
 	struct file *file = req->stolen_file;
 	struct fuse_file *ff = file->private_data;
+	struct fuse_inode *fi = get_fuse_inode(file_inode(file));
 
-	spin_lock(&fc->lock);
+	spin_lock(&fi->lock);
 	fuse_request_init(fc, req, req->pages, req->page_descs, req->max_pages);
 	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);
 }
 



More information about the Devel mailing list