From: Stefan Behrens <sbehrens@giantdisaster.de>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 0/5] Btrfs: introduce a tree for UUID to subvol ID mapping
Date: Fri, 19 Apr 2013 17:41:01 +0200 [thread overview]
Message-ID: <cover.1366384796.git.sbehrens@giantdisaster.de> (raw)
Mapping UUIDs to subvolume IDs is an operation with a high effort
today. Today, the algorithm even has quadratic effort (based on the
number of existing subvolumes), which means, that it takes minutes
to send/receive a single subvolume if 10,000 subvolumes exist. But
even linear effort would be too much since it is a waste. And these
data structures to allow mapping UUIDs to subvolume IDs are created
every time a btrfs send/receive instance is 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 is added that is able to maintain data
structures in the filesystem that allow to quickly search for a
given UUID and to retrieve the subvol ID.
Now follows the lengthy justification, why a new tree was added
instead of using the existing root tree:
The first approach was to not create another tree that holds UUID
items. Instead, the items should just go into the top root tree.
Unfortunately this confused the algorithm to assign the objectid
of subvolumes and snapshots. The reason is that
btrfs_find_free_objectid() calls btrfs_find_highest_objectid() for
the first created subvol or snapshot after mounting a filesystem,
and this function simply searches for the largest used objectid in
the root tree keys to pick the next objectid to assign. Of course,
the UUID keys have always been the ones with the highest offset
value, and the next assigned subvol ID was wastefully huge.
To use any other existing tree did not look proper. To apply a
workaround such as setting the objectid to zero in the UUID item
key and to implement collision handling would either add
limitations (in case of a btrfs_extend_item() approach to handle
the collisions) or a lot of complexity and source code (in case a
key would be looked up that is free of collisions). Adding new code
that introduces limitations is not good, and adding code that is
complex and lengthy for no good reason is also not good. That's the
justification why a completely new tree was introduced.
Stefan Behrens (5):
Btrfs: introduce a tree for items that map UUIDs to something
Btrfs: support printing UUID tree elements
Btrfs: create UUID tree if required
Btrfs: maintain subvolume items in the UUID tree
Btrfs: fill UUID tree initially
fs/btrfs/Makefile | 3 +-
fs/btrfs/ctree.h | 54 ++++++
fs/btrfs/disk-io.c | 43 ++++-
fs/btrfs/ioctl.c | 65 ++++++-
fs/btrfs/print-tree.c | 73 ++++++++
fs/btrfs/transaction.c | 21 ++-
fs/btrfs/uuid-tree.c | 497 +++++++++++++++++++++++++++++++++++++++++++++++++
fs/btrfs/volumes.c | 170 +++++++++++++++++
fs/btrfs/volumes.h | 2 +
9 files changed, 915 insertions(+), 13 deletions(-)
create mode 100644 fs/btrfs/uuid-tree.c
--
1.8.2.1
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-
next reply other threads:[~2013-04-19 15:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-19 15:41 Stefan Behrens [this message]
2013-04-19 15:41 ` [PATCH 1/5] Btrfs: introduce a tree for items that map UUIDs to something Stefan Behrens
2013-04-29 19:27 ` Josef Bacik
2013-04-19 15:41 ` [PATCH 2/5] Btrfs: support printing UUID tree elements Stefan Behrens
2013-04-29 14:31 ` David Sterba
2013-04-19 15:41 ` [PATCH 3/5] Btrfs: create UUID tree if required Stefan Behrens
2013-04-29 14:35 ` David Sterba
2013-04-19 15:41 ` [PATCH 4/5] Btrfs: maintain subvolume items in the UUID tree Stefan Behrens
2013-04-29 14:50 ` David Sterba
2013-04-19 15:41 ` [PATCH 5/5] Btrfs: fill UUID tree initially Stefan Behrens
2013-04-29 15:12 ` David Sterba
2013-04-29 17:31 ` Stefan Behrens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1366384796.git.sbehrens@giantdisaster.de \
--to=sbehrens@giantdisaster.de \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.