From: Liu Bo Date: Thu, 25 Jan 2018 18:02:50 +0000 (-0700) Subject: Btrfs: fix deadlock in run_delalloc_nocow X-Git-Tag: v4.9.83~58 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ecd72fd604b1f3aa3ec03962e4676760a8e1a1b4;p=platform%2Fkernel%2Flinux-amlogic.git 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: Signed-off-by: Liu Bo Reviewed-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a8a1fb40e258..c3d413494779 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1320,8 +1320,11 @@ next_slot: leaf = path->nodes[0]; if (path->slots[0] >= btrfs_header_nritems(leaf)) { ret = btrfs_next_leaf(root, path); - if (ret < 0) + if (ret < 0) { + if (cow_start != (u64)-1) + cur_offset = cow_start; goto error; + } if (ret > 0) break; leaf = path->nodes[0];