]> git.proxmox.com Git - mirror_zfs.git/commit
Add kernel module auto-loading
authorBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 13 Mar 2018 17:45:55 +0000 (10:45 -0700)
committerTony Hutter <hutter2@llnl.gov>
Fri, 22 Feb 2019 17:47:34 +0000 (09:47 -0800)
commite3fb781c5fdaaba0ee788a1602490dc9e3a7c7d5
tree657e9c46c4ade8619357379cb6bc5668f8ef8975
parent14a5e48fb92210541ffd04081c313f4d6061a4d9
Add kernel module auto-loading

Historically a dynamic misc minor number was registered for the
/dev/zfs device in order to prevent minor number collisions.  This
was fine but it prevented us from being able to use the kernel
module auto-loaded which requires a known reserved value.

Resolve this issue by adding a configure test to find an available
misc minor number which can then be used in MODULE_ALIAS_MISCDEV at
build time.  By adding this alias the zfs kmod is added to the list
of known static-nodes and the systemd-tmpfiles-setup-dev service
will create a /dev/zfs character device at boot time.

This in turn allows us to update the 90-zfs.rules file to make it
aware this is a static node.  The upshot of this is that whenever
a process (zpool, zfs, zed) opens the /dev/zfs the kmods will be
automatic loaded.  This even works for unprivileged users so there
is no longer a need to manually load the modules at boot time.

As an additional bonus the zed now no longer needs to start after
the zfs-import.service since it will trigger the module load.

In the unlikely event the minor number we selected conflicts with
another out of tree unregistered minor number the code falls back
to dynamically allocating it.  In this case the modules again
must be manually loaded.

Note that due to the change in the method of registering the minor
number the zimport.sh test case may incorrectly fail when the
static node for the installed packages is created instead of the
dynamic one.  This issue will only transiently impact zimport.sh
for this single commit when we transition and are mixing and
matching methods.

Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
TEST_ZIMPORT_SKIP="yes"
Closes #7287
config/kernel-misc-minor.m4 [new file with mode: 0644]
config/kernel.m4
etc/modules-load.d/zfs.conf.in
etc/systemd/system/zfs-import-cache.service.in
etc/systemd/system/zfs-import-scan.service.in
lib/libzfs/libzfs_util.c
module/zfs/zfs_ioctl.c
rpm/generic/zfs.spec.in
udev/rules.d/90-zfs.rules.in