* [PATCH] f2fs: don't leave the hashed inode while it's unlinked
@ 2026-08-18 20:01 Jaegeuk Kim
2026-08-19 2:56 ` [f2fs-dev] " Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Jaegeuk Kim @ 2026-08-18 20:01 UTC (permalink / raw)
To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim
f2fs_symlink()
1. f2fs_new_inode
2. f2fs_add_link
3. page_symlink
4. flush dirty pages and or checkpoint
Step 4 is nice to succeed, which doesn't become a reason to roll back
the created symlink. OTOH, if we get an error till step 3, let's roll
back and remove the cached inode.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/namei.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 37897f4321c0..7b318cee2ed6 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -704,14 +704,16 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
f2fs_alloc_nid_done(sbi, inode->i_ino);
err = fscrypt_encrypt_symlink(inode, symname, len, &disk_link);
- if (err)
- goto err_out;
-
- err = page_symlink(inode, disk_link.name, disk_link.len);
+ if (!err)
+ err = page_symlink(inode, disk_link.name, disk_link.len);
-err_out:
d_instantiate_new(dentry, inode);
+ if (err) {
+ f2fs_unlink(dir, dentry);
+ goto out_f2fs_handle_failed_inode;
+ }
+
/*
* Let's flush symlink data in order to avoid broken symlink as much as
* possible. Nevertheless, fsyncing is the best way, but there is no
@@ -721,16 +723,10 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
* If the symlink path is stored into inline_data, there is no
* performance regression.
*/
- if (!err) {
- err = filemap_write_and_wait_range(inode->i_mapping, 0,
- disk_link.len - 1);
-
- if (!err && IS_DIRSYNC(dir))
- err = f2fs_sync_fs(sbi->sb, 1);
- }
-
- if (err)
- f2fs_unlink(dir, dentry);
+ err = filemap_write_and_wait_range(inode->i_mapping, 0,
+ disk_link.len - 1);
+ if (!err && IS_DIRSYNC(dir))
+ f2fs_sync_fs(sbi->sb, 1);
f2fs_balance_fs(sbi, true);
goto out_free_encrypted_link;
--
2.55.0.737.g08866a6d13-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: don't leave the hashed inode while it's unlinked
2026-08-18 20:01 [PATCH] f2fs: don't leave the hashed inode while it's unlinked Jaegeuk Kim
@ 2026-08-19 2:56 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2026-08-19 2:56 UTC (permalink / raw)
To: Jaegeuk Kim, Alexander Viro; +Cc: chao, linux-kernel, linux-f2fs-devel
On 8/19/26 04:01, Jaegeuk Kim via Linux-f2fs-devel wrote:
> f2fs_symlink()
> 1. f2fs_new_inode
> 2. f2fs_add_link
> 3. page_symlink
> 4. flush dirty pages and or checkpoint
>
> Step 4 is nice to succeed, which doesn't become a reason to roll back
> the created symlink. OTOH, if we get an error till step 3, let's roll
> back and remove the cached inode.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> fs/f2fs/namei.c | 26 +++++++++++---------------
> 1 file changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index 37897f4321c0..7b318cee2ed6 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -704,14 +704,16 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> f2fs_alloc_nid_done(sbi, inode->i_ino);
>
> err = fscrypt_encrypt_symlink(inode, symname, len, &disk_link);
> - if (err)
> - goto err_out;
> -
> - err = page_symlink(inode, disk_link.name, disk_link.len);
> + if (!err)
> + err = page_symlink(inode, disk_link.name, disk_link.len);
>
> -err_out:
> d_instantiate_new(dentry, inode);
IIUC, Al means we'd better not call d_instantiate_new() before every thing is
done? IOW, do not call d_instantiate_new() if we're in error handling.
Let me know if I missed something.
Thanks,
>
> + if (err) {
> + f2fs_unlink(dir, dentry);
> + goto out_f2fs_handle_failed_inode;
> + }
> +
> /*
> * Let's flush symlink data in order to avoid broken symlink as much as
> * possible. Nevertheless, fsyncing is the best way, but there is no
> @@ -721,16 +723,10 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> * If the symlink path is stored into inline_data, there is no
> * performance regression.
> */
> - if (!err) {
> - err = filemap_write_and_wait_range(inode->i_mapping, 0,
> - disk_link.len - 1);
> -
> - if (!err && IS_DIRSYNC(dir))
> - err = f2fs_sync_fs(sbi->sb, 1);
> - }
> -
> - if (err)
> - f2fs_unlink(dir, dentry);
> + err = filemap_write_and_wait_range(inode->i_mapping, 0,
> + disk_link.len - 1);
> + if (!err && IS_DIRSYNC(dir))
> + f2fs_sync_fs(sbi->sb, 1);
>
> f2fs_balance_fs(sbi, true);
> goto out_free_encrypted_link;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-19 2:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-18 20:01 [PATCH] f2fs: don't leave the hashed inode while it's unlinked Jaegeuk Kim
2026-08-19 2:56 ` [f2fs-dev] " Chao Yu
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®