All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix to update dir's i_pino during cross_rename
@ 2019-11-07  6:12 ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2019-11-07  6:12 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

As Eric reported:

RENAME_EXCHANGE support was just added to fsstress in xfstests:

	commit 65dfd40a97b6bbbd2a22538977bab355c5bc0f06
	Author: kaixuxia <xiakaixu1987@gmail.com>
	Date:   Thu Oct 31 14:41:48 2019 +0800

	    fsstress: add EXCHANGE renameat2 support

This is causing xfstest generic/579 to fail due to fsck.f2fs reporting errors.
I'm not sure what the problem is, but it still happens even with all the
fs-verity stuff in the test commented out, so that the test just runs fsstress.

generic/579 23s ... 	[10:02:25]
[    7.745370] run fstests generic/579 at 2019-11-04 10:02:25
_check_generic_filesystem: filesystem on /dev/vdc is inconsistent
(see /results/f2fs/results-default/generic/579.full for details)
 [10:02:47]
Ran: generic/579
Failures: generic/579
Failed 1 of 1 tests
Xunit report: /results/f2fs/results-default/result.xml

Here's the contents of 579.full:

_check_generic_filesystem: filesystem on /dev/vdc is inconsistent
*** fsck.f2fs output ***
[ASSERT] (__chk_dots_dentries:1378)  --> Bad inode number[0x24] for '..', parent parent ino is [0xd10]

The root cause is that we forgot to update directory's i_pino during
cross_rename, fix it.

Fixes: 32f9bc25cbda0 ("f2fs: support ->rename2()")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/namei.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 4faf06e8bf89..a1c507b0b4ac 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -981,7 +981,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (!old_dir_entry || whiteout)
 		file_lost_pino(old_inode);
 	else
-		F2FS_I(old_inode)->i_pino = new_dir->i_ino;
+		/* adjust dir's i_pino to pass fsck check */
+		f2fs_i_pino_write(old_inode, new_dir->i_ino);
 	up_write(&F2FS_I(old_inode)->i_sem);
 
 	old_inode->i_ctime = current_time(old_inode);
@@ -1141,7 +1142,11 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	f2fs_set_link(old_dir, old_entry, old_page, new_inode);
 
 	down_write(&F2FS_I(old_inode)->i_sem);
-	file_lost_pino(old_inode);
+	if (!old_dir_entry)
+		file_lost_pino(old_inode);
+	else
+		/* adjust dir's i_pino to pass fsck check */
+		f2fs_i_pino_write(old_inode, new_dir->i_ino);
 	up_write(&F2FS_I(old_inode)->i_sem);
 
 	old_dir->i_ctime = current_time(old_dir);
@@ -1156,7 +1161,11 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	f2fs_set_link(new_dir, new_entry, new_page, old_inode);
 
 	down_write(&F2FS_I(new_inode)->i_sem);
-	file_lost_pino(new_inode);
+	if (!new_dir_entry)
+		file_lost_pino(new_inode);
+	else
+		/* adjust dir's i_pino to pass fsck check */
+		f2fs_i_pino_write(new_inode, old_dir->i_ino);
 	up_write(&F2FS_I(new_inode)->i_sem);
 
 	new_dir->i_ctime = current_time(new_dir);
-- 
2.18.0.rc1


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

* [f2fs-dev] [PATCH] f2fs: fix to update dir's i_pino during cross_rename
@ 2019-11-07  6:12 ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2019-11-07  6:12 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

As Eric reported:

RENAME_EXCHANGE support was just added to fsstress in xfstests:

	commit 65dfd40a97b6bbbd2a22538977bab355c5bc0f06
	Author: kaixuxia <xiakaixu1987@gmail.com>
	Date:   Thu Oct 31 14:41:48 2019 +0800

	    fsstress: add EXCHANGE renameat2 support

This is causing xfstest generic/579 to fail due to fsck.f2fs reporting errors.
I'm not sure what the problem is, but it still happens even with all the
fs-verity stuff in the test commented out, so that the test just runs fsstress.

generic/579 23s ... 	[10:02:25]
[    7.745370] run fstests generic/579 at 2019-11-04 10:02:25
_check_generic_filesystem: filesystem on /dev/vdc is inconsistent
(see /results/f2fs/results-default/generic/579.full for details)
 [10:02:47]
Ran: generic/579
Failures: generic/579
Failed 1 of 1 tests
Xunit report: /results/f2fs/results-default/result.xml

Here's the contents of 579.full:

_check_generic_filesystem: filesystem on /dev/vdc is inconsistent
*** fsck.f2fs output ***
[ASSERT] (__chk_dots_dentries:1378)  --> Bad inode number[0x24] for '..', parent parent ino is [0xd10]

The root cause is that we forgot to update directory's i_pino during
cross_rename, fix it.

Fixes: 32f9bc25cbda0 ("f2fs: support ->rename2()")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/namei.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 4faf06e8bf89..a1c507b0b4ac 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -981,7 +981,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (!old_dir_entry || whiteout)
 		file_lost_pino(old_inode);
 	else
-		F2FS_I(old_inode)->i_pino = new_dir->i_ino;
+		/* adjust dir's i_pino to pass fsck check */
+		f2fs_i_pino_write(old_inode, new_dir->i_ino);
 	up_write(&F2FS_I(old_inode)->i_sem);
 
 	old_inode->i_ctime = current_time(old_inode);
@@ -1141,7 +1142,11 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	f2fs_set_link(old_dir, old_entry, old_page, new_inode);
 
 	down_write(&F2FS_I(old_inode)->i_sem);
-	file_lost_pino(old_inode);
+	if (!old_dir_entry)
+		file_lost_pino(old_inode);
+	else
+		/* adjust dir's i_pino to pass fsck check */
+		f2fs_i_pino_write(old_inode, new_dir->i_ino);
 	up_write(&F2FS_I(old_inode)->i_sem);
 
 	old_dir->i_ctime = current_time(old_dir);
@@ -1156,7 +1161,11 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	f2fs_set_link(new_dir, new_entry, new_page, old_inode);
 
 	down_write(&F2FS_I(new_inode)->i_sem);
-	file_lost_pino(new_inode);
+	if (!new_dir_entry)
+		file_lost_pino(new_inode);
+	else
+		/* adjust dir's i_pino to pass fsck check */
+		f2fs_i_pino_write(new_inode, old_dir->i_ino);
 	up_write(&F2FS_I(new_inode)->i_sem);
 
 	new_dir->i_ctime = current_time(new_dir);
-- 
2.18.0.rc1



_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix to update dir's i_pino during cross_rename
  2019-11-07  6:12 ` [f2fs-dev] " Chao Yu
@ 2019-11-07 17:05   ` Eric Biggers
  -1 siblings, 0 replies; 6+ messages in thread
From: Eric Biggers @ 2019-11-07 17:05 UTC (permalink / raw)
  To: Chao Yu; +Cc: jaegeuk, linux-kernel, linux-f2fs-devel

On Thu, Nov 07, 2019 at 02:12:05PM +0800, Chao Yu wrote:
> As Eric reported:
> 
> RENAME_EXCHANGE support was just added to fsstress in xfstests:
> 
> 	commit 65dfd40a97b6bbbd2a22538977bab355c5bc0f06
> 	Author: kaixuxia <xiakaixu1987@gmail.com>
> 	Date:   Thu Oct 31 14:41:48 2019 +0800
> 
> 	    fsstress: add EXCHANGE renameat2 support
> 
> This is causing xfstest generic/579 to fail due to fsck.f2fs reporting errors.
> I'm not sure what the problem is, but it still happens even with all the
> fs-verity stuff in the test commented out, so that the test just runs fsstress.
> 
> generic/579 23s ... 	[10:02:25]
> [    7.745370] run fstests generic/579 at 2019-11-04 10:02:25
> _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
> (see /results/f2fs/results-default/generic/579.full for details)
>  [10:02:47]
> Ran: generic/579
> Failures: generic/579
> Failed 1 of 1 tests
> Xunit report: /results/f2fs/results-default/result.xml
> 
> Here's the contents of 579.full:
> 
> _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
> *** fsck.f2fs output ***
> [ASSERT] (__chk_dots_dentries:1378)  --> Bad inode number[0x24] for '..', parent parent ino is [0xd10]
> 
> The root cause is that we forgot to update directory's i_pino during
> cross_rename, fix it.
> 
> Fixes: 32f9bc25cbda0 ("f2fs: support ->rename2()")
> Signed-off-by: Chao Yu <yuchao0@huawei.com>

Tested-by: Eric Biggers <ebiggers@kernel.org>

The i_pino field is only valid on directories, right?

- Eric

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

* Re: [f2fs-dev] [PATCH] f2fs: fix to update dir's i_pino during cross_rename
@ 2019-11-07 17:05   ` Eric Biggers
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Biggers @ 2019-11-07 17:05 UTC (permalink / raw)
  To: Chao Yu; +Cc: jaegeuk, linux-kernel, linux-f2fs-devel

On Thu, Nov 07, 2019 at 02:12:05PM +0800, Chao Yu wrote:
> As Eric reported:
> 
> RENAME_EXCHANGE support was just added to fsstress in xfstests:
> 
> 	commit 65dfd40a97b6bbbd2a22538977bab355c5bc0f06
> 	Author: kaixuxia <xiakaixu1987@gmail.com>
> 	Date:   Thu Oct 31 14:41:48 2019 +0800
> 
> 	    fsstress: add EXCHANGE renameat2 support
> 
> This is causing xfstest generic/579 to fail due to fsck.f2fs reporting errors.
> I'm not sure what the problem is, but it still happens even with all the
> fs-verity stuff in the test commented out, so that the test just runs fsstress.
> 
> generic/579 23s ... 	[10:02:25]
> [    7.745370] run fstests generic/579 at 2019-11-04 10:02:25
> _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
> (see /results/f2fs/results-default/generic/579.full for details)
>  [10:02:47]
> Ran: generic/579
> Failures: generic/579
> Failed 1 of 1 tests
> Xunit report: /results/f2fs/results-default/result.xml
> 
> Here's the contents of 579.full:
> 
> _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
> *** fsck.f2fs output ***
> [ASSERT] (__chk_dots_dentries:1378)  --> Bad inode number[0x24] for '..', parent parent ino is [0xd10]
> 
> The root cause is that we forgot to update directory's i_pino during
> cross_rename, fix it.
> 
> Fixes: 32f9bc25cbda0 ("f2fs: support ->rename2()")
> Signed-off-by: Chao Yu <yuchao0@huawei.com>

Tested-by: Eric Biggers <ebiggers@kernel.org>

The i_pino field is only valid on directories, right?

- Eric


_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix to update dir's i_pino during cross_rename
  2019-11-07 17:05   ` Eric Biggers
@ 2019-11-08  2:46     ` Chao Yu
  -1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2019-11-08  2:46 UTC (permalink / raw)
  To: Eric Biggers; +Cc: jaegeuk, linux-kernel, linux-f2fs-devel

On 2019/11/8 1:05, Eric Biggers wrote:
> On Thu, Nov 07, 2019 at 02:12:05PM +0800, Chao Yu wrote:
>> As Eric reported:
>>
>> RENAME_EXCHANGE support was just added to fsstress in xfstests:
>>
>> 	commit 65dfd40a97b6bbbd2a22538977bab355c5bc0f06
>> 	Author: kaixuxia <xiakaixu1987@gmail.com>
>> 	Date:   Thu Oct 31 14:41:48 2019 +0800
>>
>> 	    fsstress: add EXCHANGE renameat2 support
>>
>> This is causing xfstest generic/579 to fail due to fsck.f2fs reporting errors.
>> I'm not sure what the problem is, but it still happens even with all the
>> fs-verity stuff in the test commented out, so that the test just runs fsstress.
>>
>> generic/579 23s ... 	[10:02:25]
>> [    7.745370] run fstests generic/579 at 2019-11-04 10:02:25
>> _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
>> (see /results/f2fs/results-default/generic/579.full for details)
>>  [10:02:47]
>> Ran: generic/579
>> Failures: generic/579
>> Failed 1 of 1 tests
>> Xunit report: /results/f2fs/results-default/result.xml
>>
>> Here's the contents of 579.full:
>>
>> _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
>> *** fsck.f2fs output ***
>> [ASSERT] (__chk_dots_dentries:1378)  --> Bad inode number[0x24] for '..', parent parent ino is [0xd10]
>>
>> The root cause is that we forgot to update directory's i_pino during
>> cross_rename, fix it.
>>
>> Fixes: 32f9bc25cbda0 ("f2fs: support ->rename2()")
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> 
> Tested-by: Eric Biggers <ebiggers@kernel.org>

Thanks for the test.

> 
> The i_pino field is only valid on directories, right?

i_pino is also valid on regular inode, because after sudden power-cut case, we
will recover fsynced file and link it into parent directory which i_pino field
points.

For rename/cross_rename cases, we just tag src/dst regular inode with
parent_lost flag instead of updating its i_pino field, once there is fsync()
comes after rename(), we will trigger checkpoint for such parent lost inode to
keep rename/cross_rename operation as an atomic operation.

Thanks,

> 
> - Eric
> .
> 

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

* Re: [f2fs-dev] [PATCH] f2fs: fix to update dir's i_pino during cross_rename
@ 2019-11-08  2:46     ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2019-11-08  2:46 UTC (permalink / raw)
  To: Eric Biggers; +Cc: jaegeuk, linux-kernel, linux-f2fs-devel

On 2019/11/8 1:05, Eric Biggers wrote:
> On Thu, Nov 07, 2019 at 02:12:05PM +0800, Chao Yu wrote:
>> As Eric reported:
>>
>> RENAME_EXCHANGE support was just added to fsstress in xfstests:
>>
>> 	commit 65dfd40a97b6bbbd2a22538977bab355c5bc0f06
>> 	Author: kaixuxia <xiakaixu1987@gmail.com>
>> 	Date:   Thu Oct 31 14:41:48 2019 +0800
>>
>> 	    fsstress: add EXCHANGE renameat2 support
>>
>> This is causing xfstest generic/579 to fail due to fsck.f2fs reporting errors.
>> I'm not sure what the problem is, but it still happens even with all the
>> fs-verity stuff in the test commented out, so that the test just runs fsstress.
>>
>> generic/579 23s ... 	[10:02:25]
>> [    7.745370] run fstests generic/579 at 2019-11-04 10:02:25
>> _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
>> (see /results/f2fs/results-default/generic/579.full for details)
>>  [10:02:47]
>> Ran: generic/579
>> Failures: generic/579
>> Failed 1 of 1 tests
>> Xunit report: /results/f2fs/results-default/result.xml
>>
>> Here's the contents of 579.full:
>>
>> _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
>> *** fsck.f2fs output ***
>> [ASSERT] (__chk_dots_dentries:1378)  --> Bad inode number[0x24] for '..', parent parent ino is [0xd10]
>>
>> The root cause is that we forgot to update directory's i_pino during
>> cross_rename, fix it.
>>
>> Fixes: 32f9bc25cbda0 ("f2fs: support ->rename2()")
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> 
> Tested-by: Eric Biggers <ebiggers@kernel.org>

Thanks for the test.

> 
> The i_pino field is only valid on directories, right?

i_pino is also valid on regular inode, because after sudden power-cut case, we
will recover fsynced file and link it into parent directory which i_pino field
points.

For rename/cross_rename cases, we just tag src/dst regular inode with
parent_lost flag instead of updating its i_pino field, once there is fsync()
comes after rename(), we will trigger checkpoint for such parent lost inode to
keep rename/cross_rename operation as an atomic operation.

Thanks,

> 
> - Eric
> .
> 


_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2019-11-08  2:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07  6:12 [PATCH] f2fs: fix to update dir's i_pino during cross_rename Chao Yu
2019-11-07  6:12 ` [f2fs-dev] " Chao Yu
2019-11-07 17:05 ` Eric Biggers
2019-11-07 17:05   ` Eric Biggers
2019-11-08  2:46   ` Chao Yu
2019-11-08  2:46     ` Chao Yu

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.