The commit is pushed to "branch-rh9-5.14.0-427.77.1.vz9.86.x-ovz" and will appear at g...@bitbucket.org:openvz/vzkernel.git after rh9-5.14.0-427.77.1.vz9.86.6 ------> commit 397c08f0763e17f2a214e8538bebb5440b8e82be Author: Liu Kui <kui....@virtuozzo.com> Date: Mon Sep 15 21:02:04 2025 +0800
fs/fuse: refactor fuse_file_fail_immediately() Remove redundant code related to fuse_file_fail_immediately(). Signed-off-by: Liu Kui <kui....@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 | 10 +++++----- fs/fuse/file.c | 15 ++++++++------- fs/fuse/fuse_i.h | 9 ++------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 5f19af552cb55..8112de4abadda 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -619,21 +619,21 @@ 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))) { - int ret = fc->kio.op->req_classify(req, false, false); + if (fc->kio.op && req->args->async && !nonblocking) { + 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))))) + fuse_file_fail_immediately(ff)))) return -EIO; if (!READ_ONCE(fc->connected)) return -ENOTCONN; - if (ff && test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state)) + if (fuse_file_fail_immediately(ff)) return -EIO; req->qhash = bkt; atomic_inc(&fc->qhash[bkt].num_reqs); diff --git a/fs/fuse/file.c b/fs/fuse/file.c index c8e1056370ad7..ce9f6b8eb274f 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1141,7 +1141,7 @@ static int fuse_do_readpage(struct file *file, struct page *page, */ fuse_wait_on_page_writeback(inode, page->index); spin_lock(&ff->lock); - if (unlikely(__fuse_file_fail_immediately(ff))) { + if (unlikely(fuse_file_fail_immediately(ff))) { spin_unlock(&ff->lock); return -EIO; } @@ -1303,7 +1303,7 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) ap->args.end = fuse_readpages_end; spin_lock(&ff->lock); - if (unlikely(__fuse_file_fail_immediately(ff))) { + if (unlikely(fuse_file_fail_immediately(ff))) { spin_unlock(&ff->lock); INIT_LIST_HEAD(&ia->revoke_entry); err = -EIO; @@ -2454,7 +2454,7 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data) wpa->ia.ff = fuse_file_get(data->ff); spin_lock(&fi->lock); - if (test_bit(FUSE_S_FAIL_IMMEDIATELY, &data->ff->ff_state)) { + if (fuse_file_fail_immediately(data->ff)) { shoot_on_sight = 1; fi->writectr++; } else { @@ -2758,7 +2758,7 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping, fuse_wait_on_page_writeback(mapping->host, page->index); - if (fuse_file_fail_immediately(file)) { + if (fuse_file_fail_immediately(file->private_data)) { err = -EIO; goto cleanup; } @@ -2870,9 +2870,10 @@ static void fuse_vma_close(struct vm_area_struct *vma) static vm_fault_t fuse_page_mkwrite(struct vm_fault *vmf) { struct page *page = vmf->page; - struct inode *inode = file_inode(vmf->vma->vm_file); + struct file *file = vmf->vma->vm_file; + struct inode *inode = file_inode(file); - file_update_time(vmf->vma->vm_file); + file_update_time(file); lock_page(page); if (page->mapping != inode->i_mapping) { unlock_page(page); @@ -2880,7 +2881,7 @@ static vm_fault_t fuse_page_mkwrite(struct vm_fault *vmf) } fuse_wait_on_page_writeback(inode, page->index); - if (fuse_file_fail_immediately(vmf->vma->vm_file)) { + if (fuse_file_fail_immediately(file->private_data)) { unlock_page(page); return VM_FAULT_SIGSEGV; } diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 901956ccb6d80..916d696805433 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1443,14 +1443,9 @@ static inline void fuse_dio_wait(struct fuse_inode *fi) fuse_write_dio_wait(fi); } -static inline bool __fuse_file_fail_immediately(struct fuse_file *ff) +static inline bool fuse_file_fail_immediately(struct fuse_file *ff) { - return test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state); -} - -static inline bool fuse_file_fail_immediately(struct file *file) -{ - return __fuse_file_fail_immediately(file->private_data); + return ff && test_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state); } /** _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel