]> git.proxmox.com Git - mirror_zfs.git/commitdiff
OpenZFS 7541 - zpool import/tryimport ioctl returns ENOMEM
authorGeorge Melikov <mail@gmelikov.ru>
Mon, 30 Jan 2017 21:20:55 +0000 (00:20 +0300)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 30 Jan 2017 21:20:54 +0000 (13:20 -0800)
Authored by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>

The refresh_config() calls into the kernel with ZFS_IOC_POOL_TRYIMPORT.
This ioctl returns the config of the pool in a buffer pre-allocated in
userland. The original estimate for the size is too conservative since
it doesn't account for the large size of vdev stats that are added to
the config before returning.
This fix simply increases the size of the buffer passed. This results in
a speed up of the zpool import process, and less spam in zfs_dbgmsg.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: George Melikov <mail@gmelikov.ru>
OpenZFS-issue: https://www.illumos.org/issues/7541
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/a3c7690
Closes #5704

include/libzfs_impl.h
lib/libzfs/libzfs_import.c

index 36441ed7bb3ab5f7741866c5c73fa877f73b28b1..75a7bc2490fb523693b0a40ad68d3b57e60a93a4 100644 (file)
@@ -131,6 +131,8 @@ typedef enum {
        SHARED_SMB = 0x4
 } zfs_share_type_t;
 
+#define        CONFIG_BUF_MINSIZE      65536
+
 int zfs_error(libzfs_handle_t *, int, const char *);
 int zfs_error_fmt(libzfs_handle_t *, int, const char *, ...);
 void zfs_error_aux(libzfs_handle_t *, const char *, ...);
index d09367e885c631acd67a4d72a58cb9858247a57f..1e378321c612d55f5849e9aeebb62935153136dd 100644 (file)
@@ -21,7 +21,7 @@
 /*
  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  * Copyright 2015 RackTop Systems.
  * Copyright (c) 2016, Intel Corporation.
  */
@@ -823,13 +823,14 @@ refresh_config(libzfs_handle_t *hdl, nvlist_t *config)
 {
        nvlist_t *nvl;
        zfs_cmd_t zc = {"\0"};
-       int err;
+       int err, dstbuf_size;
 
        if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0)
                return (NULL);
 
-       if (zcmd_alloc_dst_nvlist(hdl, &zc,
-           zc.zc_nvlist_conf_size * 2) != 0) {
+       dstbuf_size = MAX(CONFIG_BUF_MINSIZE, zc.zc_nvlist_conf_size * 4);
+
+       if (zcmd_alloc_dst_nvlist(hdl, &zc, dstbuf_size) != 0) {
                zcmd_free_nvlists(&zc);
                return (NULL);
        }