f2fs: fix the fault of checking F2FS_LINK_MAX for rename inode
authorKinglong Mee <kinglongmee@gmail.com>
Sat, 4 Mar 2017 13:48:28 +0000 (21:48 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 21 Mar 2017 20:52:16 +0000 (16:52 -0400)
The parent directory's nlink will change, not the inode.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/namei.c

index 98f00a3a7f5016a42741169736f1182efe83a3b0..25c073f6c7d49d5600a04c219076e45b191054ae 100644 (file)
@@ -908,8 +908,8 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
                old_nlink = old_dir_entry ? -1 : 1;
                new_nlink = -old_nlink;
                err = -EMLINK;
-               if ((old_nlink > 0 && old_inode->i_nlink >= F2FS_LINK_MAX) ||
-                       (new_nlink > 0 && new_inode->i_nlink >= F2FS_LINK_MAX))
+               if ((old_nlink > 0 && old_dir->i_nlink >= F2FS_LINK_MAX) ||
+                       (new_nlink > 0 && new_dir->i_nlink >= F2FS_LINK_MAX))
                        goto out_new_dir;
        }