mirror_zfs/contrib/dracut/Makefile.am
наб 3399a30ee0
contrib: dracut: fix race with root=zfs:dset when necessities required
This had always worked in my testing, but a user on hardware reported
this to happen 100%, and I reproduced it once with cold VM host caches.

dracut-zfs-generator runs as a systemd generator, i.e. at Some
Relatively Early Time; if root= is a fixed dataset, it tries to
"solve [necessities] statically at generation time".

If by that point zfs-import.target hasn't popped (because the import is
taking a non-negligible amount of time for whatever reason), it'll see
no children for the root datase, and as such generate no mounts.

This has never had any right to work. No-one caught this earlier because
it's just that much more convenient to have root=zfs:AUTO, which orders
itself properly.

To fix this, always run zfs-nonroot-necessities.service;
this additionally simplifies the implementation by:
  * making BOOTFS from zfs-env-bootfs.service be the real, canonical,
    root dataset name, not just "whatever the first bootfs is",
    and only set it if we're ZFS-booting
  * zfs-{rollback,snapshot}-bootfs.service can use this instead of
    re-implementing it
  * having zfs-env-bootfs.service also set BOOTFSFLAGS
  * this means the sysroot.mount drop-in can be fixed text
  * zfs-nonroot-necessities.service can also be constant and always
    enabled, because it's conditioned on BOOTFS being set

There is no longer any code generated at run-time
(the sysroot.mount drop-in is an unavoidable gratuitous cp).

The flow of BOOTFS{,FLAGS} from zfs-env-bootfs.service to sysroot.mount
is not noted explicitly in dracut.zfs(7), because (a) at some point it's
just visual noise and (b) it's already ordered via d-p-m.s from z-i.t.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #14690
2023-03-31 09:47:48 -07:00

29 lines
1.0 KiB
Makefile

pkgdracut_02dir = $(dracutdir)/modules.d/02zfsexpandknowledge
pkgdracut_02_SCRIPTS = \
%D%/02zfsexpandknowledge/module-setup.sh
pkgdracut_90dir = $(dracutdir)/modules.d/90zfs
pkgdracut_90_SCRIPTS = \
%D%/90zfs/export-zfs.sh \
%D%/90zfs/import-opts-generator.sh \
%D%/90zfs/module-setup.sh \
%D%/90zfs/mount-zfs.sh \
%D%/90zfs/parse-zfs.sh \
%D%/90zfs/zfs-generator.sh \
%D%/90zfs/zfs-lib.sh \
%D%/90zfs/zfs-load-key.sh \
%D%/90zfs/zfs-needshutdown.sh
pkgdracut_90_DATA = \
%D%/90zfs/zfs-env-bootfs.service \
%D%/90zfs/zfs-nonroot-necessities.service \
%D%/90zfs/zfs-rollback-bootfs.service \
%D%/90zfs/zfs-snapshot-bootfs.service
SUBSTFILES += $(pkgdracut_02_SCRIPTS) $(pkgdracut_90_SCRIPTS) $(pkgdracut_90_DATA)
SHELLCHECKSCRIPTS += $(pkgdracut_02_SCRIPTS) $(pkgdracut_90_SCRIPTS)
# Provided by /bin/sleep, and, again, every implementation of that supports this
$(call SHELLCHECK_OPTS,$(pkgdracut_90_SCRIPTS)): CHECKBASHISMS_IGNORE = -e 'sleep only takes one integer' -e 'sleep 0.'
dist_noinst_DATA += %D%/README.md