[Devel] [PATCH VZ10 1/2] fs/fuse: restore fuse_writepages() to mainstream behavior

Liu Kui kui.liu at virtuozzo.com
Mon Apr 20 10:13:02 MSK 2026


Restore fuse_writepages() and fuse_writepages_fill() to their original
behavior by removing changes from commit "67d9ccc4cc1d fuse: fix
writeback/release race". These changes make no sense at all, in particular
set err to 0 even after write_cache_pages() returns an error is just
wrong. The original commit should have been dropped as indicated by
"083cb0ac8e38 fuse: Wait inflight requests"

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

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 11fb3996a2ac..b84aac13bfc9 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1233,7 +1233,7 @@ void fuse_release_ff(struct inode *inode, struct fuse_file *ff)
 			struct fuse_inode *fi = get_fuse_inode(inode);
 			spin_lock(&fi->lock);
 			__fuse_file_put(ff);
-			wake_up(&get_fuse_inode(inode)->page_waitq);
+			wake_up(&fi->page_waitq);
 			spin_unlock(&fi->lock);
 		} else {
 			fuse_file_put(ff, false);
@@ -2724,17 +2724,20 @@ static int fuse_writepages_fill(struct folio *folio,
 	int err;
 	int check_for_blocked = 0;
 
-	BUG_ON(wpa && !data->ff);
-
 	if (!wpa && test_bit(FUSE_I_INVAL_FILES, &fi->state)) {
 		unlock_page(&folio->page);
 		return -EIO;
 	}
 
+	if (!data->ff) {
+		err = -EIO;
+		data->ff = fuse_write_file_get(fi);
+		if (!data->ff)
+			goto out_unlock;
+	}
+
 	if (wpa && fuse_writepage_need_send(fc, &folio->page, ap, data)) {
 		fuse_writepages_send(data);
-		fuse_release_ff(inode, data->ff);
-		data->ff = NULL;
 		data->wpa = NULL;
 	}
 
@@ -2757,13 +2760,6 @@ static int fuse_writepages_fill(struct folio *folio,
 	 * under writeback, so we can release the page lock.
 	 */
 	if (data->wpa == NULL) {
-		/* we can acquire ff here because we do have locked pages here! */
-		BUG_ON(data->ff);
-		err = -EIO;
-		data->ff = fuse_write_file_get(fi);
-		if (!data->ff)
-			goto out_unlock;
-
 		err = -ENOMEM;
 		wpa = fuse_writepage_args_setup(folio, data->ff);
 		if (!wpa) {
@@ -2794,8 +2790,6 @@ static int fuse_writepages_fill(struct folio *folio,
 		data->wpa = wpa;
 	} else {
 		folio_end_writeback(folio);
-		fuse_release_ff(inode, data->ff);
-		data->ff = NULL;
 	}
 out_unlock:
 	folio_unlock(folio);
@@ -2845,11 +2839,8 @@ static int fuse_writepages(struct address_space *mapping,
 	if (data.wpa) {
 		WARN_ON(!data.wpa->ia.ap.num_pages);
 		fuse_writepages_send(&data);
-		fuse_release_ff(inode, data.ff);
-		data.ff = NULL;
-		err = 0;
 	}
-	BUG_ON(data.ff);
+	fuse_release_ff(inode, data.ff);
 
 	kfree(data.orig_pages);
 out:
-- 
2.39.5 (Apple Git-154)



More information about the Devel mailing list