Btrfs-progs: use UUID tree for send/receive
authorStefan Behrens <sbehrens@giantdisaster.de>
Wed, 26 Jun 2013 15:17:57 +0000 (17:17 +0200)
committerDavid Sterba <dsterba@suse.cz>
Fri, 9 Aug 2013 12:32:31 +0000 (14:32 +0200)
commit5f9c5a23e5ff0c5949480ad24a9818c50f5a8dc6
tree24b605db2a3d20b4ef49ba4242060df3d0a80635
parentad280c1b3a8a88e2113dd1bcb725a36be7da5356
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 <sbehrens@giantdisaster.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
cmds-receive.c
cmds-send.c
send-utils.c
send-utils.h