RFC: better import integration with systemd, hotplug et al.
#4178 opened on Jan 8, 2016
Description
First, this is not an issue report per se, but rather an "RFC issue".
Currently, zfs pool importing and mounting completely bypasses the udev and hotplug machinery. That is, even the systemd pool import unit file begins with:
Requires=systemd-udev-settle.service
After=systemd-udev-settle.service
It does not hook up itself to local-fs.target, nothing. Moreover, zfs has its own dataset mounting machinery which, again, bypasses the systemd state machine. This may sound beneficial to most due to their familiarity, but (from top of my head — the list is not too impressive, but it isn't exhaustive):
- this does not allow to import pools/mount datasets after relevant devices are hot-plugged;
- this does not allow to write unit files depending on zfs datasets (well, it does, but systemd won't wait for the devices to become available and will fail right away if datasets have not been mounted beforehand);
- this means all of the usual problems with
udevadm settle(races with disk controller init).
One of the ways to solve this, for ZFS on Linux specifically, would be to integrate nicely into the existing event/dependency infrastructure (the other way would be to devise a separate hotplug handling subsystem which does not use udevadm settle, which is likely not going to happen). In particular:
- import pools as they become plugged-in (probably subject to some filtering), by triggering import from udev rules;
- From the kernel driver, create "fake" block devices for each imported dataset, which then can be "mounted" from fstab (and waited for by systemd).
Or, other way around:
- from udev rules, set
ENV{SYSTEMD_READY}=0on all block devices which appear to participate in zfs pools; - import pools as they become plugged-in (probably subject to some filtering), by triggering import from udev rules;
- once a pool has been imported in any way, mark participating block devices as
ENV{SYSTEMD_READY}=1on all block devices of this pool; - allow mounting a zfs dataset by any of its devices and dataset name in mount options (btrfs-like).
Is anybody interested in this? Maybe there are better ways? Maybe this is already done, just not reflected in mans and anywhere?