Page MenuHomeFreeBSD

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

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

Details

Summary

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 <d8zNeCFG@aon.at>

Test Plan

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

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

asomers created this revision.Oct 18 2019, 3:11 PM

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) {
					continue;
				}
asomers updated this revision to Diff 67424.Jan 28 2020, 5:33 PM

Style changes suggested by Ryan

mav accepted this revision.Jan 28 2020, 10:31 PM

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
This revision was automatically updated to reflect the committed changes.

Committed with that last style comment from @mav.