Page MenuHomeFreeBSD

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

Authored by asomers on Oct 18 2019, 3:11 PM.
Tags
None
Referenced Files
F103201922: D22077.diff
Fri, Nov 22, 4:55 AM
Unknown Object (File)
Wed, Nov 20, 11:09 PM
Unknown Object (File)
Tue, Nov 19, 7:22 PM
Unknown Object (File)
Sun, Nov 3, 11:59 PM
Unknown Object (File)
Sun, Nov 3, 11:59 PM
Unknown Object (File)
Sun, Nov 3, 11:59 PM
Unknown Object (File)
Sun, Nov 3, 11:59 PM
Unknown Object (File)
Sun, Nov 3, 11:38 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 - subversion
Lint
Lint Not Applicable
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) {
					continue;
				}

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.