linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: Create COW inode from parent dentry for atomic write
       [not found] <CGME20240813073246epcas1p4085b32d2b008b77119b811dc328b964e@epcas1p4.samsung.com>
@ 2024-08-13  7:32 ` Yeongjin Gil
  2024-08-13 17:32   ` Daeho Jeong
                     ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yeongjin Gil @ 2024-08-13  7:32 UTC (permalink / raw)
  To: jaegeuk, chao, daehojeong; +Cc: Sungjong Seo, linux-kernel, linux-f2fs-devel

The i_pino in f2fs_inode_info has the previous parent's i_ino when inode
was renamed, which may cause f2fs_ioc_start_atomic_write to fail.
If file_wrong_pino is true and i_nlink is 1, then to find a valid pino,
we should refer to the dentry from inode.

To resolve this issue, let's get parent inode using parent dentry
directly.

Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com>
Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com>
---
 fs/f2fs/file.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index fba8b5f216f9..1eae123f0315 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2127,7 +2127,6 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
 	struct mnt_idmap *idmap = file_mnt_idmap(filp);
 	struct f2fs_inode_info *fi = F2FS_I(inode);
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
-	struct inode *pinode;
 	loff_t isize;
 	int ret;
 
@@ -2178,15 +2177,10 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
 	/* Check if the inode already has a COW inode */
 	if (fi->cow_inode == NULL) {
 		/* Create a COW inode for atomic write */
-		pinode = f2fs_iget(inode->i_sb, fi->i_pino);
-		if (IS_ERR(pinode)) {
-			f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
-			ret = PTR_ERR(pinode);
-			goto out;
-		}
+		struct dentry *dentry = file_dentry(filp);
+		struct inode *dir = d_inode(dentry->d_parent);
 
-		ret = f2fs_get_tmpfile(idmap, pinode, &fi->cow_inode);
-		iput(pinode);
+		ret = f2fs_get_tmpfile(idmap, dir, &fi->cow_inode);
 		if (ret) {
 			f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
 			goto out;
-- 
2.40.1



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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: Create COW inode from parent dentry for atomic write
  2024-08-13  7:32 ` [f2fs-dev] [PATCH] f2fs: Create COW inode from parent dentry for atomic write Yeongjin Gil
@ 2024-08-13 17:32   ` Daeho Jeong
  2024-08-14  3:46   ` Chao Yu
  2024-08-30 20:51   ` patchwork-bot+f2fs--- via Linux-f2fs-devel
  2 siblings, 0 replies; 4+ messages in thread
From: Daeho Jeong @ 2024-08-13 17:32 UTC (permalink / raw)
  To: Yeongjin Gil
  Cc: daehojeong, linux-kernel, linux-f2fs-devel, jaegeuk, Sungjong Seo

On Tue, Aug 13, 2024 at 12:34 AM Yeongjin Gil <youngjin.gil@samsung.com> wrote:
>
> The i_pino in f2fs_inode_info has the previous parent's i_ino when inode
> was renamed, which may cause f2fs_ioc_start_atomic_write to fail.
> If file_wrong_pino is true and i_nlink is 1, then to find a valid pino,
> we should refer to the dentry from inode.
>
> To resolve this issue, let's get parent inode using parent dentry
> directly.
>
> Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
> Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com>
> Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com>
> ---
>  fs/f2fs/file.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index fba8b5f216f9..1eae123f0315 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2127,7 +2127,6 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
>         struct mnt_idmap *idmap = file_mnt_idmap(filp);
>         struct f2fs_inode_info *fi = F2FS_I(inode);
>         struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> -       struct inode *pinode;
>         loff_t isize;
>         int ret;
>
> @@ -2178,15 +2177,10 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
>         /* Check if the inode already has a COW inode */
>         if (fi->cow_inode == NULL) {
>                 /* Create a COW inode for atomic write */
> -               pinode = f2fs_iget(inode->i_sb, fi->i_pino);
> -               if (IS_ERR(pinode)) {
> -                       f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
> -                       ret = PTR_ERR(pinode);
> -                       goto out;
> -               }
> +               struct dentry *dentry = file_dentry(filp);
> +               struct inode *dir = d_inode(dentry->d_parent);
>
> -               ret = f2fs_get_tmpfile(idmap, pinode, &fi->cow_inode);
> -               iput(pinode);
> +               ret = f2fs_get_tmpfile(idmap, dir, &fi->cow_inode);
>                 if (ret) {
>                         f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
>                         goto out;
> --
> 2.40.1
>

Reviewed-by: Daeho Jeong <daehojeong@google.com>

Thanks,

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


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: Create COW inode from parent dentry for atomic write
  2024-08-13  7:32 ` [f2fs-dev] [PATCH] f2fs: Create COW inode from parent dentry for atomic write Yeongjin Gil
  2024-08-13 17:32   ` Daeho Jeong
@ 2024-08-14  3:46   ` Chao Yu
  2024-08-30 20:51   ` patchwork-bot+f2fs--- via Linux-f2fs-devel
  2 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2024-08-14  3:46 UTC (permalink / raw)
  To: Yeongjin Gil, jaegeuk, daehojeong
  Cc: Sungjong Seo, linux-kernel, linux-f2fs-devel

On 2024/8/13 15:32, Yeongjin Gil wrote:
> The i_pino in f2fs_inode_info has the previous parent's i_ino when inode
> was renamed, which may cause f2fs_ioc_start_atomic_write to fail.
> If file_wrong_pino is true and i_nlink is 1, then to find a valid pino,
> we should refer to the dentry from inode.
> 
> To resolve this issue, let's get parent inode using parent dentry
> directly.
> 
> Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
> Reviewed-by: Sunmin Jeong <s_min.jeong@samsung.com>
> Signed-off-by: Yeongjin Gil <youngjin.gil@samsung.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: Create COW inode from parent dentry for atomic write
  2024-08-13  7:32 ` [f2fs-dev] [PATCH] f2fs: Create COW inode from parent dentry for atomic write Yeongjin Gil
  2024-08-13 17:32   ` Daeho Jeong
  2024-08-14  3:46   ` Chao Yu
@ 2024-08-30 20:51   ` patchwork-bot+f2fs--- via Linux-f2fs-devel
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+f2fs--- via Linux-f2fs-devel @ 2024-08-30 20:51 UTC (permalink / raw)
  To: Yeongjin Gil
  Cc: daehojeong, linux-kernel, linux-f2fs-devel, jaegeuk, sj1557.seo

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Tue, 13 Aug 2024 16:32:44 +0900 you wrote:
> The i_pino in f2fs_inode_info has the previous parent's i_ino when inode
> was renamed, which may cause f2fs_ioc_start_atomic_write to fail.
> If file_wrong_pino is true and i_nlink is 1, then to find a valid pino,
> we should refer to the dentry from inode.
> 
> To resolve this issue, let's get parent inode using parent dentry
> directly.
> 
> [...]

Here is the summary with links:
  - [f2fs-dev] f2fs: Create COW inode from parent dentry for atomic write
    https://git.kernel.org/jaegeuk/f2fs/c/8c1b787938fd

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-30 20:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20240813073246epcas1p4085b32d2b008b77119b811dc328b964e@epcas1p4.samsung.com>
2024-08-13  7:32 ` [f2fs-dev] [PATCH] f2fs: Create COW inode from parent dentry for atomic write Yeongjin Gil
2024-08-13 17:32   ` Daeho Jeong
2024-08-14  3:46   ` Chao Yu
2024-08-30 20:51   ` patchwork-bot+f2fs--- via Linux-f2fs-devel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).