[Devel,vz7,39/46] fuse: abort: no fc->lock needed for request ending

Submitted by Maxim Patlasov on March 25, 2017, 2:28 a.m.

Details

Message ID 149040889906.25341.9968706714198039125.stgit@maxim-thinkpad
State New
Series "fuse: add multi-threading support"
Headers show

Commit Message

Maxim Patlasov March 25, 2017, 2:28 a.m.
Backport from ml:

commit ee314a870e402f4e63b8a651bc96c740ed69cb31
Author: Miklos Szeredi <mszeredi@suse.cz>
Date:   Wed Jul 1 16:26:08 2015 +0200

    fuse: abort: no fc->lock needed for request ending

    In fuse_abort_conn() when all requests are on private lists we no longer
    need fc->lock protection.

    Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
    Reviewed-by: Ashish Samant <ashish.samant@oracle.com>

Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 fs/fuse/dev.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 16e2be9..70694ed 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2067,8 +2067,6 @@  static unsigned fuse_dev_poll(struct file *file, poll_table *wait)
  * This function releases and reacquires fc->lock
  */
 static void end_requests(struct fuse_conn *fc, struct list_head *head)
-__releases(fc->lock)
-__acquires(fc->lock)
 {
 	while (!list_empty(head)) {
 		struct fuse_req *req;
@@ -2077,9 +2075,7 @@  __acquires(fc->lock)
 		clear_bit(FR_PENDING, &req->flags);
 		clear_bit(FR_SENT, &req->flags);
 		list_del_init(&req->list);
-		spin_unlock(&fc->lock);
 		request_end(fc, req);
-		spin_lock(&fc->lock);
 	}
 }
 
@@ -2155,20 +2151,20 @@  void fuse_abort_conn(struct fuse_conn *fc)
 		wake_up_all_locked(&fiq->waitq);
 		spin_unlock(&fiq->waitq.lock);
 		kill_fasync(&fiq->fasync, SIGIO, POLL_IN);
+		end_polls(fc);
+		wake_up_all(&fc->blocked_waitq);
+		spin_unlock(&fc->lock);
 
 		while (!list_empty(&to_end1)) {
 			req = list_first_entry(&to_end1, struct fuse_req, list);
 			__fuse_get_request(req);
 			list_del_init(&req->list);
-			spin_unlock(&fc->lock);
 			request_end(fc, req);
-			spin_lock(&fc->lock);
 		}
 		end_requests(fc, &to_end2);
-		end_polls(fc);
-		wake_up_all(&fc->blocked_waitq);
+	} else {
+		spin_unlock(&fc->lock);
 	}
-	spin_unlock(&fc->lock);
 }
 EXPORT_SYMBOL_GPL(fuse_abort_conn);