mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
FreeBSD: unregister mountroot eventhandler on unload
Otherwise if zfs is unloaded and reroot is being used it trips over a stale pointer. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Sponsored by: Rubicon Communications, LLC ("Netgate") Signed-off-by: Mateusz Guzik <[email protected]> Closes #16242
This commit is contained in:
1 parent
20c8bdd85e
commit
121a2d3354
1 file changed
+14
-7
@@ -111,6 +111,7 @@ static int zfs__fini(void);
|
||||
static void zfs_shutdown(void *, int);
|
||||
|
||||
static eventhandler_tag zfs_shutdown_event_tag;
|
||||
static eventhandler_tag zfs_mountroot_event_tag;
|
||||
|
||||
#define ZFS_MIN_KSTACK_PAGES 4
|
||||
|
||||
@@ -305,16 +306,25 @@ zfs_modevent(module_t mod, int type, void *unused __unused)
|
||||
switch (type) {
|
||||
case MOD_LOAD:
|
||||
err = zfs__init();
|
||||
if (err == 0)
|
||||
if (err == 0) {
|
||||
zfs_shutdown_event_tag = EVENTHANDLER_REGISTER(
|
||||
shutdown_post_sync, zfs_shutdown, NULL,
|
||||
SHUTDOWN_PRI_FIRST);
|
||||
zfs_mountroot_event_tag = EVENTHANDLER_REGISTER(
|
||||
mountroot, spa_boot_init, NULL,
|
||||
SI_ORDER_ANY);
|
||||
}
|
||||
return (err);
|
||||
case MOD_UNLOAD:
|
||||
err = zfs__fini();
|
||||
if (err == 0 && zfs_shutdown_event_tag != NULL)
|
||||
EVENTHANDLER_DEREGISTER(shutdown_post_sync,
|
||||
zfs_shutdown_event_tag);
|
||||
if (err == 0) {
|
||||
if (zfs_shutdown_event_tag != NULL)
|
||||
EVENTHANDLER_DEREGISTER(shutdown_post_sync,
|
||||
zfs_shutdown_event_tag);
|
||||
if (zfs_mountroot_event_tag != NULL)
|
||||
EVENTHANDLER_DEREGISTER(mountroot,
|
||||
zfs_mountroot_event_tag);
|
||||
}
|
||||
return (err);
|
||||
case MOD_SHUTDOWN:
|
||||
return (0);
|
||||
@@ -330,9 +340,6 @@ static moduledata_t zfs_mod = {
|
||||
0
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
EVENTHANDLER_DEFINE(mountroot, spa_boot_init, NULL, 0);
|
||||
#endif
|
||||
|
||||
FEATURE(zfs, "OpenZFS support");
|
||||
|
||||
|
||||
Reference in new issue
Block a user