[Devel] [PATCH vz7 29/46] fuse: duplicate ->connected in pqueue

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


Backport from ml:

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

    fuse: duplicate ->connected in pqueue

    This will allow checking ->connected just with the processing queue lock.

    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    |    7 ++++---
 fs/fuse/fuse_i.h |    3 +++
 fs/fuse/inode.c  |    1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 77ff42c..545cd68 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1267,7 +1267,7 @@ static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
 	fuse_copy_finish(cs);
 	spin_lock(&fc->lock);
 	clear_bit(FR_LOCKED, &req->flags);
-	if (!fc->connected) {
+	if (!fpq->connected) {
 		request_end(fc, req);
 		return -ENODEV;
 	}
@@ -1887,7 +1887,7 @@ static ssize_t fuse_dev_do_write(struct fuse_conn *fc,
 
 	spin_lock(&fc->lock);
 	err = -ENOENT;
-	if (!fc->connected)
+	if (!fpq->connected)
 		goto err_unlock;
 
 	req = request_find(fpq, oh.unique);
@@ -1924,7 +1924,7 @@ static ssize_t fuse_dev_do_write(struct fuse_conn *fc,
 
 	spin_lock(&fc->lock);
 	clear_bit(FR_LOCKED, &req->flags);
-	if (!fc->connected)
+	if (!fpq->connected)
 		err = -ENOENT;
 	else if (err)
 		req->out.h.error = -EIO;
@@ -2118,6 +2118,7 @@ void fuse_abort_conn(struct fuse_conn *fc)
 		fc->connected = 0;
 		fc->blocked = 0;
 		fuse_set_initialized(fc);
+		fpq->connected = 0;
 		list_for_each_entry_safe(req, next, &fpq->io, list) {
 			req->out.h.error = -ECONNABORTED;
 			spin_lock(&req->waitq.lock);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index d609749..cabe549 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -435,6 +435,9 @@ struct fuse_iqueue {
 };
 
 struct fuse_pqueue {
+	/** Connection established */
+	unsigned connected;
+
 	/** The list of requests being processed */
 	struct list_head processing;
 
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index d5d6a00..c95418d 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -702,6 +702,7 @@ static void fuse_pqueue_init(struct fuse_pqueue *fpq)
 	memset(fpq, 0, sizeof(struct fuse_pqueue));
 	INIT_LIST_HEAD(&fpq->processing);
 	INIT_LIST_HEAD(&fpq->io);
+	fpq->connected = 1;
 }
 
 void fuse_conn_init(struct fuse_conn *fc)



More information about the Devel mailing list