aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.yan@oracle.com>2009-09-21 16:00:26 -0400
committerChris Mason <chris.mason@oracle.com>2009-09-21 16:00:26 -0400
commit76dda93c6ae2c1dc3e6cde34569d6aca26b0c918 (patch)
treef5ca46ec89d4ae2c762952d5f35e2c6f95ac046a /fs/btrfs/extent-tree.c
parent4df27c4d5cc1dda54ed7d0a8389347f2df359cf9 (diff)
Btrfs: add snapshot/subvolume destroy ioctl
This patch adds snapshot/subvolume destroy ioctl. A subvolume that isn't being used and doesn't contains links to other subvolumes can be destroyed. Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 8fc922982183..4bd04f3fa8bb 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5463,9 +5463,24 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref)
5463 ret = btrfs_del_root(trans, tree_root, &root->root_key); 5463 ret = btrfs_del_root(trans, tree_root, &root->root_key);
5464 BUG_ON(ret); 5464 BUG_ON(ret);
5465 5465
5466 free_extent_buffer(root->node); 5466 if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) {
5467 free_extent_buffer(root->commit_root); 5467 ret = btrfs_find_last_root(tree_root, root->root_key.objectid,
5468 kfree(root); 5468 NULL, NULL);
5469 BUG_ON(ret < 0);
5470 if (ret > 0) {
5471 ret = btrfs_del_orphan_item(trans, tree_root,
5472 root->root_key.objectid);
5473 BUG_ON(ret);
5474 }
5475 }
5476
5477 if (root->in_radix) {
5478 btrfs_free_fs_root(tree_root->fs_info, root);
5479 } else {
5480 free_extent_buffer(root->node);
5481 free_extent_buffer(root->commit_root);
5482 kfree(root);
5483 }
5469out: 5484out:
5470 btrfs_end_transaction(trans, tree_root); 5485 btrfs_end_transaction(trans, tree_root);
5471 kfree(wc); 5486 kfree(wc);