[RHEL7,COMMIT] fuse: do not take fc->lock in fuse_request_send_background() - fixup

Submitted by Konstantin Khorenko on April 30, 2019, 11:35 a.m.

Details

Message ID 201904301135.x3UBZckc021416@finist-ce7.sw.ru
State New
Series "fuse:Backport of ms locking patches part 2"
Headers show

Commit Message

Konstantin Khorenko April 30, 2019, 11:35 a.m.
The commit is pushed to "branch-rh7-3.10.0-957.12.1.vz7.95.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.1.vz7.95.2
------>
commit 9e6a856ba7b711fee48801cc84c8897ca37caaa2
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Apr 30 14:35:38 2019 +0300

    fuse: do not take fc->lock in fuse_request_send_background() - fixup
    
    This goes on top of the series and fixes up immediate logic for
    [3/8] ("fuse: do not take fc->lock in fuse_request_send_background()").
    
    It goes separate to simplify [3/8] review and for easier rebase in future
    (I hope).
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    
    =====================
    Patchset description:
    
    fuse: Backport of ms locking patches part 2
    
    Here is backport of locking patches: introducing of fc->bg_lock and fi->lock.
    
    This may need additional changes for kio and NOT verified for fast-path.
    
    Reviewed-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
    
    Kirill Tkhai (9):
          fuse: introduce fc->bg_lock
          fuse: Remove bogus list_del_init() from-fuse_request_send_background
          fuse: do not take fc->lock in fuse_request_send_background()
          fuse: Add fuse_inode argument to fuse_prepare_release()
          fuse: Convert fc->attr_version into atomic64_t
          fuse: Introduce fi->lock to protect write related fields
          fuse: Protect fi->nlookup with fi->lock
          fuse: Protect ff->reserved_req via corresponding fi->lock
          fuse: do not take fc->lock in fuse_request_send_background() - fixup
---
 fs/fuse/dev.c  | 23 +++++------------------
 fs/fuse/file.c |  3 ---
 2 files changed, 5 insertions(+), 21 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index d10e7edd8711..1958c6e33d79 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -612,7 +612,9 @@  bool fuse_request_queue_background(struct fuse_conn *fc, struct fuse_req *req)
 	}
 	__set_bit(FR_ISREPLY, &req->flags);
 	spin_lock(&fc->bg_lock);
-	if (likely(fc->connected)) {
+	if (unlikely(test_bit(FUSE_S_FAIL_IMMEDIATELY, &req->ff->ff_state)))
+		req->out.h.error = -EIO;
+	else if (likely(fc->connected)) {
 		fc->num_background++;
 		if (fc->num_background == fc->max_background)
 			fc->blocked = 1;
@@ -642,29 +644,14 @@  bool fuse_request_queue_background(struct fuse_conn *fc, struct fuse_req *req)
 
 void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req)
 {
-	bool fail;
 	WARN_ON(!req->end);
 
 	if (fc->kio.op && !fc->kio.op->req_send(fc, req, true, false))
 		return;
 
-	spin_lock(&fc->lock);
-	fail = (req->page_cache && req->ff &&
-		test_bit(FUSE_S_FAIL_IMMEDIATELY, &req->ff->ff_state));
-	spin_unlock(&fc->lock);
-
-	if (fail) {
-		/* FIXME */
-		BUG_ON(req->in.h.opcode != FUSE_READ);
-		req->out.h.error = -EIO;
-		__clear_bit(FR_BACKGROUND, &req->flags);
-		__clear_bit(FR_PENDING, &req->flags);
-		request_end(fc, req);
-		return;
-	}
-
 	if (!fuse_request_queue_background(fc, req)) {
-		req->out.h.error = -ENOTCONN;
+		if (!req->out.h.error)
+			req->out.h.error = -ENOTCONN;
 		req->end(fc, req);
 		fuse_put_request(fc, req);
 	}
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 7929f4b6b346..0222854340df 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1949,9 +1949,6 @@  __acquires(fi->lock)
 	__u64 data_size = req->num_pages * PAGE_CACHE_SIZE;
 	bool queued;
 
-	if (test_bit(FUSE_S_FAIL_IMMEDIATELY, &req->ff->ff_state))
-		goto out_free;
-
 	if (inarg->offset + data_size <= size) {
 		inarg->size = data_size;
 	} else if (inarg->offset < size) {