diff options
Diffstat (limited to 'fs/btrfs/root-tree.c')
-rw-r--r-- | fs/btrfs/root-tree.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index ddc1c13a5352..72be9836932f 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, | |||
83 | { | 83 | { |
84 | struct btrfs_path *path; | 84 | struct btrfs_path *path; |
85 | int ret; | 85 | int ret; |
86 | u32 refs; | ||
87 | struct btrfs_root_item *ri; | ||
86 | 88 | ||
87 | path = btrfs_alloc_path(); | 89 | path = btrfs_alloc_path(); |
88 | BUG_ON(!path); | 90 | BUG_ON(!path); |
@@ -91,7 +93,19 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
91 | if (ret < 0) | 93 | if (ret < 0) |
92 | goto out; | 94 | goto out; |
93 | BUG_ON(ret != 0); | 95 | BUG_ON(ret != 0); |
94 | ret = btrfs_del_item(trans, root, path); | 96 | ri = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), |
97 | path->slots[0], struct btrfs_root_item); | ||
98 | |||
99 | refs = btrfs_root_refs(ri); | ||
100 | BUG_ON(refs == 0); | ||
101 | if (refs == 1) { | ||
102 | ret = btrfs_del_item(trans, root, path); | ||
103 | printk("deleting root %Lu %Lu %u\n", key->objectid, key->offset, key->flags); | ||
104 | } else { | ||
105 | btrfs_set_root_refs(ri, refs - 1); | ||
106 | printk("ref now %u root %Lu %Lu %u\n", refs -1, key->objectid, key->offset, key->flags); | ||
107 | mark_buffer_dirty(path->nodes[0]); | ||
108 | } | ||
95 | out: | 109 | out: |
96 | btrfs_release_path(root, path); | 110 | btrfs_release_path(root, path); |
97 | btrfs_free_path(path); | 111 | btrfs_free_path(path); |