[Devel] [PATCH RHEL9 COMMIT] fs/fuse: remove useless code related to fuse_kill_requests

Konstantin Khorenko khorenko at virtuozzo.com
Mon Sep 15 17:05:12 MSK 2025


The commit is pushed to "branch-rh9-5.14.0-427.77.1.vz9.86.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.77.1.vz9.86.6
------>
commit 65f1c5a2fc21a569f36d77d270df3d96f3e38382
Author: Liu Kui <kui.liu at virtuozzo.com>
Date:   Mon Sep 15 21:02:02 2025 +0800

    fs/fuse: remove useless code related to fuse_kill_requests
    
    It's no longer needed to check the file state when moving a request
    from one queue to another, so remove these code.
    
    Related to #VSTOR-101450
    Signed-off-by: Liu Kui <kui.liu at virtuozzo.com>
    
    ======
    Patchset description:
    fs/fuse: Revamp fuse_invalidate_files()
    
    Current implementation requires traversing various queues to find
    requests that need to be killed. This approach is problematic because:
    
     1. Requests can move between different queues during their lifecycle
     2. Special care must be taken when moving requests between queues to
        avoid missing requests that need to be killed.
     3. The current implementation is complex, bug-prone, and difficult to
        maintain
    
    This patch series implements a cleaner solution by introducing a dedicated
    queue to track all killable requests. Each request is enqueued when created
    and dequeued only when destroyed, ensuring that no requests are missed
    during kill operations.
    
    Key changes:
     - Add a new killable requests queue to track all requests that can be
       killed
     - Simplify kill operations by iterating only through the dedicated queue
     - Remove complex queue traversal logic and race condition handling
     - Improve code maintainability and reduce bug potential
    
    Implements #VSTOR-101450
    https://virtuozzo.atlassian.net/browse/VSTOR-101450
    
    Feature: vStorage
---
 fs/fuse/dev.c                      | 26 +++++---------------------
 fs/fuse/inode.c                    |  1 -
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 10 +---------
 3 files changed, 6 insertions(+), 31 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index e3e97ed8c92f6..99bb359cf4ad8 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -470,7 +470,6 @@ static void __fuse_request_send(struct fuse_req *req)
 	struct fuse_mount *fm = req->fm;
 	struct fuse_conn *fc = fm->fc;
 	struct fuse_iqueue *fiq = req->args->fiq;
-	struct fuse_file *ff = req->args->ff;
 
 	BUG_ON(test_bit(FR_BACKGROUND, &req->flags));
 
@@ -489,11 +488,6 @@ static void __fuse_request_send(struct fuse_req *req)
 		req->out.h.error = -ENOTCONN;
 		if (req->args->end)
 			req->args->end(fm, req->args, req->out.h.error);
-	} else if (ff && test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state)) {
-		spin_unlock(&fiq->lock);
-		req->out.h.error = -EIO;
-		if (req->args->end)
-			req->args->end(fm, req->args, req->out.h.error);
 	} else {
 		req->in.h.unique = fuse_get_unique(fiq);
 		/* acquire extra reference, since request is still needed
@@ -626,16 +620,16 @@ static int fuse_request_queue_background(struct fuse_req *req)
 	__set_bit(FR_ISREPLY, &req->flags);
 
 	if (fc->kio.op && req->args->async && !nonblocking && READ_ONCE(fc->connected) &&
-	    (!ff || !test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state))) {
+		(!ff || !test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state))) {
 		int ret = fc->kio.op->req_classify(req, false, false);
 		if (likely(!ret)) {
 			unsigned int bkt = fuse_qhash_bucket();
 			__clear_bit(FR_BACKGROUND, &req->flags);
 			__set_bit(FR_NO_ACCT, &req->flags);
 			if (wait_event_killable_exclusive(fc->qhash[bkt].waitq,
-							  (atomic_read(&fc->qhash[bkt].num_reqs) < fuse_qhash_bucket_len ||
-							   !READ_ONCE(fc->connected) ||
-							   (ff && test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state)))))
+						(atomic_read(&fc->qhash[bkt].num_reqs) < fuse_qhash_bucket_len ||
+					   !READ_ONCE(fc->connected) ||
+					   (ff && test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state)))))
 				return -EIO;
 			if (!READ_ONCE(fc->connected))
 				return -ENOTCONN;
@@ -650,9 +644,7 @@ static int fuse_request_queue_background(struct fuse_req *req)
 	}
 
 	spin_lock(&fc->bg_lock);
-	if (ff && test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state)) {
-		ret = -EIO;
-	} else if (likely(fc->connected)) {
+	if (likely(fc->connected)) {
 		ret = 0;
 		fc->num_background++;
 		if (fc->num_background == fc->max_background)
@@ -1421,15 +1413,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
 		goto out_end;
 
 	}
-	if (args->page_cache && args->io_inode) {
-		struct fuse_inode *fi = get_fuse_inode(args->io_inode);
 
-		if (test_bit(FUSE_I_INVAL_FILES, &fi->state) || args->killed) {
-			req->out.h.error = -EIO;
-			err = -EAGAIN;
-			goto out_end;
-		}
-	}
 	list_add(&req->list, &fpq->io);
 	spin_unlock(&fpq->lock);
 	cs->req = req;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 3e0413048b118..324e8086a256c 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -509,7 +509,6 @@ int fuse_invalidate_files(struct fuse_conn *fc, u64 nodeid)
 
 	/* let them see FUSE_S_FAIL_IMMEDIATELY */
 	wake_up_all(&fc->blocked_waitq);
-
 	for (i = 0; i < FUSE_QHASH_SIZE; i++)
 		wake_up_all(&fc->qhash[i].waitq);
 
diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index 0a59271a6f124..379fac0a13431 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -837,13 +837,7 @@ static void wait_shrink(struct pcs_fuse_req *r, struct pcs_dentry_info *di)
 
 static bool kqueue_insert(struct pcs_dentry_info *di, struct fuse_req *req)
 {
-	struct fuse_file *ff = req->args->ff;
-
 	spin_lock(&di->kq_lock);
-	if (ff && test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state)) {
-		spin_unlock(&di->kq_lock);
-		return false;
-	}
 	list_add_tail(&req->list, &di->kq);
 	spin_unlock(&di->kq_lock);
 	return true;
@@ -984,9 +978,7 @@ static int pcs_fuse_prep_rw(struct pcs_fuse_req *r)
 		BUG();
 	}
 
-	if (req->args->ff && test_bit(FUSE_S_FAIL_IMMEDIATELY, &req->args->ff->ff_state))
-		ret = -EIO;
-	else if (req->in.h.opcode == FUSE_READ || req->in.h.opcode == FUSE_FSYNC ||
+	if (req->in.h.opcode == FUSE_READ || req->in.h.opcode == FUSE_FSYNC ||
 	    req->in.h.opcode == FUSE_FLUSH)
 		fuse_read_dio_begin(fi);
 	else


More information about the Devel mailing list