* [PATCH v2] f2fs: return symlink writeback errors
@ 2026-08-10 13:38 Wenjie Qi
2026-08-12 9:30 ` Chao Yu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wenjie Qi @ 2026-08-10 13:38 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, stable, qiwenjie, qwjhust
F2FS writes long symlink data with page_symlink() and then flushes the
symlink mapping to reduce the chance of exposing a broken symlink.
That flush result is currently ignored. If the writeback fails, symlink()
still returns success even though the symlink is not durable and the same
operation can already surface -EIO through syncfs().
Return the writeback error to userspace and skip the dirsync flush once the
symlink data flush has failed.
Fixes: d0cae97cb600 ("f2fs: flush symlink path to avoid broken symlink after POR")
Cc: stable@kernel.org
Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
---
Changes since v1:
- fix the Fixes tag to point to the real introducing commit
Reproducer:
- enable FAULT_WRITE_IO on the mounted F2FS filesystem
- create a long symlink so the target is written through page_symlink()
- old kernel: symlink() returns 0, syncfs() returns -EIO, and the symlink is
absent after remount
- new kernel: symlink() returns -EIO
fs/f2fs/namei.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 7ffdf23cea5e..a8db3928c8b5 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -707,15 +707,16 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
* performance regression.
*/
if (!err) {
- filemap_write_and_wait_range(inode->i_mapping, 0,
- disk_link.len - 1);
+ err = filemap_write_and_wait_range(inode->i_mapping, 0,
+ disk_link.len - 1);
- if (IS_DIRSYNC(dir))
+ if (!err && IS_DIRSYNC(dir))
f2fs_sync_fs(sbi->sb, 1);
- } else {
- f2fs_unlink(dir, dentry);
}
+ if (err)
+ f2fs_unlink(dir, dentry);
+
f2fs_balance_fs(sbi, true);
goto out_free_encrypted_link;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] f2fs: return symlink writeback errors
2026-08-10 13:38 [PATCH v2] f2fs: return symlink writeback errors Wenjie Qi
@ 2026-08-12 9:30 ` Chao Yu
2026-08-12 20:30 ` [f2fs-dev] " patchwork-bot+f2fs
2026-08-15 5:18 ` Al Viro
2 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2026-08-12 9:30 UTC (permalink / raw)
To: Wenjie Qi, jaegeuk; +Cc: chao, linux-f2fs-devel, linux-kernel, stable, qiwenjie
On 8/10/26 21:38, Wenjie Qi wrote:
> F2FS writes long symlink data with page_symlink() and then flushes the
> symlink mapping to reduce the chance of exposing a broken symlink.
>
> That flush result is currently ignored. If the writeback fails, symlink()
> still returns success even though the symlink is not durable and the same
> operation can already surface -EIO through syncfs().
>
> Return the writeback error to userspace and skip the dirsync flush once the
> symlink data flush has failed.
>
> Fixes: d0cae97cb600 ("f2fs: flush symlink path to avoid broken symlink after POR")
> Cc: stable@kernel.org
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [f2fs-dev] [PATCH v2] f2fs: return symlink writeback errors
2026-08-10 13:38 [PATCH v2] f2fs: return symlink writeback errors Wenjie Qi
2026-08-12 9:30 ` Chao Yu
@ 2026-08-12 20:30 ` patchwork-bot+f2fs
2026-08-15 5:18 ` Al Viro
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+f2fs @ 2026-08-12 20:30 UTC (permalink / raw)
To: Wenjie Qi; +Cc: jaegeuk, chao, stable, qiwenjie, linux-kernel, linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Mon, 10 Aug 2026 21:38:32 +0800 you wrote:
> F2FS writes long symlink data with page_symlink() and then flushes the
> symlink mapping to reduce the chance of exposing a broken symlink.
>
> That flush result is currently ignored. If the writeback fails, symlink()
> still returns success even though the symlink is not durable and the same
> operation can already surface -EIO through syncfs().
>
> [...]
Here is the summary with links:
- [f2fs-dev,v2] f2fs: return symlink writeback errors
https://git.kernel.org/jaegeuk/f2fs/c/5d6f08574082
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] 4+ messages in thread* Re: [PATCH v2] f2fs: return symlink writeback errors
2026-08-10 13:38 [PATCH v2] f2fs: return symlink writeback errors Wenjie Qi
2026-08-12 9:30 ` Chao Yu
2026-08-12 20:30 ` [f2fs-dev] " patchwork-bot+f2fs
@ 2026-08-15 5:18 ` Al Viro
2 siblings, 0 replies; 4+ messages in thread
From: Al Viro @ 2026-08-15 5:18 UTC (permalink / raw)
To: Wenjie Qi; +Cc: jaegeuk, chao, linux-f2fs-devel, linux-kernel, stable, qiwenjie
On Mon, Aug 10, 2026 at 09:38:32PM +0800, Wenjie Qi wrote:
> F2FS writes long symlink data with page_symlink() and then flushes the
> symlink mapping to reduce the chance of exposing a broken symlink.
>
> That flush result is currently ignored. If the writeback fails, symlink()
> still returns success even though the symlink is not durable and the same
> operation can already surface -EIO through syncfs().
>
> Return the writeback error to userspace and skip the dirsync flush once the
> symlink data flush has failed.
> if (!err) {
> - filemap_write_and_wait_range(inode->i_mapping, 0,
> - disk_link.len - 1);
> + err = filemap_write_and_wait_range(inode->i_mapping, 0,
> + disk_link.len - 1);
>
> - if (IS_DIRSYNC(dir))
> + if (!err && IS_DIRSYNC(dir))
> f2fs_sync_fs(sbi->sb, 1);
> - } else {
> - f2fs_unlink(dir, dentry);
> }
>
> + if (err)
> + f2fs_unlink(dir, dentry);
That looks fishy. At that point you already have dentry hashed and
AFAICS f2fs_unlink() will leave it hashed and attached to the same
inode; sure, memory pressure will eventually evict the sucker, but
until that point any lookups will simply pick it from dcache.
It's not introduced by this patch; the same issue, AFAICS, already exists
in mainline. Why do we even bother with d_instantiate_new() before we
know that everything's fine, nevermind doing that when we already know
the operation has failed?
Incidentally, is there any reason to add a directory entry before the
inode is set up? Usually that's the last step, and cleanup tends to
be simpler that way; are there f2fs-specific reasons to do it in the
unusual order?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-15 5:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-10 13:38 [PATCH v2] f2fs: return symlink writeback errors Wenjie Qi
2026-08-12 9:30 ` Chao Yu
2026-08-12 20:30 ` [f2fs-dev] " patchwork-bot+f2fs
2026-08-15 5:18 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox