path: root/send-utils.h
diff options
authorStefan Behrens <>2013-06-26 17:17:57 +0200
committerDavid Sterba <>2013-08-09 14:32:31 +0200
commit5f9c5a23e5ff0c5949480ad24a9818c50f5a8dc6 (patch)
tree24b605db2a3d20b4ef49ba4242060df3d0a80635 /send-utils.h
parentad280c1b3a8a88e2113dd1bcb725a36be7da5356 (diff)
Btrfs-progs: use UUID tree for send/receive
This commit changes the btrfs send/receive commands to use the UUID tree to map UUIDs to subvolumes, and to use the root tree to map subvolume IDs to paths. Now these tools start fast and are independent on the number of subvolules/snapshot that exist. Before this commit, mapping UUIDs to subvolume IDs was an operation with a high effort. The algorithm even had quadratic effort (based on the number of existing subvolumes). E.g. with 15,000 subvolumes it took much more than 5 minutes on a state of the art XEON CPU to start btrfs send or receive before these tools were able to send or receive the first byte). Even linear effort instead of the current quadratic effort would be too much since it would be a waste. And these data structures to allow mapping UUIDs to subvolume IDs had been created every time a btrfs send/receive instance was started. It is much more efficient to maintain a searchable persistent data structure in the filesystem, one that is updated whenever a subvolume/snapshot is created and deleted, and when the received subvolume UUID is set by the btrfs-receive tool. Therefore kernel code was added that is able to maintain data structures in the filesystem that allow to quickly search for a given UUID and to retrieve data that is assigned to this UUID, like which subvolume ID is related to this UUID. Signed-off-by: Stefan Behrens <> Signed-off-by: David Sterba <> Signed-off-by: Chris Mason <>
Diffstat (limited to 'send-utils.h')
1 files changed, 1 insertions, 8 deletions
diff --git a/send-utils.h b/send-utils.h
index 06af75f3..ed1a40e0 100644
--- a/send-utils.h
+++ b/send-utils.h
@@ -38,10 +38,6 @@ enum subvol_search_type {
struct subvol_info {
- struct rb_node rb_root_id_node;
- struct rb_node rb_local_node;
- struct rb_node rb_received_node;
- struct rb_node rb_path_node;
u64 root_id;
u8 parent_uuid[BTRFS_UUID_SIZE];
@@ -55,10 +51,7 @@ struct subvol_info {
struct subvol_uuid_search {
- struct rb_root root_id_subvols;
- struct rb_root local_subvols;
- struct rb_root received_subvols;
- struct rb_root path_subvols;
+ int mnt_fd;
int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s);