Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
7541 zpool import/tryimport ioctl returns ENOMEM because provided buf…
Browse files Browse the repository at this point in the history
…fer is too small for config

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>
  • Loading branch information
pzakha authored and ahrens committed Jan 27, 2017
1 parent 898c3fe commit 8b65a70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions usr/src/lib/libzfs/common/libzfs_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,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 *, ...);
Expand Down
9 changes: 5 additions & 4 deletions usr/src/lib/libzfs/common/libzfs_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
* Copyright 2015 RackTop Systems.
* Copyright 2016 Nexenta Systems, Inc.
*/
Expand Down Expand Up @@ -380,13 +380,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);
}
Expand Down

0 comments on commit 8b65a70

Please sign in to comment.