All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 0/3] btrfs-progs: small cleanups related to subvolume creation
Date: Mon, 15 Jul 2024 14:52:07 +0930	[thread overview]
Message-ID: <cover.1721020730.git.wqu@suse.com> (raw)

[CHANGELOG]
v2:
- A new patch to cleanup btrfs_mksubvol()
  We have a kernel function with the same name, but those two are doing
  completely different works.

  The progs version is more like linking a subvolume to a destination.

  The new patch removes btrfs_mksubvol(), and move the convert specific
  code to convert code basis.

Thanks to Mark's new effort to introduce subvolume creation ability, the
long existing duplicated subvolume creation problem is exposed again.

The first patch to do a small cleanup for btrfs_create_tree() so that
the parameter list matches the kernel one.

The second one is the main dish to fully merge the different functions
to create a subvolume.

We have btrfs_create_tree() to properly create an empty tree, and
btrfs_make_root_dir() to create the initial root dir.

So use them to create btrfs_make_subvolume():

- Calls btrfs_create_tree() to properly create an empty tree
  Unlike btrfs_copy_root() used in create_subvol(), which can be unsafe
  if the source subvolume is not empty.

- Calls btrfs_read_fs_root() to setup the cache and tracking
  Inside create_data_reloc_tree() we directly added the root to
  fs_root_tree, which is only safe for data reloc tree.

  As we didn't properly set the correct tracking flags.

- Calls btrfs_make_root_dir() to setup the root directory

And finally cleanup a confusing function, btrfs_mksubvol(), which is not
really creating a subvolume, but linking a subvolume to a parent inode.

Instead of the confusing name, create a new helper,
btrfs_link_subvolume() to do the linkage, and move the convert specific
retry behavior into convert code.

Qu Wenruo (3):
  btrfs-progs: remove fs_info parameter from btrfs_create_tree()
  btrfs-progs: introduce btrfs_make_subvolume()
  btrfs-progs: use btrfs_link_subvolume() to replace btrfs_mksubvol()

 Makefile                        |   1 +
 check/main.c                    |   9 +-
 common/root-tree-utils.c        | 215 ++++++++++++++++++++++++++++++++
 common/root-tree-utils.h        |  30 +++++
 convert/main.c                  | 107 +++++++++-------
 kernel-shared/ctree.h           |   8 +-
 kernel-shared/disk-io.c         |   4 +-
 kernel-shared/disk-io.h         |   1 -
 kernel-shared/free-space-tree.c |   2 +-
 kernel-shared/inode.c           | 140 +--------------------
 mkfs/common.c                   |  39 ------
 mkfs/common.h                   |   2 -
 mkfs/main.c                     |  78 +-----------
 13 files changed, 331 insertions(+), 305 deletions(-)
 create mode 100644 common/root-tree-utils.c
 create mode 100644 common/root-tree-utils.h

--
2.45.2


             reply	other threads:[~2024-07-15  5:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15  5:22 Qu Wenruo [this message]
2024-07-15  5:22 ` [PATCH v2 1/3] btrfs-progs: remove fs_info parameter from btrfs_create_tree() Qu Wenruo
2024-07-15  5:22 ` [PATCH v2 2/3] btrfs-progs: introduce btrfs_make_subvolume() Qu Wenruo
2024-07-15  5:22 ` [PATCH v2 3/3] btrfs-progs: use btrfs_link_subvolume() to replace btrfs_mksubvol() Qu Wenruo

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.1721020730.git.wqu@suse.com \
    --to=wqu@suse.com \
    --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.