Patch "f2fs: fix to update dir's i_pino during cross_rename" has been added to the 4.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    f2fs: fix to update dir's i_pino during cross_rename

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     f2fs-fix-to-update-dir-s-i_pino-during-cross_rename.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4453d8462c3f84d653510cbf84268f7e7fc50504
Author: Chao Yu <yuchao0@xxxxxxxxxx>
Date:   Thu Nov 7 14:12:05 2019 +0800

    f2fs: fix to update dir's i_pino during cross_rename
    
    [ Upstream commit 2a60637f06ac94869b2e630eaf837110d39bf291 ]
    
    As Eric reported:
    
    RENAME_EXCHANGE support was just added to fsstress in xfstests:
    
            commit 65dfd40a97b6bbbd2a22538977bab355c5bc0f06
            Author: kaixuxia <xiakaixu1987@xxxxxxxxx>
            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@xxxxxxxxxx>
    Tested-by: Eric Biggers <ebiggers@xxxxxxxxxx>
    Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index b80e7db3b55b..b13383948fca 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -862,7 +862,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);
@@ -1027,7 +1028,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);
@@ -1042,7 +1047,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);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux