diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-09-28 15:58:29 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-09-28 15:58:29 -0400 |
commit | f3ce8064b388ccf420012c5a4907aae4f13fe9d0 (patch) | |
tree | 3d0cbfffc75ea698726d71c06c9b0be82982d6eb /fs | |
parent | 8d5d02e6b176565c77ff03604908b1453a22044d (diff) |
ext4: EXT4_IOC_MOVE_EXT: Check for different original and donor inodes first
Move the check to make sure the original and donor inodes are
different earlier, to avoid a potential deadlock by trying to lock the
same inode twice.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/move_extent.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 5332fd4c4028..25b6b1457360 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c | |||
@@ -1001,14 +1001,6 @@ mext_check_arguments(struct inode *orig_inode, | |||
1001 | return -EINVAL; | 1001 | return -EINVAL; |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | /* orig and donor should be different file */ | ||
1005 | if (orig_inode->i_ino == donor_inode->i_ino) { | ||
1006 | ext4_debug("ext4 move extent: The argument files should not " | ||
1007 | "be same file [ino:orig %lu, donor %lu]\n", | ||
1008 | orig_inode->i_ino, donor_inode->i_ino); | ||
1009 | return -EINVAL; | ||
1010 | } | ||
1011 | |||
1012 | /* Ext4 move extent supports only extent based file */ | 1004 | /* Ext4 move extent supports only extent based file */ |
1013 | if (!(EXT4_I(orig_inode)->i_flags & EXT4_EXTENTS_FL)) { | 1005 | if (!(EXT4_I(orig_inode)->i_flags & EXT4_EXTENTS_FL)) { |
1014 | ext4_debug("ext4 move extent: orig file is not extents " | 1006 | ext4_debug("ext4 move extent: orig file is not extents " |
@@ -1232,6 +1224,14 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, | |||
1232 | int block_len_in_page; | 1224 | int block_len_in_page; |
1233 | int uninit; | 1225 | int uninit; |
1234 | 1226 | ||
1227 | /* orig and donor should be different file */ | ||
1228 | if (orig_inode->i_ino == donor_inode->i_ino) { | ||
1229 | ext4_debug("ext4 move extent: The argument files should not " | ||
1230 | "be same file [ino:orig %lu, donor %lu]\n", | ||
1231 | orig_inode->i_ino, donor_inode->i_ino); | ||
1232 | return -EINVAL; | ||
1233 | } | ||
1234 | |||
1235 | /* protect orig and donor against a truncate */ | 1235 | /* protect orig and donor against a truncate */ |
1236 | ret1 = mext_inode_double_lock(orig_inode, donor_inode); | 1236 | ret1 = mext_inode_double_lock(orig_inode, donor_inode); |
1237 | if (ret1 < 0) | 1237 | if (ret1 < 0) |