]> git.proxmox.com Git - mirror_zfs.git/commitdiff
zpool: speed up importing large pools (#11469)
authorAlan Somers <asomers@FreeBSD.org>
Thu, 21 Jan 2021 20:55:54 +0000 (13:55 -0700)
committerGitHub <noreply@github.com>
Thu, 21 Jan 2021 20:55:54 +0000 (12:55 -0800)
The ZFS_IOC_POOL_TRYIMPORT ioctl returns an nvlist from the kernel to a
preallocated buffer in  userland.  Userland must guess how large the
buffer should be.  If it undersizes it, it must reallocate and try
again.  That can cost a lot of time for large pools.

OpenZFS commit 28b40c8a6e3 set the guess at "zc.zc_nvlist_conf_size * 4"
without explanation.  On my system, that is too small.  From experiment,
x 32 is a better multiplier.  But I don't know how to calculate it
theoretically.

Sponsored by: Axcient
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alek Pinchuk <apinchuk@axcient.com>
Signed-off-by: Alan Somers <asomers@gmail.com>
Closes #11469

lib/libzfs/libzfs_import.c

index 44d3ade496443c50a932020f89c36332609a423a..64fa31c67d0f4dbaba571d29b59f0c85b0b552c2 100644 (file)
@@ -77,7 +77,7 @@ refresh_config(libzfs_handle_t *hdl, nvlist_t *config)
        if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0)
                return (NULL);
 
-       dstbuf_size = MAX(CONFIG_BUF_MINSIZE, zc.zc_nvlist_conf_size * 4);
+       dstbuf_size = MAX(CONFIG_BUF_MINSIZE, zc.zc_nvlist_conf_size * 32);
 
        if (zcmd_alloc_dst_nvlist(hdl, &zc, dstbuf_size) != 0) {
                zcmd_free_nvlists(&zc);