]>
Commit | Line | Data |
---|---|---|
dfbc6f9b GKH |
1 | From e89166990f11c3f21e1649d760dd35f9e410321c Mon Sep 17 00:00:00 2001 |
2 | From: Liu Bo <bo.li.liu@oracle.com> | |
3 | Date: Thu, 25 Jan 2018 11:02:50 -0700 | |
4 | Subject: Btrfs: fix deadlock in run_delalloc_nocow | |
5 | ||
6 | From: Liu Bo <bo.li.liu@oracle.com> | |
7 | ||
8 | commit e89166990f11c3f21e1649d760dd35f9e410321c upstream. | |
9 | ||
10 | @cur_offset is not set back to what it should be (@cow_start) if | |
11 | btrfs_next_leaf() returns something wrong, and the range [cow_start, | |
12 | cur_offset) remains locked forever. | |
13 | ||
14 | cc: <stable@vger.kernel.org> | |
15 | Signed-off-by: Liu Bo <bo.li.liu@oracle.com> | |
16 | Reviewed-by: Josef Bacik <jbacik@fb.com> | |
17 | Signed-off-by: David Sterba <dsterba@suse.com> | |
18 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
19 | ||
20 | --- | |
21 | fs/btrfs/inode.c | 5 ++++- | |
22 | 1 file changed, 4 insertions(+), 1 deletion(-) | |
23 | ||
24 | --- a/fs/btrfs/inode.c | |
25 | +++ b/fs/btrfs/inode.c | |
26 | @@ -1330,8 +1330,11 @@ next_slot: | |
27 | leaf = path->nodes[0]; | |
28 | if (path->slots[0] >= btrfs_header_nritems(leaf)) { | |
29 | ret = btrfs_next_leaf(root, path); | |
30 | - if (ret < 0) | |
31 | + if (ret < 0) { | |
32 | + if (cow_start != (u64)-1) | |
33 | + cur_offset = cow_start; | |
34 | goto error; | |
35 | + } | |
36 | if (ret > 0) | |
37 | break; | |
38 | leaf = path->nodes[0]; |