Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c57c2b3e authored by Filipe David Borba Manana's avatar Filipe David Borba Manana Committed by Chris Mason
Browse files

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: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent f499e40f
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -3263,9 +3263,17 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,

	unlock_extent(&BTRFS_I(src)->io_tree, off, off + len - 1);
out_unlock:
	if (!same_inode) {
		if (inode < src) {
			mutex_unlock(&src->i_mutex);
	if (!same_inode)
			mutex_unlock(&inode->i_mutex);
		} else {
			mutex_unlock(&inode->i_mutex);
			mutex_unlock(&src->i_mutex);
		}
	} else {
		mutex_unlock(&src->i_mutex);
	}
out_fput:
	fdput(src_file);
out_drop_write: