[Devel] [PATCH VZ9 2/2] fs/fuse kio: Set FUSE_S_FAIL_IMMEDIATELY bit on newly opened fuse_file correctly

Liu Kui kui.liu at virtuozzo.com
Tue Dec 16 12:25:45 MSK 2025


When fuse_invalidate_file() is in progress, set the FUSE_S_FAIL_IMMEDIATELY
bit on the newly created fuse_file before adding it to fi->rw_files list.

This prevents the page cache from issuing new read requests with locked
pages during fuse_invalidate_file(), which could otherwise cause a deadlock.

https://virtuozzo.atlassian.net/browse/VSTOR-120952

Signed-off-by: Liu Kui <kui.liu at virtuozzo.com>
---
 fs/fuse/file.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index b59dacd29a6a..e804e3c0d6bd 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -242,6 +242,11 @@ static void fuse_link_file(struct file *file, bool write)
 	 * inodes's write_file list
 	 */
 	spin_lock(&fi->lock);
+	if (test_bit(FUSE_I_INVAL_FILES, &fi->state)) {
+		spin_lock(&ff->lock);
+		set_bit(FUSE_S_FAIL_IMMEDIATELY, &ff->ff_state);
+		spin_unlock(&ff->lock);
+	}
 	if (list_empty(entry))
 		list_add(entry, list);
 	spin_unlock(&fi->lock);
-- 
2.39.5 (Apple Git-154)



More information about the Devel mailing list