linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Mason <chris.mason@fusionio.com>
To: Stefan Behrens <sbehrens@giantdisaster.de>, Zach Brown <zab@redhat.com>
Cc: <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v5 1/8] Btrfs: introduce a tree for items that map UUIDs to something
Date: Fri, 21 Jun 2013 12:20:22 -0400	[thread overview]
Message-ID: <20130621162022.4477.20734@localhost.localdomain> (raw)
In-Reply-To: <51C41318.8070703@giantdisaster.de>

Quoting Stefan Behrens (2013-06-21 04:47:20)
> On Thu, 20 Jun 2013 12:47:04 -0700, Zach Brown wrote:
> > 
> >> +/* for items that use the BTRFS_UUID_KEY */
> >> +#define BTRFS_UUID_ITEM_TYPE_SUBVOL 0 /* for UUIDs assigned to subvols */
> >> +#define BTRFS_UUID_ITEM_TYPE_RECEIVED_SUBVOL        1 /* for UUIDs assigned to
> >> +                                               * received subvols */
> >> +
> >> +/* a sequence of such items is stored under the BTRFS_UUID_KEY */
> >> +struct btrfs_uuid_item {
> >> +    __le16 type;    /* refer to BTRFS_UUID_ITEM_TYPE* defines above */
> >> +    __le32 len;     /* number of following 64bit values */
> >> +    __le64 subid[0];        /* sequence of subids */
> >> +} __attribute__ ((__packed__));
> >> +
> > 
> > [...]
> > 
> >>  /*
> >> + * Stores items that allow to quickly map UUIDs to something else.
> >> + * These items are part of the filesystem UUID tree.
> >> + * The key is built like this:
> >> + * (UUID_upper_64_bits, BTRFS_UUID_KEY, UUID_lower_64_bits).
> >> + */
> >> +#if BTRFS_UUID_SIZE != 16
> >> +#error "UUID items require BTRFS_UUID_SIZE == 16!"
> >> +#endif
> >> +#define BTRFS_UUID_KEY      251
> > 
> > Why do we need this btrfs_uuid_item structure?  Why not set the key type
> > to either _SUBVOL or _RECEIVED_SUBVOL instead of embedding structs with
> > those types under items with the constant BTRFS_UUID_KEY.  Then use the
> > item size to determine the number of u64 subids.  Then the item has a
> > simple array of u64s in the data which will be a lot easier to work
> > with.
> 
> Maintaining a 16 bit uuid_type field inside the item is done in order to
> avoid wasting type values for the key. The type field in the key has a
> width of 8 bits, so far 34 type values are defined in ctree.h.
> 
> As long as such items are in separated trees, their type value could be
> reused in the future when the 8 bit type field is exhausted.
> 
> There was some discussion in #btrfs about this topic on 2013-04-26.
> There are pros and cons. The uuid_type field in the item allows to use
> the uuid items generically outside of the uuid tree since it occupies
> only one type value in the 8 bit type field. On the other hand, if the 8
> bit type field in the key is exhausted, it saves lines of codes and
> avoids complexity to implement a common way to expand this field instead
> of implementing multiplexing layers at multiple places, although maybe
> with some added performance penalty.
> 
> Anybody else with an opinion for this topic?

I've been thinking about this, and while I clearly did not have this use
of uuids in mind originally, they have become a key part of the FS.  They
deserve their own bits in the type field.

I know this is not an easy thing to redo, but long term it really looks
worth it to me.

-chris

  parent reply	other threads:[~2013-06-21 16:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-20 17:45 [PATCH v5 0/8] Btrfs: introduce a tree for UUID to subvol ID mapping Stefan Behrens
2013-06-20 17:45 ` [PATCH v5 1/8] Btrfs: introduce a tree for items that map UUIDs to something Stefan Behrens
2013-06-20 19:47   ` Zach Brown
2013-06-21  8:47     ` Stefan Behrens
2013-06-21 16:11       ` Zach Brown
2013-06-24 16:42         ` Stefan Behrens
2013-06-24 18:10           ` Zach Brown
2013-06-21 16:20       ` Chris Mason [this message]
2013-06-20 17:45 ` [PATCH v5 2/8] Btrfs: support printing UUID tree elements Stefan Behrens
2013-06-20 17:45 ` [PATCH v5 3/8] Btrfs: create UUID tree if required Stefan Behrens
2013-06-20 17:45 ` [PATCH v5 4/8] Btrfs: maintain subvolume items in the UUID tree Stefan Behrens
2013-06-20 17:45 ` [PATCH v5 5/8] Btrfs: fill UUID tree initially Stefan Behrens
2013-06-20 17:45 ` [PATCH v5 6/8] Btrfs: introduce uuid-tree-gen field Stefan Behrens
2013-06-20 17:45 ` [PATCH v5 7/8] Btrfs: check UUID tree during mount if required Stefan Behrens
2013-06-20 19:49   ` Zach Brown
2013-06-20 17:45 ` [PATCH v5 8/8] Btrfs: add mount option to force UUID tree checking 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=20130621162022.4477.20734@localhost.localdomain \
    --to=chris.mason@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sbehrens@giantdisaster.de \
    --cc=zab@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).