All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Jaegeuk Kim <jaegeuk@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: don't leave the hashed inode while it's unlinked
Date: Wed, 19 Aug 2026 10:56:45 +0800	[thread overview]
Message-ID: <4f8e32e7-be61-44f0-9bc7-10eefe1cad94@kernel.org> (raw)
In-Reply-To: <20260818200121.2684318-1-jaegeuk@kernel.org>

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;



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <chao@kernel.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Cc: chao@kernel.org, linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: don't leave the hashed inode while it's unlinked
Date: Wed, 19 Aug 2026 10:56:45 +0800	[thread overview]
Message-ID: <4f8e32e7-be61-44f0-9bc7-10eefe1cad94@kernel.org> (raw)
In-Reply-To: <20260818200121.2684318-1-jaegeuk@kernel.org>

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;


  reply	other threads:[~2026-08-19  2:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 20:01 [PATCH] f2fs: don't leave the hashed inode while it's unlinked Jaegeuk Kim
2026-08-18 20:01 ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2026-08-19  2:56 ` Chao Yu via Linux-f2fs-devel [this message]
2026-08-19  2:56   ` Chao Yu
2026-08-21 15:23 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim via Linux-f2fs-devel
2026-08-21 15:23   ` Jaegeuk Kim
2026-08-22  7:37   ` Chao Yu via Linux-f2fs-devel
2026-08-22  7:37     ` Chao Yu
2026-08-23  9:56   ` Wenjie Qi
2026-08-23  9:56     ` Wenjie Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f8e32e7-be61-44f0-9bc7-10eefe1cad94@kernel.org \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.