Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btrfs-progs: add option for recursive subvol snapshots #886

Open
wants to merge 18 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0e11b21
btrfs-progs: subvolume delete: add new option for recursive deletion
osandov Jun 27, 2024
082ce75
btrfs-progs: mkfs: add new option --subvol
maharmstone Aug 7, 2024
3ca473e
btrfs-progs: ci: update cleanup scripts
kdave Aug 16, 2024
2b204e1
btrfs-progs: fi show: remove stray newline in filesystem show
mattlangford Aug 8, 2024
2688073
btrfs-progs: docs: clarify number represention in on-disk-format tables
hanyuwei70 Aug 29, 2024
91a4311
btrfs-progs: mkfs: add default flag to --subvol
maharmstone Aug 15, 2024
2c8dc94
btrfs-progs: mkfs: add ro flag to --subvol
maharmstone Aug 27, 2024
50f408d
btrfs-progs: use libbtrfsutil for btrfs subvolume create
maharmstone Jun 28, 2024
a9416ed
btrfs-progs: use libbtrfsutil for btrfs subvolume snapshot
maharmstone Jun 28, 2024
261f25b
btrfs-progs: remove unused qgroup functions
maharmstone Jun 28, 2024
f396c03
btrfs-progs: add rudimentary log checking
maharmstone Jul 3, 2024
af0e8be
btrfs-progs: mkfs/rootdir: add hard link support
adam900710 Aug 15, 2024
c72719b
btrfs-progs: mkfs-tests: add hardlink related tests for --subvol
adam900710 Aug 15, 2024
184eddc
btrfs-progs: convert: fix inline extent size for symbol link
adam900710 Sep 3, 2024
2afdbd7
btrfs-progs: check/original: detect invalid file extent items for
adam900710 Sep 3, 2024
b1ccd69
btrfs-progs: check/lowmem: detect invalid file extents for symbolic l…
adam900710 Sep 3, 2024
c75b2f2
btrfs-progs: convert-tests: add a test case to verify large symbolic …
adam900710 Sep 3, 2024
180d79f
btrfs-progs: add option for recursive subvol snapshots
maharmstone Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Documentation/btrfs-subvolume.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ delete [options] [<subvolume> [<subvolume>...]], delete -i|--subvolid <subvolid>
-i|--subvolid <subvolid>
subvolume id to be removed instead of the <path> that should point to the
filesystem with the subvolume

-R|--recursive
delete subvolumes beneath each subvolume recursively

This requires either `CAP_SYS_ADMIN` or the filesystem must be
mounted with `user_subvol_rm_allowed` mount option.
In the unprivileged case, subvolumes which cannot be accessed
are skipped. The deletion is not atomic.

-v|--verbose
(deprecated) alias for global *-v* option

Expand Down Expand Up @@ -243,17 +252,23 @@ show [options] <path>
-u|--uuid UUID
show details about subvolume with the given *UUID*, looked up in *path*

snapshot [-r] [-i <qgroupid>] <source> <dest>|[<dest>/]<name>
snapshot [-r|-R|--recursive] [-i <qgroupid>] <source> <dest>|[<dest>/]<name>
Create a snapshot of the subvolume *source* with the
name *name* in the *dest* directory.

If only *dest* is given, the subvolume will be named the basename of *source*.
If *source* is not a subvolume, btrfs returns an error.

If you wish to recursively create a readonly snapshot, you can run
:command:`btrfs property set <path> ro true` on each subvolume after this command completes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity I'd suggest to mention that it has to be done from the leaves up in the tree consisting of subvolumes. Which may not be that easy to find out manually, so this could be a separate command for subvolume (in a separate patch). For parity an option to the snapshot command can be added that should read like it's doing the read-only change after the snapshots. This can be also added separatelly, we need to define the use cases first.


``Options``

-r
Make the new snapshot read only.
-R|--recursive
Recursively snapshot subvolumes beneath the source. This option cannot be
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like limitation but we can't do better in user space. This is possible in kernel but is quite complicated so we must exclude -r and -R for now. As a suggestion to documenation, the subvolume can be mad read-only afterwards by changing the property to ro.

And as this is using libbtrfsutil the same limitations apply (and need to be documented): it's not atomic and depends on the capabilities to enumerate the subvolumes. Similar to what the recursive deletion has, we might need a special section in documentation for that so we can refer to it instead of repeating the whole text.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've added a bit to the man page.

I might also look into fixing the kernel so that this can be done properly.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still does not mention the limitations, nor referes to a section where it would be explained.

combined with -r.
-i <qgroupid>
Add the newly created subvolume to a qgroup. This option can be given multiple
times.
Expand Down
439 changes: 221 additions & 218 deletions Documentation/dev/On-disk-format.rst

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions Documentation/mkfs.btrfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,29 @@ OPTIONS
contain the files from *rootdir*. Since version 4.14.1 the filesystem size is
not minimized. Please see option *--shrink* if you need that functionality.

-u|--subvol <subdir>:<flags>
Specify that *subdir* is to be created as a subvolume rather than a regular
directory. The option *--rootdir* must also be specified, and *subdir* must be an
existing subdirectory within it. This option can be specified multiple times.

*flags* is an optional comma-separated list of modifiers. Valid choices are:

* *default*: create as default subvolume (this can only be specified once)
* *ro*: create as readonly subvolume

If there are hard links inside *rootdir* and *subdir* will split the
subvolumes, like the following case::

rootdir/
|- hardlink1
|- hardlink2
|- subdir/ <- will be a subvolume
|- hardlink3

In that case we cannot create `hardlink3` as hardlinks of
`hardlink1` and `hardlink2` because hardlink3 will be inside a new
subvolume.

--shrink
Shrink the filesystem to its minimal size, only works with *--rootdir* option.

Expand Down
Loading