[Devel] [PATCH vz7 37/46] fuse: no fc->lock in request_end()

Maxim Patlasov mpatlasov at virtuozzo.com
Fri Mar 24 19:27:39 PDT 2017


Backport from ml:

commit efe2800facb4505696e602ec4ed1fc947bf114dd
Author: Miklos Szeredi <mszeredi at suse.cz>
Date:   Wed Jul 1 16:26:07 2015 +0200

    fuse: no fc->lock in request_end()

    No longer need to call request_end() with the connection lock held.  We
    still protect the background counters and queue with fc->lock, so acquire
    it if necessary.

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

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

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index d2ad658..3733cea 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -359,18 +359,13 @@ static void flush_bg_queue(struct fuse_conn *fc)
  * was closed.  The requester thread is woken up (if still waiting),
  * the 'end' callback is called if given, else the reference to the
  * request is released
- *
- * Called with fc->lock, unlocks it
  */
 static void request_end(struct fuse_conn *fc, struct fuse_req *req)
-__releases(fc->lock)
 {
 	struct fuse_iqueue *fiq = &fc->iq;
 
-	if (test_and_set_bit(FR_FINISHED, &req->flags)) {
-		spin_unlock(&fc->lock);
+	if (test_and_set_bit(FR_FINISHED, &req->flags))
 		return;
-	}
 
 	spin_lock(&fiq->waitq.lock);
 	list_del_init(&req->intr_entry);
@@ -378,6 +373,7 @@ __releases(fc->lock)
 	WARN_ON(test_bit(FR_PENDING, &req->flags));
 	WARN_ON(test_bit(FR_SENT, &req->flags));
 	if (test_bit(FR_BACKGROUND, &req->flags)) {
+		spin_lock(&fc->lock);
 		clear_bit(FR_BACKGROUND, &req->flags);
 		if (fc->num_background == fc->max_background)
 			fc->blocked = 0;
@@ -394,8 +390,8 @@ __releases(fc->lock)
 		fc->num_background--;
 		fc->active_background--;
 		flush_bg_queue(fc);
+		spin_unlock(&fc->lock);
 	}
-	spin_unlock(&fc->lock);
 	wake_up(&req->waitq);
 	if (req->end)
 		req->end(fc, req);
@@ -539,6 +535,7 @@ void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req)
 		req->out.h.error = -EIO;
 		__clear_bit(FR_BACKGROUND, &req->flags);
 		list_del_init(&req->list);
+		spin_unlock(&fc->lock);
 		request_end(fc, req);
 	} else if (fc->connected) {
 		fuse_request_send_background_locked(fc, req);
@@ -1255,6 +1252,7 @@ static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
 		/* SETXATTR is special, since it may contain too large data */
 		if (in->h.opcode == FUSE_SETXATTR)
 			req->out.h.error = -E2BIG;
+		spin_unlock(&fc->lock);
 		request_end(fc, req);
 		goto restart;
 	}
@@ -1298,6 +1296,7 @@ out_end:
 	if (!test_bit(FR_PRIVATE, &req->flags))
 		list_del_init(&req->list);
 	spin_unlock(&fpq->lock);
+	spin_unlock(&fc->lock);
 	request_end(fc, req);
 	return err;
 
@@ -1948,6 +1947,7 @@ static ssize_t fuse_dev_do_write(struct fuse_conn *fc,
 	if (!test_bit(FR_PRIVATE, &req->flags))
 		list_del_init(&req->list);
 	spin_unlock(&fpq->lock);
+	spin_unlock(&fc->lock);
 	request_end(fc, req);
 
 	return err ? err : nbytes;
@@ -2089,6 +2089,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);
 	}
@@ -2171,6 +2172,7 @@ void fuse_abort_conn(struct fuse_conn *fc)
 			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);
 		}



More information about the Devel mailing list