aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2010-05-17 13:15:27 -0400
committerChris Mason <chris.mason@oracle.com>2010-06-11 15:57:39 -0400
commit15e7000095e6fc9ad07e476a100c900c72c14225 (patch)
treec97fa27a7727c82d78d43ac0b1df63a4f9954cfa /fs
parent731e3d1b4348a96d53de6c084774424dedc64a3b (diff)
Btrfs: avoid BUG when dropping root and reference in same transaction
If btrfs_ioctl_snap_destroy() deletes a snapshot but finishes with end_transaction(), the cleaner kthread may come in and drop the root in the same transaction. If that's the case, the root's refs still == 1 in the tree when btrfs_del_root() deletes the item, because commit_fs_roots() hasn't updated it yet (that happens during the commit). This wasn't a problem before only because btrfs_ioctl_snap_destroy() would commit the transaction before dropping the dentry reference, so the dead root wouldn't get queued up until after the fs root item was updated in the btree. Since it is not an error to drop the root reference and the root in the same transaction, just drop the BUG_ON() in btrfs_del_root(). Signed-off-by: Sage Weil <sage@newdream.net> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/root-tree.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index b91ccd972644..2d958be761c8 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -330,7 +330,6 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
330{ 330{
331 struct btrfs_path *path; 331 struct btrfs_path *path;
332 int ret; 332 int ret;
333 u32 refs;
334 struct btrfs_root_item *ri; 333 struct btrfs_root_item *ri;
335 struct extent_buffer *leaf; 334 struct extent_buffer *leaf;
336 335
@@ -344,8 +343,6 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
344 leaf = path->nodes[0]; 343 leaf = path->nodes[0];
345 ri = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_item); 344 ri = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_item);
346 345
347 refs = btrfs_disk_root_refs(leaf, ri);
348 BUG_ON(refs != 0);
349 ret = btrfs_del_item(trans, root, path); 346 ret = btrfs_del_item(trans, root, path);
350out: 347out:
351 btrfs_free_path(path); 348 btrfs_free_path(path);