* [PATCH] f2fs: return writeback error from collapse range
@ 2026-07-27 7:49 Wenjie Qi
2026-08-03 8:35 ` Chao Yu
2026-08-05 21:21 ` [f2fs-dev] " patchwork-bot+f2fs
0 siblings, 2 replies; 3+ messages in thread
From: Wenjie Qi @ 2026-07-27 7:49 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: stable, linux-f2fs-devel, linux-kernel, qiwenjie, qwjhust
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")
Cc: stable@kernel.org
Assisted-by: Codex:gpt-5.5
Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
---
QEMU fault injection:
- baseline: FAULT_WRITE_IO made fallocate(COLLAPSE_RANGE) return 0.
- patched: the same trigger returned -1/EIO.
- no-fault collapse returned 0 and fsck.f2fs core checks were Ok.
fs/f2fs/file.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index c54897a25981..4bbd89320b00 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -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);
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] f2fs: return writeback error from collapse range
2026-07-27 7:49 [PATCH] f2fs: return writeback error from collapse range Wenjie Qi
@ 2026-08-03 8:35 ` Chao Yu
2026-08-05 21:21 ` [f2fs-dev] " patchwork-bot+f2fs
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2026-08-03 8:35 UTC (permalink / raw)
To: Wenjie Qi, jaegeuk; +Cc: chao, stable, linux-f2fs-devel, linux-kernel, qiwenjie
On 7/27/26 15:49, Wenjie Qi wrote:
> 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")
> Cc: stable@kernel.org
> Assisted-by: Codex:gpt-5.5
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: return writeback error from collapse range
2026-07-27 7:49 [PATCH] f2fs: return writeback error from collapse range Wenjie Qi
2026-08-03 8:35 ` Chao Yu
@ 2026-08-05 21:21 ` patchwork-bot+f2fs
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs @ 2026-08-05 21:21 UTC (permalink / raw)
To: Wenjie Qi; +Cc: jaegeuk, chao, linux-kernel, qiwenjie, stable, linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Mon, 27 Jul 2026 15:49:10 +0800 you wrote:
> 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")
> Cc: stable@kernel.org
> Assisted-by: Codex:gpt-5.5
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
>
> [...]
Here is the summary with links:
- [f2fs-dev] f2fs: return writeback error from collapse range
https://git.kernel.org/jaegeuk/f2fs/c/f8a410880025
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-05 21:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-27 7:49 [PATCH] f2fs: return writeback error from collapse range Wenjie Qi
2026-08-03 8:35 ` Chao Yu
2026-08-05 21:21 ` [f2fs-dev] " patchwork-bot+f2fs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®