Skip to content

Commit 0d7d5d6

Browse files
author
Miklos Szeredi
committed
ext4: rename: move EMLINK check up
Move checking i_nlink from after ext4_get_first_dir_block() to before. The check doesn't rely on the result of that function and the function only fails on fs corruption, so the order shouldn't matter. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Reviewed-by: Jan Kara <jack@suse.cz>
1 parent c0d268c commit 0d7d5d6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎fs/ext4/namei.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3084,6 +3084,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
30843084
retval = -ENOTEMPTY;
30853085
if (!empty_dir(new.inode))
30863086
goto end_rename;
3087+
} else {
3088+
retval = -EMLINK;
3089+
if (new.dir != old.dir && EXT4_DIR_LINK_MAX(new.dir))
3090+
goto end_rename;
30873091
}
30883092
retval = -EIO;
30893093
old.dir_bh = ext4_get_first_dir_block(handle, old.inode,
@@ -3093,10 +3097,6 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
30933097
goto end_rename;
30943098
if (le32_to_cpu(old.parent_de->inode) != old.dir->i_ino)
30953099
goto end_rename;
3096-
retval = -EMLINK;
3097-
if (!new.inode && new.dir != old.dir &&
3098-
EXT4_DIR_LINK_MAX(new.dir))
3099-
goto end_rename;
31003100
BUFFER_TRACE(old.dir_bh, "get_write_access");
31013101
retval = ext4_journal_get_write_access(handle, old.dir_bh);
31023102
if (retval)

0 commit comments

Comments
 (0)