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

Submitted by Kirill Tkhai on April 3, 2019, 3:37 p.m.

Details

Message ID 155430586325.24379.15985007378895605312.stgit@localhost.localdomain
State New
Series "fuse:Backport of ms locking patches part 2"
Headers show

Commit Message

Kirill Tkhai April 3, 2019, 3:37 p.m.
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@virtuozzo.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 fs/fuse/dev.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

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);
 }