Btrfs: fix lock leak when resuming snapshot deletion
authorJosef Bacik <jbacik@fusionio.com>
Mon, 15 Jul 2013 16:41:42 +0000 (12:41 -0400)
committerJosef Bacik <jbacik@fusionio.com>
Fri, 19 Jul 2013 19:07:11 +0000 (15:07 -0400)
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,

Cc: stable@vger.kernel.org
Reported-by: Alex Lyakas <alex.btrfs@zadarastorage.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/extent-tree.c

index a429704dd95f7d23ce1287fd27d4f0628610dfb5..e814b13125111cbe6cd4a34ea95defea324502b3 100644 (file)
@@ -7523,6 +7523,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,
@@ -7538,6 +7539,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--;
                }