summaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorDmitry Monakhov <dmonakhov@openvz.org>2013-04-08 13:02:25 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-04-08 13:02:25 -0400
commite8238f9a8339b3578c85e4192a7a23bc2bdc0333 (patch)
treed33c573dc71982138d5fd71d6335ac664cb03bbc /fs/ext4
parent393d1d1d76933886d5e1ce603214c9987589c6d5 (diff)
downloadlinux-e8238f9a8339b3578c85e4192a7a23bc2bdc0333.tar.gz
linux-e8238f9a8339b3578c85e4192a7a23bc2bdc0333.tar.bz2
linux-e8238f9a8339b3578c85e4192a7a23bc2bdc0333.zip
ext4: fix incorrect lock ordering for ext4_ind_migrate
existing locking ordering: journal-> i_data_sem, but ext4_ind_migrate() grab locks in opposite order which may result in deadlock. Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/extents.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 6c5a70a7b573..ea607f907232 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4735,6 +4735,10 @@ int ext4_ind_migrate(struct inode *inode)
(!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
return -EINVAL;
+ handle = ext4_journal_start(inode, EXT4_HT_MIGRATE, 1);
+ if (IS_ERR(handle))
+ return PTR_ERR(handle);
+
down_write(&EXT4_I(inode)->i_data_sem);
ret = ext4_ext_check_inode(inode);
if (ret)
@@ -4758,19 +4762,13 @@ int ext4_ind_migrate(struct inode *inode)
}
}
- handle = ext4_journal_start(inode, EXT4_HT_MIGRATE, 1);
- if (IS_ERR(handle)) {
- ret = PTR_ERR(handle);
- goto errout;
- }
-
ext4_clear_inode_flag(inode, EXT4_INODE_EXTENTS);
memset(ei->i_data, 0, sizeof(ei->i_data));
for (i=0; i < len; i++)
ei->i_data[i] = cpu_to_le32(blk++);
ext4_mark_inode_dirty(handle, inode);
- ext4_journal_stop(handle);
errout:
+ ext4_journal_stop(handle);
up_write(&EXT4_I(inode)->i_data_sem);
return ret;
}