summaryrefslogtreecommitdiff
path: root/root-tree.c
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2016-11-14 10:43:21 -0800
committerDavid Sterba <dsterba@suse.com>2016-11-23 11:07:05 +0100
commit981441102199c5c9e3fca84ff3e723ddfa78de01 (patch)
tree151141eee76739f9ba94415cfb635004d3b6d478 /root-tree.c
parent441d8aea8ff939dcd4e37286831d42c91610b5eb (diff)
btrfs-progs: add btrfs_clear_free_space_tree() from the kernel
Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'root-tree.c')
-rw-r--r--root-tree.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/root-tree.c b/root-tree.c
index cca424e3..ab01a140 100644
--- a/root-tree.c
+++ b/root-tree.c
@@ -143,6 +143,31 @@ int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
return ret;
}
+/* drop the root item for 'key' from 'root' */
+int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
+ struct btrfs_key *key)
+{
+ struct btrfs_path *path;
+ int ret;
+
+ path = btrfs_alloc_path();
+ if (!path)
+ return -ENOMEM;
+ ret = btrfs_search_slot(trans, root, key, path, -1, 1);
+ if (ret < 0)
+ goto out;
+
+ if (ret != 0) {
+ ret = -ENOENT;
+ goto out;
+ }
+
+ ret = btrfs_del_item(trans, root, path);
+out:
+ btrfs_free_path(path);
+ return ret;
+}
+
/*
* add a btrfs_root_ref item. type is either BTRFS_ROOT_REF_KEY
* or BTRFS_ROOT_BACKREF_KEY.