Page MenuHomeFreeBSD

Speed up "zpool import" in the presence of many zvols

Authored by asomers on Oct 18 2019, 3:11 PM.



Speed up "zpool import" in the presence of many zvols

By default, zpools may not be backed by zvols (that can be changed with the
"vfs.zfs.vol.recursive sysctl). When that sysctl is set to 0, the kernel
does not attempt to read zvols when looking for vdevs. But the zpool
command still does. This change brings the zpool command into line with the
kernel's behavior. It speeds "zpool import" when an already imported pool
has many zvols.

PR: 241083
Reported by: Martin Birgmeier <>

Test Plan

Ran all "zpool import"-related tests from the ZFS test suite

Diff Detail

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

I have recently looked at this function to port adapt it for ZoF. I like the overall idea here, but as a nit please do try matching the surrounding style. I would also find it easier to follow without the extra negations. Calling the bool skip_zvols would read more naturally to me.

	boolean_t skip_zvols = B_FALSE;
	if (sysctlbyname("vfs.zfs.vol.recursive", &value, &size, NULL, 0) == 0 &&
	    value == 0) {
		skip_zvols = B_TRUE;
				if (skip_zvols &&
				    strcmp(mp->lg_name, "ZFS::ZVOL") == 0) {

Style changes suggested by Ryan

I have no objections, other than I would not use braces for the if's, or at least put the opening one in the first case on the same like, as Ryan proposed.

Seems it should not be a problem to adapt it to ZoF.

This revision is now accepted and ready to land.Jan 28 2020, 10:31 PM

Committed with that last style comment from @mav.