Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: dsterba@suse.cz, Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/3] btrfs-progs: introduce btrfs_rebuild_uuid_tree() for mkfs and btrfs-convert
Date: Sat, 27 Jul 2024 00:58:35 +0200	[thread overview]
Message-ID: <20240726225835.GQ17473@twin.jikos.cz> (raw)
In-Reply-To: <2a103477-428f-4145-94c0-5d2352c9a926@gmx.com>

On Sat, Jul 27, 2024 at 08:03:23AM +0930, Qu Wenruo wrote:
> 
> 
> 在 2024/7/27 01:05, David Sterba 写道:
> > On Fri, Jul 26, 2024 at 07:29:55PM +0930, Qu Wenruo wrote:
> >> Currently mkfs uses its own create_uuid_tree(), but that function is
> >> only handling FS_TREE.
> >>
> >> This means for btrfs-convert, we do not generate the uuid tree, nor
> >> add the UUID of the image subvolume.
> >>
> >> This can be a problem if we're going to support multiple subvolumes
> >> during mkfs time.
> >>
> >> To address this inconvenience, this patch introduces a new helper,
> >> btrfs_rebuild_uuid_tree(), which will:
> >>
> >> - Create a new uuid tree if there is not one
> >>
> >> - Empty the existing uuid tree
> >>
> >> - Iterate through all subvolumes
> >>    * If the subvolume has no valid UUID, regenerate one
> >>    * Add the uuid entry for the subvolume UUID
> >>    * If the subvolume has received UUID, also add it to UUID tree
> >>
> >> By this, this new helper can handle all the uuid tree generation needs for:
> >>
> >> - Current mkfs
> >>    Only one uuid entry for FS_TREE
> >>
> >> - Current btrfs-convert
> >>    Only FS_TREE and the image subvolume
> >>
> >> - Future multi-subvolume mkfs
> >>    As we do the scan for all subvolumes.
> >>
> >> - Future "btrfs rescue rebuild-uuid-tree"
> >>
> >> Signed-off-by: Qu Wenruo <wqu@suse.com>
> >> ---
> >>   common/root-tree-utils.c | 265 +++++++++++++++++++++++++++++++++++++++
> >>   common/root-tree-utils.h |   1 +
> >>   convert/main.c           |   5 +
> >>   mkfs/main.c              |  37 +-----
> >>   4 files changed, 274 insertions(+), 34 deletions(-)
> >>
> >> diff --git a/common/root-tree-utils.c b/common/root-tree-utils.c
> >> index 6a57c51a8a74..13f89dbd5293 100644
> >> --- a/common/root-tree-utils.c
> >> +++ b/common/root-tree-utils.c
> >> @@ -15,9 +15,11 @@
> >>    */
> >>
> >>   #include <time.h>
> >> +#include <uuid/uuid.h>
> >>   #include "common/root-tree-utils.h"
> >>   #include "common/messages.h"
> >>   #include "kernel-shared/disk-io.h"
> >> +#include "kernel-shared/uuid-tree.h"
> >>
> >>   int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
> >>   			struct btrfs_root *root, u64 objectid)
> >> @@ -212,3 +214,266 @@ abort:
> >>   	btrfs_abort_transaction(trans, ret);
> >>   	return ret;
> >>   }
> >> +
> >> +static int empty_tree(struct btrfs_root *root)
> >
> > Please rename this, it's confusing as empty can be a noun and verb so
> > it's not clear if it's a meant as a predicate or action.
> >
> Any recommendation? clear_tree()?

I've posted soem suggestions as the pull request review comments.

      reply	other threads:[~2024-07-26 22:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26  9:59 [PATCH 0/3] btrfs-progs: a more generic uuid tree rebuild ability Qu Wenruo
2024-07-26  9:59 ` [PATCH 1/3] btrfs-progs: move uuid-tree definitions to kernel-shared/uuid-tree.h Qu Wenruo
2024-07-26  9:59 ` [PATCH 2/3] btrfs-progs: cross-port btrfs_uuid_tree_add() from kernel Qu Wenruo
2024-07-26  9:59 ` [PATCH 3/3] btrfs-progs: introduce btrfs_rebuild_uuid_tree() for mkfs and btrfs-convert Qu Wenruo
2024-07-26 10:03   ` Qu Wenruo
2024-07-26 14:49   ` Josef Bacik
2024-07-26 15:35   ` David Sterba
2024-07-26 22:33     ` Qu Wenruo
2024-07-26 22:58       ` David Sterba [this message]

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=20240726225835.GQ17473@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    --cc=wqu@suse.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