Page MenuHomeFreeBSD

Make libzfs not autoload the ZFS module
Needs ReviewPublic

Authored by allanjude on Fri, Jun 19, 3:10 AM.
Tags
None
Referenced Files
F160549079: D57657.id180035.diff
Thu, Jun 25, 1:56 PM
Unknown Object (File)
Wed, Jun 24, 8:10 AM
Unknown Object (File)
Wed, Jun 24, 5:13 AM
Unknown Object (File)
Tue, Jun 23, 2:59 AM

Details

Reviewers
markj
gordon
Summary

Only load the module if the env var ZFS_AUTOLOAD_MODULE is set to YES

This prevents zpool status loading the ZFS module as a side effect.

PR: 295485
Reported by: Dan Mahoney
Event: BSDcan 2026
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 73990
Build 70873: arc lint + arc unit

Event Timeline

Do we need to have rc.d/zfs kldload zfs as-needed in case someone's implicitly relying on this and running ZFS strictly for data pools rather than root? I think that would make this a non-event for 98%+ of our users if it wasn't already.

It was determined that zpool status and zfs list are not the commands used in the original context. Instead:

zpool upgrade -v
and:
zfs upgrade -v

An upstream change has been proposed:

https://github.com/openzfs/zfs/pull/18694/changes/3c971d9b219ac135767802c5c014fdd687dacf5b

Because, unlike FreeBSD, the Linux zpool upgrade -v does depends on some kernel module results ( /sys/module/zfs/features.pool ), that part of the proposed change is FreeBSD OS specific and Linux would still load its kernel module.

Linux does not use kernel module results for zfs upgrade -v and, so, that part is more general.

It was determined that zpool status and zfs list are not the commands used in the original context. Instead:

zpool upgrade -v
and:
zfs upgrade -v

An upstream change has been proposed:

https://github.com/openzfs/zfs/pull/18694/changes/3c971d9b219ac135767802c5c014fdd687dacf5b

Because, unlike FreeBSD, the Linux zpool upgrade -v does depends on some kernel module results ( /sys/module/zfs/features.pool ), that part of the proposed change is FreeBSD OS specific and Linux would still load its kernel module.

Linux does not use kernel module results for zfs upgrade -v and, so, that part is more general.

Either way, running zpool status should ALSO not load zfs.ko automatically.

Do we need to have rc.d/zfs kldload zfs as-needed in case someone's implicitly relying on this and running ZFS strictly for data pools rather than root? I think that would make this a non-event for 98%+ of our users if it wasn't already.

Need to do more tests to confirm, but it looks like the required_modules="zfs" in rc.d/zpool that it should get taken care of that way