zfs/contrib/dracut/90zfs
наб 18edf7a3ba 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.

Backport-of: 3399a30ee0
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
2023-04-18 10:10:45 -07:00
..
.gitignore dracut: 90zfs: respect zfs_force=1 on systemd systems 2021-06-10 10:50:16 -07:00
Makefile.am contrib: dracut: fix race with root=zfs:dset when necessities required 2023-04-18 10:10:45 -07:00
export-zfs.sh.in contrib/dracut: zfs-lib: export_all: replace with inline zpool export -a 2022-05-06 12:01:48 -07:00
import-opts-generator.sh.in dracut: 90zfs: respect zfs_force=1 on systemd systems 2021-06-10 10:50:16 -07:00
module-setup.sh.in contrib: dracut: fix race with root=zfs:dset when necessities required 2023-04-18 10:10:45 -07:00
mount-zfs.sh.in dracut: fix typo in mount-zfs.sh.in 2023-01-19 12:50:42 -08:00
parse-zfs.sh.in contrib; dracut: centralise root= parsing, actually support root=s 2022-05-06 12:01:48 -07:00
zfs-env-bootfs.service.in contrib: dracut: fix race with root=zfs:dset when necessities required 2023-04-18 10:10:45 -07:00
zfs-generator.sh.in contrib: dracut: fix race with root=zfs:dset when necessities required 2023-04-18 10:10:45 -07:00
zfs-lib.sh.in contrib: dracut: fix race with root=zfs:dset when necessities required 2023-04-18 10:10:45 -07:00
zfs-load-key.sh.in contrib: dracut: don't require essentials to be under the same encroot 2022-05-06 12:01:48 -07:00
zfs-needshutdown.sh.in contrib: dracut: zfs-needshutdown: don't list 2022-05-06 12:01:48 -07:00
zfs-nonroot-necessities.service.in contrib: dracut: fix race with root=zfs:dset when necessities required 2023-04-18 10:10:45 -07:00
zfs-rollback-bootfs.service.in contrib: dracut: fix race with root=zfs:dset when necessities required 2023-04-18 10:10:45 -07:00
zfs-snapshot-bootfs.service.in contrib: dracut: fix race with root=zfs:dset when necessities required 2023-04-18 10:10:45 -07:00