[Devel,vz7,04/46] fuse: account as waiting before queuing for background

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

Details

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

Commit Message

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

commit 5437f2417225dc89c785867f4790012668006abc
Author: Miklos Szeredi <mszeredi@suse.cz>
Date:   Wed Jul 1 16:25:56 2015 +0200

    fuse: account as waiting before queuing for background

    Move accounting of fc->num_waiting to the point where the request actually
    starts waiting.  This is earlier than the current queue_request() for
    background requests, since they might be waiting on the fc->bg_queue before
    being queued on fc->pending.

    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 |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 92ec220..1dd88a9 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -299,10 +299,6 @@  static void queue_request(struct fuse_conn *fc, struct fuse_req *req)
 		len_args(req->in.numargs, (struct fuse_arg *) req->in.args);
 	list_add_tail(&req->list, &fc->pending);
 	req->state = FUSE_REQ_PENDING;
-	if (!req->waiting) {
-		req->waiting = 1;
-		atomic_inc(&fc->num_waiting);
-	}
 	wake_up(&fc->waitq);
 	kill_fasync(&fc->fasync, SIGIO, POLL_IN);
 }
@@ -504,6 +500,10 @@  void fuse_request_check_and_send(struct fuse_conn *fc, struct fuse_req *req,
 				 struct fuse_file *ff)
 {
 	req->isreply = 1;
+	if (!req->waiting) {
+		req->waiting = 1;
+		atomic_inc(&fc->num_waiting);
+	}
 	__fuse_request_send(fc, req, ff);
 }
 
@@ -517,6 +517,10 @@  static void fuse_request_send_nowait_locked(struct fuse_conn *fc,
 					    struct fuse_req *req)
 {
 	BUG_ON(!req->background);
+	if (!req->waiting) {
+		req->waiting = 1;
+		atomic_inc(&fc->num_waiting);
+	}
 	fc->num_background++;
 	if (fc->num_background == fc->max_background)
 		fc->blocked = 1;