[Devel,vz7,05/46] fuse: check conn_error earlier

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

Details

Message ID 149040802317.25341.3207783931483518268.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 de15522646b9822d82b613d84cfeb4482370db3d
Author: Miklos Szeredi <mszeredi@suse.cz>
Date:   Wed Jul 1 16:25:57 2015 +0200

    fuse: check conn_error earlier

    fc->conn_error is set once in FUSE_INIT reply and never cleared.  Check it
    in request allocation, there's no sense in doing all the preparation if
    sending will surely fail.

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

Patch hide | download patch | download mbox

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 1dd88a9..c14e102 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -142,6 +142,10 @@  static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages,
 	if (!fc->connected)
 		goto out;
 
+	err = -ECONNREFUSED;
+	if (fc->conn_error)
+		goto out;
+
 	req = fuse_request_alloc(npages);
 	err = -ENOMEM;
 	if (!req) {
@@ -480,8 +484,6 @@  static void __fuse_request_send(struct fuse_conn *fc, struct fuse_req *req,
 	spin_lock(&fc->lock);
 	if (!fc->connected)
 		req->out.h.error = -ENOTCONN;
-	else if (fc->conn_error)
-		req->out.h.error = -ECONNREFUSED;
 	else if (ff && test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state))
 		req->out.h.error = -EIO;
 	else {