summaryrefslogtreecommitdiff
path: root/fs/btrfs/root-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-10 09:27:04 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-10 09:27:04 -0400
commitc5739bba5260a59cebd20a51a55080592c8d3b07 (patch)
treeff33f7acddcfc60e7395209ff949bb9d90afda32 /fs/btrfs/root-tree.c
parent0f7d52f4431c530b4f39c524448c688bb7754de5 (diff)
downloadlinux-3.10-c5739bba5260a59cebd20a51a55080592c8d3b07.tar.gz
linux-3.10-c5739bba5260a59cebd20a51a55080592c8d3b07.tar.bz2
linux-3.10-c5739bba5260a59cebd20a51a55080592c8d3b07.zip
Btrfs: snapshot progress
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/root-tree.c')
-rw-r--r--fs/btrfs/root-tree.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index ddc1c13a535..72be9836932 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -83,6 +83,8 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
{
struct btrfs_path *path;
int ret;
+ u32 refs;
+ struct btrfs_root_item *ri;
path = btrfs_alloc_path();
BUG_ON(!path);
@@ -91,7 +93,19 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
if (ret < 0)
goto out;
BUG_ON(ret != 0);
- ret = btrfs_del_item(trans, root, path);
+ ri = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),
+ path->slots[0], struct btrfs_root_item);
+
+ refs = btrfs_root_refs(ri);
+ BUG_ON(refs == 0);
+ if (refs == 1) {
+ ret = btrfs_del_item(trans, root, path);
+printk("deleting root %Lu %Lu %u\n", key->objectid, key->offset, key->flags);
+ } else {
+ btrfs_set_root_refs(ri, refs - 1);
+printk("ref now %u root %Lu %Lu %u\n", refs -1, key->objectid, key->offset, key->flags);
+ mark_buffer_dirty(path->nodes[0]);
+ }
out:
btrfs_release_path(root, path);
btrfs_free_path(path);