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

Commit ecd72fd6 authored by Liu Bo's avatar Liu Bo Committed by Greg Kroah-Hartman
Browse files

Btrfs: fix deadlock in run_delalloc_nocow



commit e89166990f11c3f21e1649d760dd35f9e410321c upstream.

@cur_offset is not set back to what it should be (@cow_start) if
btrfs_next_leaf() returns something wrong, and the range [cow_start,
cur_offset) remains locked forever.

cc: <stable@vger.kernel.org>
Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fffc0fca
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -1320,8 +1320,11 @@ static noinline int run_delalloc_nocow(struct inode *inode,
		leaf = path->nodes[0];
		leaf = path->nodes[0];
		if (path->slots[0] >= btrfs_header_nritems(leaf)) {
		if (path->slots[0] >= btrfs_header_nritems(leaf)) {
			ret = btrfs_next_leaf(root, path);
			ret = btrfs_next_leaf(root, path);
			if (ret < 0)
			if (ret < 0) {
				if (cow_start != (u64)-1)
					cur_offset = cow_start;
				goto error;
				goto error;
			}
			if (ret > 0)
			if (ret > 0)
				break;
				break;
			leaf = path->nodes[0];
			leaf = path->nodes[0];