Btrfs: avoid BUG when dropping root and reference in same transaction
authorSage Weil <sage@newdream.net>
Mon, 17 May 2010 17:15:27 +0000 (17:15 +0000)
committerChris Mason <chris.mason@oracle.com>
Fri, 11 Jun 2010 19:57:39 +0000 (15:57 -0400)
commit15e7000095e6fc9ad07e476a100c900c72c14225
treec97fa27a7727c82d78d43ac0b1df63a4f9954cfa
parent731e3d1b4348a96d53de6c084774424dedc64a3b
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>
fs/btrfs/root-tree.c