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
Make both btrfs_subvolumes_setup implementations available (follow up of issue 2079) #2080
Make both btrfs_subvolumes_setup implementations available (follow up of issue 2079) #2080
Conversation
@rear/contributors @OliverO2 Currently this is work in progress... |
…RFS_SUBVOLUME_SLES_SETUP for improved precedence handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some ideas for improvements, but should work without those.
usr/share/rear/layout/prepare/GNU/Linux/130_include_mount_filesystem_code.sh
Outdated
Show resolved
Hide resolved
# Final fallback to be backward compatible (btrfs_subvolumes_setup_SLES is the old way): | ||
LogPrint "Doing SLES-like btrfs subvolumes setup for $device on $mountpoint (no match in BTRFS_SUBVOLUME_GENERIC_SETUP or BTRFS_SUBVOLUME_SLES_SETUP)" | ||
btrfs_subvolumes_setup_SLES $device $mountpoint $mountopts | ||
done | ||
;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, it looks like this would work and support lots of possible combinations. (I'd probably just go for a simpler variant with less configurability.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to provide the user as much freedom to specify what ReaR should do
as possible to be implemented with reasonable effort.
E.g. one can specify
BTRFS_SUBVOLUME_SLES_SETUP=( 'false' '/dev/sda3' '/dev/sdc5' )
to avoid btrfs_subvolumes_setup_SLES for all devices
except '/dev/sda3' and '/dev/sdc5' which means
btrfs_subvolumes_setup_generic is done on all other devices.
Let's try out and see how things behave in practice for now.
If it gets too complicated I can simplify it as long as
it is not yet officially documented in default.conf.
usr/share/rear/layout/prepare/GNU/Linux/130_include_mount_subvolumes_code.sh
Show resolved
Hide resolved
usr/share/rear/layout/prepare/GNU/Linux/131_include_new_btrfs_subvolumes_code.sh
Show resolved
Hide resolved
@@ -25,7 +28,7 @@ btrfs_subvolumes_setup() { | |||
mountopts="$3 $4" | |||
# Empty device or mountpoint may indicate an error. In this case be verbose and inform the user: | |||
if test -z "$device" -o -z "$mountpoint" ; then | |||
LogPrint "Empty device='$device' or mountpoint='$mountpoint' may indicate an error, skipping btrfs_subvolumes_setup( $@ )." | |||
LogPrintError "Empty device='$device' or mountpoint='$mountpoint' may indicate an error, skipping btrfs_subvolumes_setup( $@ )." | |||
Log "Return 0 from btrfs_subvolumes_setup( $@ )" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is my understanding that file system creation code as in 130_include_filesystem_code.sh
makes ReaR abort if any error occurs (and so does the new Btrfs setup implementation). Since subvolumes are file system-like objects (Btrfs doubles as a volume manager in this respect), it can be risky to continue with an incomplete setup: For example, the wrong disk partition may fill up with files restored from a backup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not want to change with this pull request how the old code behaves.
I don't know if I can error out here without causing subtle regressions.
I wished I had better descibed in my comment why I don't error out here.
Tested it a bit on SLES12: "rear recover" still works with the defaults (which is using the old code). "rear recover" fails on SLES12 with its btrfs structure when the new code is used, |
…y callee). Better descriptive names of scripts and renumbered scripts (avoid same numbers which looks sloppy).
My latest commit |
Sound reasonable to include such an automatism for now. I'm curious about discovering why the |
@OliverO2 |
Take your time. The reason why I am curious is that the generic code should create a layout for any setup (which would include SLES12). It might not be the "right" or "ideal" layout for now, but at least |
Testing helps ( unsurprisingly ;-) |
Now things work for me so far so that I like to merge it right now |
@OliverO2 In "rear -D recover" log there is
|
Ah, I see: Your version of the Btrfs tool suite requires the |
On my SLES15-like openSUSE Leap 15.0 system
which belongs to btrfsprogs version 4.15. On my SLES12 system I have btrfsprogs-4.5.3
so for SLES12 the subvolume's "name" is not possible. |
…e_GNU_Linux_13X_include_scripts_that_were_renamed_via_issue_2080 Fixed comments and messages about the layout/prepare/GNU/Linux/13X_include_... scripts that had been renamed via #2080
In layout/prepare/GNU/Linux/135_include_btrfs_subvolumes_generic_code.sh fixed 'btrfs subvolume set-default' command for older versions of 'btrfsprogs' where that command requires both arguments 'subvolid' and 'path', see #2080 (comment)
Type: Enhancement
Impact: Low
Reference to related issue (URL):
Add new implementation to recreate all mounted Btrfs subvolumes #2079 (comment)
How was this pull request tested?
Not yet tested at all by me.
Brief description of the changes in this pull request:
Now there are two functions that implement btrfs subvolumes setup:
The old btrfs_subvolumes_setup is now btrfs_subvolumes_setup_SLES
The new one from #2079
is now btrfs_subvolumes_setup_generic
There are two new user config array variables
BTRFS_SUBVOLUME_SLES_SETUP
and
BTRFS_SUBVOLUME_GENERIC_SETUP
where the suer can - if needed - specify how his btrfs subvolumes
should be set up.
When neither BTRFS_SUBVOLUME_SLES_SETUP
nor BTRFS_SUBVOLUME_GENERIC_SETUP
is set the old behaviour is kept (now via btrfs_subvolumes_setup_SLES).
When both BTRFS_SUBVOLUME_SLES_SETUP
and BTRFS_SUBVOLUME_GENERIC_SETUP are set to a false value
no btrfs subvolumes setup is done.
When BTRFS_SUBVOLUME_GENERIC_SETUP is set to a true value
or when BTRFS_SUBVOLUME_SLES_SETUP is set to a false value
btrfs subvolumes setup is done via btrfs_subvolumes_setup_generic
When BTRFS_SUBVOLUME_GENERIC_SETUP is set to a false value
or when BTRFS_SUBVOLUME_SLES_SETUP is set to a true value
btrfs subvolumes setup is done via btrfs_subvolumes_setup_SLES
When the BTRFS_SUBVOLUME_GENERIC_SETUP array contains
devices those are set up via btrfs_subvolumes_setup_generic
When the BTRFS_SUBVOLUME_SLES_SETUP array contains
devices those are set up via btrfs_subvolumes_setup_SLES