diff options
author | Filipe David Borba Manana <fdmanana@gmail.com> | 2014-01-11 16:31:25 -0500 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-01-28 16:20:30 -0500 |
commit | c57c2b3ed248b3f1712e4172eb85b361199582f2 (patch) | |
tree | 7dc61c170e763cb469c0d11957152e702356093a /fs/btrfs/ioctl.c | |
parent | f499e40fd97698a1c48d188279647009b21905fe (diff) |
Btrfs: unlock inodes in correct order in clone ioctl
In the clone ioctl, when the source and target inodes are different,
we can acquire their mutexes in 2 possible different orders. After
we're done cloning, we were releasing the mutexes always in the same
order - the most correct way of doing it is to release them by the
reverse order they were acquired.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 332b624e25db..5ed5bd001084 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -3263,9 +3263,17 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
3263 | 3263 | ||
3264 | unlock_extent(&BTRFS_I(src)->io_tree, off, off + len - 1); | 3264 | unlock_extent(&BTRFS_I(src)->io_tree, off, off + len - 1); |
3265 | out_unlock: | 3265 | out_unlock: |
3266 | mutex_unlock(&src->i_mutex); | 3266 | if (!same_inode) { |
3267 | if (!same_inode) | 3267 | if (inode < src) { |
3268 | mutex_unlock(&inode->i_mutex); | 3268 | mutex_unlock(&src->i_mutex); |
3269 | mutex_unlock(&inode->i_mutex); | ||
3270 | } else { | ||
3271 | mutex_unlock(&inode->i_mutex); | ||
3272 | mutex_unlock(&src->i_mutex); | ||
3273 | } | ||
3274 | } else { | ||
3275 | mutex_unlock(&src->i_mutex); | ||
3276 | } | ||
3269 | out_fput: | 3277 | out_fput: |
3270 | fdput(src_file); | 3278 | fdput(src_file); |
3271 | out_drop_write: | 3279 | out_drop_write: |