Skip to contentSkip to conversation

FAILED: patch "[PATCH] f2fs: return writeback error from collapse range" failed to apply to 5.10-stable tree

PATCH New [email protected] 2 participants 2 messages Sep 9 – Sep 11

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x f8a4108800254d6f7b2755515fbbd9d0caac561e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090921-luncheon-anywhere-f22e@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From f8a4108800254d6f7b2755515fbbd9d0caac561e Mon Sep 17 00:00:00 2001
From: Wenjie Qi <[email protected]>
Date: Mon, 27 Jul 2026 15:49:10 +0800
Subject: [PATCH] f2fs: return writeback error from collapse range

f2fs_collapse_range() writes back pages moved by f2fs_do_collapse(), but ignores the return value. If writeback fails, the ioctl can still truncate page cache, shrink blocks, and report success.

Return the error before truncating page cache or updating the file size.

Fixes b4ace3370324 ("f2fs: support FALLOC_FL_COLLAPSE_RANGE")
Assisted-by Codex:gpt-5.5
fs/f2fs/file.c +4 -1
index 2773c6ce7ec1..c19f0de271a9 100644
@@ -1623,11 +1623,14 @@ static int f2fs_collapse_range(struct inode *inode, loff_t offset, loff_t len)
 
 	/* write out all moved pages, if possible */
 	filemap_invalidate_lock(inode->i_mapping);
-	filemap_write_and_wait_range(inode->i_mapping, offset, LLONG_MAX);
+	ret = filemap_write_and_wait_range(inode->i_mapping, offset, LLONG_MAX);
+	if (ret)
+		goto out_unlock;
 	truncate_pagecache(inode, offset);
 
 	new_size = i_size_read(inode) - len;
 	ret = f2fs_truncate_blocks(inode, new_size, true);
+out_unlock:
 	filemap_invalidate_unlock(inode->i_mapping);
 	if (!ret)
 		f2fs_i_size_write(inode, new_size);
maintainer
#1 lore raw

PATCH 1/1 f2fs: return writeback error from collapse range

From: Wenjie Qi <[email protected]>

[ Upstream commit f8a4108800254d6f7b2755515fbbd9d0caac561e ]

f2fs_collapse_range() writes back pages moved by f2fs_do_collapse(), but ignores the return value. If writeback fails, the ioctl can still truncate page cache, shrink blocks, and report success.

Return the error before truncating page cache or updating the file size.

Fixes b4ace3370324 ("f2fs: support FALLOC_FL_COLLAPSE_RANGE")
Assisted-by Codex:gpt-5.5
[ adjusted context to retain down_write()/up_write() on i_mmap_sem instead of filemap_invalidate_lock()/filemap_invalidate_unlock(). ]
---
 fs/f2fs/file.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/file.c +4 -1
index 8e68546987af5..092ec12b6d638 100644
@@ -1402,11 +1402,14 @@ static int f2fs_collapse_range(struct inode *inode, loff_t offset, loff_t len)
 
 	/* write out all moved pages, if possible */
 	down_write(&F2FS_I(inode)->i_mmap_sem);
-	filemap_write_and_wait_range(inode->i_mapping, offset, LLONG_MAX);
+	ret = filemap_write_and_wait_range(inode->i_mapping, offset, LLONG_MAX);
+	if (ret)
+		goto out_unlock;
 	truncate_pagecache(inode, offset);
 
 	new_size = i_size_read(inode) - len;
 	ret = f2fs_truncate_blocks(inode, new_size, true);
+out_unlock:
 	up_write(&F2FS_I(inode)->i_mmap_sem);
 	if (!ret)
 		f2fs_i_size_write(inode, new_size);
Signature · 1 line
2.53.0