diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2014-04-01 11:08:44 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2014-04-01 11:08:44 -0400 |
commit | 0d7d5d678bf9e07dffe22b018cf035d511d9e86e (patch) | |
tree | 400d85b05ea6b1af9bd39ce75d48de9269d8cd06 /fs/ext4/namei.c | |
parent | c0d268c3661efdfc76dde90ff2bc12806410cd0a (diff) |
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>
Diffstat (limited to 'fs/ext4/namei.c')
-rw-r--r-- | fs/ext4/namei.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 7193cea805ff..87a8a6e613ba 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -3084,6 +3084,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
3084 | retval = -ENOTEMPTY; | 3084 | retval = -ENOTEMPTY; |
3085 | if (!empty_dir(new.inode)) | 3085 | if (!empty_dir(new.inode)) |
3086 | goto end_rename; | 3086 | goto end_rename; |
3087 | } else { | ||
3088 | retval = -EMLINK; | ||
3089 | if (new.dir != old.dir && EXT4_DIR_LINK_MAX(new.dir)) | ||
3090 | goto end_rename; | ||
3087 | } | 3091 | } |
3088 | retval = -EIO; | 3092 | retval = -EIO; |
3089 | old.dir_bh = ext4_get_first_dir_block(handle, old.inode, | 3093 | 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, | |||
3093 | goto end_rename; | 3097 | goto end_rename; |
3094 | if (le32_to_cpu(old.parent_de->inode) != old.dir->i_ino) | 3098 | if (le32_to_cpu(old.parent_de->inode) != old.dir->i_ino) |
3095 | goto end_rename; | 3099 | 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; | ||
3100 | BUFFER_TRACE(old.dir_bh, "get_write_access"); | 3100 | BUFFER_TRACE(old.dir_bh, "get_write_access"); |
3101 | retval = ext4_journal_get_write_access(handle, old.dir_bh); | 3101 | retval = ext4_journal_get_write_access(handle, old.dir_bh); |
3102 | if (retval) | 3102 | if (retval) |