Message ID | cover.1697430866.git.wqu@suse.com (mailing list archive) |
---|---|
Headers | show |
Series | btrfs-progs: mkfs: introduce an experimental --subvol option | expand |
Hi Qu, On 16/10/2023 06.38, Qu Wenruo wrote: > Issue #42 (good number by the way) is suggesting a very useful feature > for rootfs image creation. > > Currently we only support "mkfs.btrfs --rootdir" to fill the fs tree > with target directory, but there has no btrfs specific features > involved. > > If we can create certain paths as subvolumes, not pure directories, it > can be very useful to create the whole btrfs image just by "mkfs.btrfs" > > This series is the first step torwards this idea. > > Now we have a new experimental option "--subvol" for mkfs.btrfs, but > with the following limits: I have a suggestion and an enhancement request: - why not use --mk-subvol? to me it seems more clear that a subvolume will be created - add another option like --mk-default-subvolume that: - create a subvolume - make it the default. The use case is the following: in btrfs it is easy make a snapshot, and move/rename/delete subvolumes and snapshot. The only exception is the subvolid=5 (or /). You cannot delete it. So if you want to do a snapshot of / and then rollback to this snapshot, it is complicated because you cannot remove the original subvolume. Starting from a subvolume different from subvolid=5 makes this easier. > > - No co-operation with --rootdir > This requires --rootdir to have extra handling for any existing > inodes. > (Currently --rootdir assumes the fs tree is completely empty) > > - No multiple --subvol options supports > This requires us to collect and sort all the paths and start creating > subvolumes from the shortest path. > Furthermore this requires us to create subvolume under another > subvolume. > > Each limit would need a new series of patches to address, but this > series would already provide a working but not-that-useful > implementation of "--subvol" option, along with a basic test case for > it. > > Qu Wenruo (6): > btrfs-progs: enhance btrfs_mkdir() function > btrfs-progs: enhance and rename btrfs_mksubvol() function > btrfs-progs: enhance btrfs_create_root() function > btrfs-progs: use a unified btrfs_make_subvol() implementation > btrfs-progs: mkfs: introduce experimental --subvol option > btrfs-progs: mkfs-tests: introduce a test case to verify --subvol > option > > convert/main.c | 60 ++------ > kernel-shared/ctree.c | 106 ++++++-------- > kernel-shared/ctree.h | 12 +- > kernel-shared/inode.c | 129 ++++++++++++----- > kernel-shared/root-tree.c | 86 +++++++++++ > mkfs/common.c | 39 ----- > mkfs/common.h | 2 - > mkfs/main.c | 103 ++++---------- > mkfs/rootdir.c | 157 +++++++++++++++++++++ > mkfs/rootdir.h | 1 + > tests/mkfs-tests/031-subvol-option/test.sh | 39 +++++ > tune/convert-bgt.c | 3 +- > tune/quota.c | 2 +- > 13 files changed, 473 insertions(+), 266 deletions(-) > create mode 100755 tests/mkfs-tests/031-subvol-option/test.sh > > -- > 2.42.0 >