#1497 PR merged: Fix btrfsmountedsubvol exclusion and dependency management

Labels: enhancement, fixed / solved / done

OliverO2 opened issue at 2017-09-16 17:01:

This PR closes the existing gap between 'fs'-type file systems and mounted btrfs subvolumes (type 'btrfsmountedsubvol').

  • It allows mounted btrfs subvolumes to be excluded like other components, for example:
EXCLUDE_RECREATE=( "${EXCLUDE_RECREATE[@]}" "btrfsmountedsubvol:/mnt/dir" )
  • It enables dependency management for mounted btrfs subvolumes (making sure that file systems containing btrfs mount points are recreated as well).

Related: #1496

Tested on Ubuntu 16.04.3 LTS

jsmeix commented at 2017-09-18 07:34:

@OliverO2
as far as I see this is basically an additional enhancement
where no existing btrfs behaviour in ReaR could be changed.
From plain looking at the code the cleanup of the 'lvmdev' and
'swap' cases into the 'fs|btrfsmountedsubvol|swap|lvmdev' case
does not change any behaviour in ReaR.
If I am right, I would "just merge" it.

@OliverO2
I also see and I do very much appreciate it
that you replace meaningless, misleading, and confusing
names like the dummy read variable 'done' (it hurts my eyes
when I see a variable named e.g. as a shell keyword ;-)
with a proper name. Many thanks for that!

jsmeix commented at 2017-09-18 11:47:

If there are no objections I will merge it soon...

jsmeix commented at 2017-09-19 08:50:

I have tested that a ReaR recovery still works
with the SUSE SLES12-SP2 default btrfs structure.

jsmeix commented at 2018-09-25 13:40:

This pull request introduced another regression via
https://github.com/rear/rear/commit/72810e9594d121ee12b5d8394c9fc9daa31ce749
in the generate_layout_dependencies() function
in usr/share/rear/lib/layout-functions.sh via this change (excerpt)

-                done < <(grep "^fs" $LAYOUT_FILE)
+                done < <(awk '$1 ~ /^fs|btrfsmountedsubvol$/ { print; }' $LAYOUT_FILE)

On SLES11 with btrfs and separated boot partition the
disklayout.conf file can contain a (correctly) commented entry like:

#btrfsmountedsubvol /dev/sda3 / rw

that matches the above new oversophisticated awk-ward code
so that during "rear recover" in the diskdeps.conf file
something like the following false dependency appears

fs:/boot #btrfsmountedsubvol:/

but because the correctly commented #btrfsmountedsubvol component
will never be created and because fs:/boot (i.e. the filesystem creation
of the 'boot' partition) now falsely depends on that #btrfsmountedsubvol
component the filesystem of the 'boot' partition gets also not created and
"rear recover" fails in layout/prepare/default/600_show_unprocessed.sh with

No code has been generated to recreate fs:/boot (fs)
To recreate it manually add code to diskrestore.sh or abort.

The right (and minimal - i.e. KISS) change should have been

-                done < <(grep "^fs" $LAYOUT_FILE)
+                done < <(egrep '^fs |^btrfsmountedsubvol ' $LAYOUT_FILE)

so that no such false #btrfsmountedsubvol dependency would be created
because commented entries in disklayout.conf would no longer match.

jsmeix commented at 2018-09-25 13:47:

I fixed it via
https://github.com/rear/rear/commit/88f6d22a3b3812d1ca33cbf06000aafd352fabe1

jsmeix commented at 2018-09-25 14:36:

@OliverO2
could you verify if things still work for your particular use case with my
https://github.com/rear/rear/commit/88f6d22a3b3812d1ca33cbf06000aafd352fabe1

OliverO2 commented at 2018-09-25 15:32:

@jsmeix Cannot test it right now as I've removed docker from the installation.

However, I've looked at your change and commented there.

jsmeix commented at 2018-09-26 09:06:

@OliverO2
thank you for your prompt reply!

OliverO2 commented at 2018-09-26 09:08:

@jsmeix Always a pleasure. Thanks for your fix!


[Export of Github issue for rear/rear.]