diff options
author | Alan Somers <asomers@FreeBSD.org> | 2020-01-28 23:07:31 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2020-01-28 23:07:31 +0000 |
commit | 03e7a2be06a2ce72077515cf86a7bba48c3bae5e (patch) | |
tree | 34d8ddce78b23bb52a12633fef9bd7e72dac44a6 /cddl | |
parent | 5458a63bca18b3651f68bbc82a1d031742dbc62b (diff) | |
download | src-03e7a2be06a2ce72077515cf86a7bba48c3bae5e.tar.gz src-03e7a2be06a2ce72077515cf86a7bba48c3bae5e.zip |
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, or a zvol with many snapshots.
PR: 241083
Reported by: Martin Birgmeier <d8zNeCFG@aon.at>
Reviewed by: mav, Ryan Moeller <ryan@freqlabs.com>
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D22077
Notes
Notes:
svn path=/head/; revision=357235
Diffstat (limited to 'cddl')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c index a982e545a0b8..87c8dd14898b 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c @@ -1244,12 +1244,20 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg) avl_tree_t slice_cache; rdsk_node_t *slice; void *cookie; + boolean_t skip_zvols = B_FALSE; + int value; + size_t size = sizeof(value); if (dirs == 0) { dirs = 1; dir = &default_dir; } + if (sysctlbyname("vfs.zfs.vol.recursive", &value, &size, NULL, 0) == 0 + && value == 0) { + skip_zvols = B_TRUE; + } + /* * Go through and read the label configuration information from every * possible device, organizing the information according to pool GUID @@ -1314,6 +1322,10 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg) } LIST_FOREACH(mp, &mesh.lg_class, lg_class) { + if (skip_zvols && + strcmp(mp->lg_name, "ZFS::ZVOL") == 0) { + continue; + } LIST_FOREACH(gp, &mp->lg_geom, lg_geom) { LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { slice = zfs_alloc(hdl, sizeof (rdsk_node_t)); |