Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD: unregister mountroot eventhandler on unload #16242

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions module/os/freebsd/zfs/kmod_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand All @@ -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");

Expand Down
Loading