[PATCH 036/106] Btrfs: fix lock leak when resuming snapshot deletion

From: Luis Henriques
Date: Tue Jul 30 2013 - 05:32:58 EST


3.5.7.18 -stable review patch. If anyone has any objections, please let me know.

------------------

From: Josef Bacik <jbacik@xxxxxxxxxxxx>

commit fec386ac1428f9c0e672df952cbca5cebd4e4e2f upstream.

We aren't setting path->locks[level] when we resume a snapshot deletion which
means we won't unlock the buffer when we free the path. This causes deadlocks
if we happen to re-allocate the block before we've evicted the extent buffer
from cache. Thanks,

Reported-by: Alex Lyakas <alex.btrfs@xxxxxxxxxxxxxxxxx>
Signed-off-by: Josef Bacik <jbacik@xxxxxxxxxxxx>
Signed-off-by: Luis Henriques <luis.henriques@xxxxxxxxxxxxx>
---
fs/btrfs/extent-tree.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9e99ea0..9b1dc7b 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6905,6 +6905,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
while (1) {
btrfs_tree_lock(path->nodes[level]);
btrfs_set_lock_blocking(path->nodes[level]);
+ path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;

ret = btrfs_lookup_extent_info(trans, root,
path->nodes[level]->start,
@@ -6921,6 +6922,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
break;

btrfs_tree_unlock(path->nodes[level]);
+ path->locks[level] = 0;
WARN_ON(wc->refs[level] != 1);
level--;
}
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/