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
Unknown Object (File)
Sat, Apr 20, 3:54 PM
Unknown Object (File)
Fri, Mar 29, 1:24 AM
Unknown Object (File)
Jan 27 2024, 9:45 AM
Unknown Object (File)
Jan 11 2024, 10:45 PM
Unknown Object (File)
Jan 10 2024, 7:45 AM
Unknown Object (File)
Jan 5 2024, 11:40 PM
Unknown Object (File)
Dec 22 2023, 10:02 PM
Unknown Object (File)
Dec 1 2023, 3:22 AM

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.