Skip to content

Commit 28b40c8

Browse files
gmelikovbehlendorf
authored andcommitted
OpenZFS 7541 - zpool import/tryimport ioctl returns ENOMEM
Authored by: Pavel Zakharov <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Reviewed by: Dan Kimmel <[email protected]> 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 <[email protected]> Ported-by: George Melikov <[email protected]> OpenZFS-issue: https://www.illumos.org/issues/7541 OpenZFS-commit: openzfs/openzfs@a3c7690 Closes openzfs#5704
1 parent 456079d commit 28b40c8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

include/libzfs_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ typedef enum {
131131
SHARED_SMB = 0x4
132132
} zfs_share_type_t;
133133

134+
#define CONFIG_BUF_MINSIZE 65536
135+
134136
int zfs_error(libzfs_handle_t *, int, const char *);
135137
int zfs_error_fmt(libzfs_handle_t *, int, const char *, ...);
136138
void zfs_error_aux(libzfs_handle_t *, const char *, ...);

lib/libzfs/libzfs_import.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/*
2222
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
2323
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24-
* Copyright (c) 2012 by Delphix. All rights reserved.
24+
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
2525
* Copyright 2015 RackTop Systems.
2626
* Copyright (c) 2016, Intel Corporation.
2727
*/
@@ -823,13 +823,14 @@ refresh_config(libzfs_handle_t *hdl, nvlist_t *config)
823823
{
824824
nvlist_t *nvl;
825825
zfs_cmd_t zc = {"\0"};
826-
int err;
826+
int err, dstbuf_size;
827827

828828
if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0)
829829
return (NULL);
830830

831-
if (zcmd_alloc_dst_nvlist(hdl, &zc,
832-
zc.zc_nvlist_conf_size * 2) != 0) {
831+
dstbuf_size = MAX(CONFIG_BUF_MINSIZE, zc.zc_nvlist_conf_size * 4);
832+
833+
if (zcmd_alloc_dst_nvlist(hdl, &zc, dstbuf_size) != 0) {
833834
zcmd_free_nvlists(&zc);
834835
return (NULL);
835836
}

0 commit comments

Comments
 (0)