libzfs: don't NULL-check infallible allocations
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13229
This commit is contained in:
parent
bc3f12bfac
commit
18dbf5c8c3
|
@ -447,12 +447,7 @@ changelist_add_mounted(zfs_handle_t *zhp, void *data)
|
||||||
|
|
||||||
ASSERT3U(clp->cl_prop, ==, ZFS_PROP_MOUNTPOINT);
|
ASSERT3U(clp->cl_prop, ==, ZFS_PROP_MOUNTPOINT);
|
||||||
|
|
||||||
if ((cn = zfs_alloc(zfs_get_handle(zhp),
|
cn = zfs_alloc(zfs_get_handle(zhp), sizeof (prop_changenode_t));
|
||||||
sizeof (prop_changenode_t))) == NULL) {
|
|
||||||
zfs_close(zhp);
|
|
||||||
return (ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
cn->cn_handle = zhp;
|
cn->cn_handle = zhp;
|
||||||
cn->cn_mounted = zfs_is_mounted(zhp, NULL);
|
cn->cn_mounted = zfs_is_mounted(zhp, NULL);
|
||||||
ASSERT3U(cn->cn_mounted, ==, B_TRUE);
|
ASSERT3U(cn->cn_mounted, ==, B_TRUE);
|
||||||
|
@ -522,12 +517,7 @@ change_one(zfs_handle_t *zhp, void *data)
|
||||||
(clp->cl_shareprop != ZPROP_INVAL &&
|
(clp->cl_shareprop != ZPROP_INVAL &&
|
||||||
(share_sourcetype == ZPROP_SRC_DEFAULT ||
|
(share_sourcetype == ZPROP_SRC_DEFAULT ||
|
||||||
share_sourcetype == ZPROP_SRC_INHERITED))) {
|
share_sourcetype == ZPROP_SRC_INHERITED))) {
|
||||||
if ((cn = zfs_alloc(zfs_get_handle(zhp),
|
cn = zfs_alloc(zfs_get_handle(zhp), sizeof (prop_changenode_t));
|
||||||
sizeof (prop_changenode_t))) == NULL) {
|
|
||||||
ret = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
cn->cn_handle = zhp;
|
cn->cn_handle = zhp;
|
||||||
cn->cn_mounted = (clp->cl_gflags & CL_GATHER_MOUNT_ALWAYS) ||
|
cn->cn_mounted = (clp->cl_gflags & CL_GATHER_MOUNT_ALWAYS) ||
|
||||||
zfs_is_mounted(zhp, NULL);
|
zfs_is_mounted(zhp, NULL);
|
||||||
|
@ -630,8 +620,7 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
|
||||||
char property[ZFS_MAXPROPLEN];
|
char property[ZFS_MAXPROPLEN];
|
||||||
boolean_t legacy = B_FALSE;
|
boolean_t legacy = B_FALSE;
|
||||||
|
|
||||||
if ((clp = zfs_alloc(zhp->zfs_hdl, sizeof (prop_changelist_t))) == NULL)
|
clp = zfs_alloc(zhp->zfs_hdl, sizeof (prop_changelist_t));
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For mountpoint-related tasks, we want to sort everything by
|
* For mountpoint-related tasks, we want to sort everything by
|
||||||
|
@ -744,13 +733,7 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
|
||||||
* Always add ourself to the list. We add ourselves to the end so that
|
* Always add ourself to the list. We add ourselves to the end so that
|
||||||
* we're the last to be unmounted.
|
* we're the last to be unmounted.
|
||||||
*/
|
*/
|
||||||
if ((cn = zfs_alloc(zhp->zfs_hdl,
|
cn = zfs_alloc(zhp->zfs_hdl, sizeof (prop_changenode_t));
|
||||||
sizeof (prop_changenode_t))) == NULL) {
|
|
||||||
zfs_close(temp);
|
|
||||||
changelist_free(clp);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
cn->cn_handle = temp;
|
cn->cn_handle = temp;
|
||||||
cn->cn_mounted = (clp->cl_gflags & CL_GATHER_MOUNT_ALWAYS) ||
|
cn->cn_mounted = (clp->cl_gflags & CL_GATHER_MOUNT_ALWAYS) ||
|
||||||
zfs_is_mounted(temp, NULL);
|
zfs_is_mounted(temp, NULL);
|
||||||
|
|
|
@ -126,8 +126,7 @@ namespace_reload(libzfs_handle_t *hdl)
|
||||||
return (no_memory(hdl));
|
return (no_memory(hdl));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0)
|
zcmd_alloc_dst_nvlist(hdl, &zc, 0);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
zc.zc_cookie = hdl->libzfs_ns_gen;
|
zc.zc_cookie = hdl->libzfs_ns_gen;
|
||||||
|
@ -141,10 +140,7 @@ namespace_reload(libzfs_handle_t *hdl)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
|
zcmd_expand_dst_nvlist(hdl, &zc);
|
||||||
zcmd_free_nvlists(&zc);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -181,18 +177,8 @@ namespace_reload(libzfs_handle_t *hdl)
|
||||||
nvlist_t *child;
|
nvlist_t *child;
|
||||||
uu_avl_index_t where;
|
uu_avl_index_t where;
|
||||||
|
|
||||||
if ((cn = zfs_alloc(hdl, sizeof (config_node_t))) == NULL) {
|
cn = zfs_alloc(hdl, sizeof (config_node_t));
|
||||||
nvlist_free(config);
|
cn->cn_name = zfs_strdup(hdl, nvpair_name(elem));
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((cn->cn_name = zfs_strdup(hdl,
|
|
||||||
nvpair_name(elem))) == NULL) {
|
|
||||||
free(cn);
|
|
||||||
nvlist_free(config);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
child = fnvpair_value_nvlist(elem);
|
child = fnvpair_value_nvlist(elem);
|
||||||
if (nvlist_dup(child, &cn->cn_config, 0) != 0) {
|
if (nvlist_dup(child, &cn->cn_config, 0) != 0) {
|
||||||
free(cn->cn_name);
|
free(cn->cn_name);
|
||||||
|
@ -273,8 +259,7 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
|
||||||
if (zhp->zpool_config_size == 0)
|
if (zhp->zpool_config_size == 0)
|
||||||
zhp->zpool_config_size = 1 << 16;
|
zhp->zpool_config_size = 1 << 16;
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size) != 0)
|
zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_STATS,
|
if (zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_STATS,
|
||||||
|
@ -286,12 +271,9 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errno == ENOMEM) {
|
if (errno == ENOMEM)
|
||||||
if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
|
zcmd_expand_dst_nvlist(hdl, &zc);
|
||||||
zcmd_free_nvlists(&zc);
|
else {
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_free_nvlists(&zc);
|
||||||
if (errno == ENOENT || errno == EINVAL)
|
if (errno == ENOENT || errno == EINVAL)
|
||||||
*missing = B_TRUE;
|
*missing = B_TRUE;
|
||||||
|
|
|
@ -783,8 +783,6 @@ derive_key(libzfs_handle_t *hdl, zfs_keyformat_t format, uint64_t iters,
|
||||||
*key_out = NULL;
|
*key_out = NULL;
|
||||||
|
|
||||||
key = zfs_alloc(hdl, WRAPPING_KEY_LEN);
|
key = zfs_alloc(hdl, WRAPPING_KEY_LEN);
|
||||||
if (!key)
|
|
||||||
return (ENOMEM);
|
|
||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case ZFS_KEYFORMAT_RAW:
|
case ZFS_KEYFORMAT_RAW:
|
||||||
|
|
|
@ -331,13 +331,10 @@ get_stats_ioctl(zfs_handle_t *zhp, zfs_cmd_t *zc)
|
||||||
(void) strlcpy(zc->zc_name, zhp->zfs_name, sizeof (zc->zc_name));
|
(void) strlcpy(zc->zc_name, zhp->zfs_name, sizeof (zc->zc_name));
|
||||||
|
|
||||||
while (zfs_ioctl(hdl, ZFS_IOC_OBJSET_STATS, zc) != 0) {
|
while (zfs_ioctl(hdl, ZFS_IOC_OBJSET_STATS, zc) != 0) {
|
||||||
if (errno == ENOMEM) {
|
if (errno == ENOMEM)
|
||||||
if (zcmd_expand_dst_nvlist(hdl, zc) != 0) {
|
zcmd_expand_dst_nvlist(hdl, zc);
|
||||||
return (-1);
|
else
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -353,17 +350,14 @@ get_recvd_props_ioctl(zfs_handle_t *zhp)
|
||||||
zfs_cmd_t zc = {"\0"};
|
zfs_cmd_t zc = {"\0"};
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0)
|
zcmd_alloc_dst_nvlist(hdl, &zc, 0);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
||||||
|
|
||||||
while (zfs_ioctl(hdl, ZFS_IOC_OBJSET_RECVD_PROPS, &zc) != 0) {
|
while (zfs_ioctl(hdl, ZFS_IOC_OBJSET_RECVD_PROPS, &zc) != 0) {
|
||||||
if (errno == ENOMEM) {
|
if (errno == ENOMEM)
|
||||||
if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
|
zcmd_expand_dst_nvlist(hdl, &zc);
|
||||||
return (-1);
|
else {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_free_nvlists(&zc);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -415,8 +409,8 @@ get_stats(zfs_handle_t *zhp)
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
zfs_cmd_t zc = {"\0"};
|
zfs_cmd_t zc = {"\0"};
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
|
zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
|
||||||
return (-1);
|
|
||||||
if (get_stats_ioctl(zhp, &zc) != 0)
|
if (get_stats_ioctl(zhp, &zc) != 0)
|
||||||
rc = -1;
|
rc = -1;
|
||||||
else if (put_stats_zhdl(zhp, &zc) != 0)
|
else if (put_stats_zhdl(zhp, &zc) != 0)
|
||||||
|
@ -489,10 +483,8 @@ make_dataset_handle(libzfs_handle_t *hdl, const char *path)
|
||||||
|
|
||||||
zhp->zfs_hdl = hdl;
|
zhp->zfs_hdl = hdl;
|
||||||
(void) strlcpy(zhp->zfs_name, path, sizeof (zhp->zfs_name));
|
(void) strlcpy(zhp->zfs_name, path, sizeof (zhp->zfs_name));
|
||||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0) {
|
zcmd_alloc_dst_nvlist(hdl, &zc, 0);
|
||||||
free(zhp);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
if (get_stats_ioctl(zhp, &zc) == -1) {
|
if (get_stats_ioctl(zhp, &zc) == -1) {
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_free_nvlists(&zc);
|
||||||
free(zhp);
|
free(zhp);
|
||||||
|
@ -1847,9 +1839,8 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props)
|
||||||
*/
|
*/
|
||||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
||||||
|
|
||||||
if ((ret = zcmd_write_src_nvlist(hdl, &zc, nvl)) != 0 ||
|
zcmd_write_src_nvlist(hdl, &zc, nvl);
|
||||||
(ret = zcmd_alloc_dst_nvlist(hdl, &zc, 0)) != 0)
|
zcmd_alloc_dst_nvlist(hdl, &zc, 0);
|
||||||
goto error;
|
|
||||||
|
|
||||||
ret = zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
|
ret = zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
|
||||||
|
|
||||||
|
@ -1885,8 +1876,7 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props)
|
||||||
zfs_prop_to_name(ZFS_PROP_VOLSIZE),
|
zfs_prop_to_name(ZFS_PROP_VOLSIZE),
|
||||||
old_volsize) != 0)
|
old_volsize) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (zcmd_write_src_nvlist(hdl, &zc, nvl) != 0)
|
zcmd_write_src_nvlist(hdl, &zc, nvl);
|
||||||
goto error;
|
|
||||||
(void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
|
(void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2195,12 +2185,9 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
|
||||||
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
libzfs_handle_t *hdl = zhp->zfs_hdl;
|
||||||
struct mnttab entry;
|
struct mnttab entry;
|
||||||
|
|
||||||
if (libzfs_mnttab_find(hdl, zhp->zfs_name, &entry) == 0) {
|
if (libzfs_mnttab_find(hdl, zhp->zfs_name, &entry) == 0)
|
||||||
zhp->zfs_mntopts = zfs_strdup(hdl,
|
zhp->zfs_mntopts = zfs_strdup(hdl,
|
||||||
entry.mnt_mntopts);
|
entry.mnt_mntopts);
|
||||||
if (zhp->zfs_mntopts == NULL)
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
zhp->zfs_mntcheck = B_TRUE;
|
zhp->zfs_mntcheck = B_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2267,8 +2254,8 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
|
||||||
case ZFS_PROP_NORMALIZE:
|
case ZFS_PROP_NORMALIZE:
|
||||||
case ZFS_PROP_UTF8ONLY:
|
case ZFS_PROP_UTF8ONLY:
|
||||||
case ZFS_PROP_CASE:
|
case ZFS_PROP_CASE:
|
||||||
if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
|
zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
|
||||||
return (-1);
|
|
||||||
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
|
||||||
if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_OBJSET_ZPLPROPS, &zc)) {
|
if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_OBJSET_ZPLPROPS, &zc)) {
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_free_nvlists(&zc);
|
||||||
|
@ -4505,10 +4492,6 @@ zfs_rename(zfs_handle_t *zhp, const char *target, renameflags_t flags)
|
||||||
}
|
}
|
||||||
if (flags.recursive) {
|
if (flags.recursive) {
|
||||||
char *parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name);
|
char *parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name);
|
||||||
if (parentname == NULL) {
|
|
||||||
ret = -1;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
delim = strchr(parentname, '@');
|
delim = strchr(parentname, '@');
|
||||||
*delim = '\0';
|
*delim = '\0';
|
||||||
zfs_handle_t *zhrp = zfs_open(zhp->zfs_hdl, parentname,
|
zfs_handle_t *zhrp = zfs_open(zhp->zfs_hdl, parentname,
|
||||||
|
@ -4670,14 +4653,9 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*last == NULL) {
|
if (*last == NULL) {
|
||||||
if ((entry = zfs_alloc(hdl,
|
entry = zfs_alloc(hdl, sizeof (zprop_list_t));
|
||||||
sizeof (zprop_list_t))) == NULL ||
|
entry->pl_user_prop =
|
||||||
((entry->pl_user_prop = zfs_strdup(hdl,
|
zfs_strdup(hdl, nvpair_name(elem));
|
||||||
nvpair_name(elem)))) == NULL) {
|
|
||||||
free(entry);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
entry->pl_prop = ZPROP_INVAL;
|
entry->pl_prop = ZPROP_INVAL;
|
||||||
entry->pl_width = strlen(nvpair_name(elem));
|
entry->pl_width = strlen(nvpair_name(elem));
|
||||||
entry->pl_all = B_TRUE;
|
entry->pl_all = B_TRUE;
|
||||||
|
@ -4790,10 +4768,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
|
||||||
(void) no_memory(hdl);
|
(void) no_memory(hdl);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (zcmd_write_src_nvlist(hdl, &zc, nvlist) != 0) {
|
zcmd_write_src_nvlist(hdl, &zc, nvlist);
|
||||||
nvlist_free(nvlist);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ZFS_SMB_ACL_PURGE:
|
case ZFS_SMB_ACL_PURGE:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -602,11 +602,10 @@ get_snapshot_names(differ_info_t *di, const char *fromsnap,
|
||||||
|
|
||||||
di->isclone = B_TRUE;
|
di->isclone = B_TRUE;
|
||||||
di->fromsnap = zfs_strdup(hdl, fromsnap);
|
di->fromsnap = zfs_strdup(hdl, fromsnap);
|
||||||
if (tsnlen) {
|
if (tsnlen)
|
||||||
di->tosnap = zfs_strdup(hdl, tosnap);
|
di->tosnap = zfs_strdup(hdl, tosnap);
|
||||||
} else {
|
else
|
||||||
return (make_temp_snapshot(di));
|
return (make_temp_snapshot(di));
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int dslen = fdslen ? fdslen : tdslen;
|
int dslen = fdslen ? fdslen : tdslen;
|
||||||
|
|
||||||
|
|
|
@ -175,10 +175,10 @@ extern int zprop_expand_list(libzfs_handle_t *hdl, zprop_list_t **plp,
|
||||||
|
|
||||||
typedef struct prop_changelist prop_changelist_t;
|
typedef struct prop_changelist prop_changelist_t;
|
||||||
|
|
||||||
extern int zcmd_alloc_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, size_t);
|
extern void zcmd_alloc_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, size_t);
|
||||||
extern int zcmd_write_src_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *);
|
extern void zcmd_write_src_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *);
|
||||||
extern int zcmd_write_conf_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *);
|
extern void zcmd_write_conf_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *);
|
||||||
extern int zcmd_expand_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *);
|
extern void zcmd_expand_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *);
|
||||||
extern int zcmd_read_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t **);
|
extern int zcmd_read_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t **);
|
||||||
extern void zcmd_free_nvlists(zfs_cmd_t *);
|
extern void zcmd_free_nvlists(zfs_cmd_t *);
|
||||||
|
|
||||||
|
|
|
@ -73,23 +73,15 @@ refresh_config(libzfs_handle_t *hdl, nvlist_t *config)
|
||||||
zfs_cmd_t zc = {"\0"};
|
zfs_cmd_t zc = {"\0"};
|
||||||
int err, dstbuf_size;
|
int err, dstbuf_size;
|
||||||
|
|
||||||
if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0)
|
zcmd_write_conf_nvlist(hdl, &zc, config);
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
dstbuf_size = MAX(CONFIG_BUF_MINSIZE, zc.zc_nvlist_conf_size * 32);
|
dstbuf_size = MAX(CONFIG_BUF_MINSIZE, zc.zc_nvlist_conf_size * 32);
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, dstbuf_size) != 0) {
|
zcmd_alloc_dst_nvlist(hdl, &zc, dstbuf_size);
|
||||||
zcmd_free_nvlists(&zc);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((err = zfs_ioctl(hdl, ZFS_IOC_POOL_TRYIMPORT,
|
while ((err = zfs_ioctl(hdl, ZFS_IOC_POOL_TRYIMPORT,
|
||||||
&zc)) != 0 && errno == ENOMEM) {
|
&zc)) != 0 && errno == ENOMEM)
|
||||||
if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
|
zcmd_expand_dst_nvlist(hdl, &zc);
|
||||||
zcmd_free_nvlists(&zc);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_free_nvlists(&zc);
|
||||||
|
@ -442,12 +434,7 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr,
|
||||||
|
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if ((*namestr = zfs_strdup(hdl, name)) == NULL) {
|
*namestr = zfs_strdup(hdl, name);
|
||||||
if (cb.cb_zhp)
|
|
||||||
zpool_close(cb.cb_zhp);
|
|
||||||
nvlist_free(config);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
*state = (pool_state_t)stateval;
|
*state = (pool_state_t)stateval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,7 @@ top:
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
/* expand nvlist memory and try again */
|
/* expand nvlist memory and try again */
|
||||||
if (zcmd_expand_dst_nvlist(zhp->zfs_hdl, zc) != 0) {
|
zcmd_expand_dst_nvlist(zhp->zfs_hdl, zc);
|
||||||
zcmd_free_nvlists(zc);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
zc->zc_cookie = orig_cookie;
|
zc->zc_cookie = orig_cookie;
|
||||||
goto top;
|
goto top;
|
||||||
/*
|
/*
|
||||||
|
@ -113,8 +110,7 @@ zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data)
|
||||||
if (zhp->zfs_type != ZFS_TYPE_FILESYSTEM)
|
if (zhp->zfs_type != ZFS_TYPE_FILESYSTEM)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
|
zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_DATASET_LIST_NEXT,
|
while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_DATASET_LIST_NEXT,
|
||||||
&zc)) == 0) {
|
&zc)) == 0) {
|
||||||
|
@ -154,8 +150,7 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func,
|
||||||
|
|
||||||
zc.zc_simple = simple;
|
zc.zc_simple = simple;
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
|
zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (min_txg != 0) {
|
if (min_txg != 0) {
|
||||||
range_nvl = fnvlist_alloc();
|
range_nvl = fnvlist_alloc();
|
||||||
|
@ -167,12 +162,8 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func,
|
||||||
fnvlist_add_uint64(range_nvl, SNAP_ITER_MAX_TXG, max_txg);
|
fnvlist_add_uint64(range_nvl, SNAP_ITER_MAX_TXG, max_txg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (range_nvl != NULL &&
|
if (range_nvl != NULL)
|
||||||
zcmd_write_src_nvlist(zhp->zfs_hdl, &zc, range_nvl) != 0) {
|
zcmd_write_src_nvlist(zhp->zfs_hdl, &zc, range_nvl);
|
||||||
zcmd_free_nvlists(&zc);
|
|
||||||
fnvlist_free(range_nvl);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_SNAPSHOT_LIST_NEXT,
|
while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_SNAPSHOT_LIST_NEXT,
|
||||||
&zc)) == 0) {
|
&zc)) == 0) {
|
||||||
|
|
|
@ -1572,29 +1572,19 @@ zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force)
|
||||||
*/
|
*/
|
||||||
if (used == alloc) {
|
if (used == alloc) {
|
||||||
if (alloc == 0) {
|
if (alloc == 0) {
|
||||||
|
sets = zfs_alloc(hdl,
|
||||||
if ((sets = zfs_alloc(hdl,
|
8 * sizeof (struct sets_s));
|
||||||
8 * sizeof (struct sets_s))) == NULL)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
alloc = 8;
|
alloc = 8;
|
||||||
} else {
|
} else {
|
||||||
void *ptr;
|
sets = zfs_realloc(hdl, sets,
|
||||||
|
|
||||||
if ((ptr = zfs_realloc(hdl, sets,
|
|
||||||
alloc * sizeof (struct sets_s),
|
alloc * sizeof (struct sets_s),
|
||||||
alloc * 2 * sizeof (struct sets_s)))
|
alloc * 2 * sizeof (struct sets_s));
|
||||||
== NULL)
|
|
||||||
goto out;
|
|
||||||
sets = ptr;
|
|
||||||
|
|
||||||
alloc *= 2;
|
alloc *= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sets[used].mountpoint = zfs_strdup(hdl,
|
sets[used].mountpoint = zfs_strdup(hdl, entry.mnt_mountp);
|
||||||
entry.mnt_mountp)) == NULL)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is allowed to fail, in case there is some I/O error. It
|
* This is allowed to fail, in case there is some I/O error. It
|
||||||
|
|
|
@ -79,16 +79,12 @@ zpool_get_all_props(zpool_handle_t *zhp)
|
||||||
|
|
||||||
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0)
|
zcmd_alloc_dst_nvlist(hdl, &zc, 0);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
while (zfs_ioctl(hdl, ZFS_IOC_POOL_GET_PROPS, &zc) != 0) {
|
while (zfs_ioctl(hdl, ZFS_IOC_POOL_GET_PROPS, &zc) != 0) {
|
||||||
if (errno == ENOMEM) {
|
if (errno == ENOMEM)
|
||||||
if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
|
zcmd_expand_dst_nvlist(hdl, &zc);
|
||||||
zcmd_free_nvlists(&zc);
|
else {
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_free_nvlists(&zc);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -813,10 +809,7 @@ zpool_set_prop(zpool_handle_t *zhp, const char *propname, const char *propval)
|
||||||
*/
|
*/
|
||||||
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||||
|
|
||||||
if (zcmd_write_src_nvlist(zhp->zpool_hdl, &zc, nvl) != 0) {
|
zcmd_write_src_nvlist(zhp->zpool_hdl, &zc, nvl);
|
||||||
nvlist_free(nvl);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_SET_PROPS, &zc);
|
ret = zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_SET_PROPS, &zc);
|
||||||
|
|
||||||
|
@ -982,10 +975,8 @@ vdev_expand_proplist(zpool_handle_t *zhp, const char *vdevname,
|
||||||
|
|
||||||
strval = fnvlist_lookup_string(propval, ZPROP_VALUE);
|
strval = fnvlist_lookup_string(propval, ZPROP_VALUE);
|
||||||
|
|
||||||
if ((entry = zfs_alloc(zhp->zpool_hdl,
|
entry = zfs_alloc(zhp->zpool_hdl,
|
||||||
sizeof (zprop_list_t))) == NULL)
|
sizeof (zprop_list_t));
|
||||||
return (ENOMEM);
|
|
||||||
|
|
||||||
entry->pl_prop = prop;
|
entry->pl_prop = prop;
|
||||||
entry->pl_user_prop = zfs_strdup(zhp->zpool_hdl,
|
entry->pl_user_prop = zfs_strdup(zhp->zpool_hdl,
|
||||||
propname);
|
propname);
|
||||||
|
@ -1179,8 +1170,7 @@ zpool_open_canfail(libzfs_handle_t *hdl, const char *pool)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((zhp = zfs_alloc(hdl, sizeof (zpool_handle_t))) == NULL)
|
zhp = zfs_alloc(hdl, sizeof (zpool_handle_t));
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
zhp->zpool_hdl = hdl;
|
zhp->zpool_hdl = hdl;
|
||||||
(void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
|
(void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
|
||||||
|
@ -1211,8 +1201,7 @@ zpool_open_silent(libzfs_handle_t *hdl, const char *pool, zpool_handle_t **ret)
|
||||||
zpool_handle_t *zhp;
|
zpool_handle_t *zhp;
|
||||||
boolean_t missing;
|
boolean_t missing;
|
||||||
|
|
||||||
if ((zhp = zfs_alloc(hdl, sizeof (zpool_handle_t))) == NULL)
|
zhp = zfs_alloc(hdl, sizeof (zpool_handle_t));
|
||||||
return (-1);
|
|
||||||
|
|
||||||
zhp->zpool_hdl = hdl;
|
zhp->zpool_hdl = hdl;
|
||||||
(void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
|
(void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
|
||||||
|
@ -1388,8 +1377,7 @@ zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot,
|
||||||
if (!zpool_name_valid(hdl, B_FALSE, pool))
|
if (!zpool_name_valid(hdl, B_FALSE, pool))
|
||||||
return (zfs_error(hdl, EZFS_INVALIDNAME, msg));
|
return (zfs_error(hdl, EZFS_INVALIDNAME, msg));
|
||||||
|
|
||||||
if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0)
|
zcmd_write_conf_nvlist(hdl, &zc, nvroot);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
if (props) {
|
if (props) {
|
||||||
prop_flags_t flags = { .create = B_TRUE, .import = B_FALSE };
|
prop_flags_t flags = { .create = B_TRUE, .import = B_FALSE };
|
||||||
|
@ -1450,8 +1438,8 @@ zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zc_props && zcmd_write_src_nvlist(hdl, &zc, zc_props) != 0)
|
if (zc_props)
|
||||||
goto create_failed;
|
zcmd_write_src_nvlist(hdl, &zc, zc_props);
|
||||||
|
|
||||||
(void) strlcpy(zc.zc_name, pool, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, pool, sizeof (zc.zc_name));
|
||||||
|
|
||||||
|
@ -1665,8 +1653,7 @@ zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot)
|
||||||
return (zfs_error(hdl, EZFS_BADVERSION, msg));
|
return (zfs_error(hdl, EZFS_BADVERSION, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0)
|
zcmd_write_conf_nvlist(hdl, &zc, nvroot);
|
||||||
return (-1);
|
|
||||||
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||||
|
|
||||||
if (zfs_ioctl(hdl, ZFS_IOC_VDEV_ADD, &zc) != 0) {
|
if (zfs_ioctl(hdl, ZFS_IOC_VDEV_ADD, &zc) != 0) {
|
||||||
|
@ -2048,10 +2035,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
|
||||||
if ((props = zpool_valid_proplist(hdl, origname,
|
if ((props = zpool_valid_proplist(hdl, origname,
|
||||||
props, version, flags, errbuf)) == NULL)
|
props, version, flags, errbuf)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (zcmd_write_src_nvlist(hdl, &zc, props) != 0) {
|
zcmd_write_src_nvlist(hdl, &zc, props);
|
||||||
nvlist_free(props);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
nvlist_free(props);
|
nvlist_free(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2059,23 +2043,13 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
|
||||||
|
|
||||||
zc.zc_guid = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID);
|
zc.zc_guid = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID);
|
||||||
|
|
||||||
if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0) {
|
zcmd_write_conf_nvlist(hdl, &zc, config);
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_alloc_dst_nvlist(hdl, &zc, zc.zc_nvlist_conf_size * 2);
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, zc.zc_nvlist_conf_size * 2) != 0) {
|
|
||||||
zcmd_free_nvlists(&zc);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
zc.zc_cookie = flags;
|
zc.zc_cookie = flags;
|
||||||
while ((ret = zfs_ioctl(hdl, ZFS_IOC_POOL_IMPORT, &zc)) != 0 &&
|
while ((ret = zfs_ioctl(hdl, ZFS_IOC_POOL_IMPORT, &zc)) != 0 &&
|
||||||
errno == ENOMEM) {
|
errno == ENOMEM)
|
||||||
if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
|
zcmd_expand_dst_nvlist(hdl, &zc);
|
||||||
zcmd_free_nvlists(&zc);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
error = errno;
|
error = errno;
|
||||||
|
|
||||||
|
@ -3408,8 +3382,7 @@ zpool_vdev_attach(zpool_handle_t *zhp, const char *old_disk,
|
||||||
|
|
||||||
free(newname);
|
free(newname);
|
||||||
|
|
||||||
if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0)
|
zcmd_write_conf_nvlist(hdl, &zc, nvroot);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
ret = zfs_ioctl(hdl, ZFS_IOC_VDEV_ATTACH, &zc);
|
ret = zfs_ioctl(hdl, ZFS_IOC_VDEV_ATTACH, &zc);
|
||||||
|
|
||||||
|
@ -3815,10 +3788,9 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot,
|
||||||
zc.zc_cookie = ZPOOL_EXPORT_AFTER_SPLIT;
|
zc.zc_cookie = ZPOOL_EXPORT_AFTER_SPLIT;
|
||||||
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||||
(void) strlcpy(zc.zc_string, newname, sizeof (zc.zc_string));
|
(void) strlcpy(zc.zc_string, newname, sizeof (zc.zc_string));
|
||||||
if (zcmd_write_conf_nvlist(hdl, &zc, newconfig) != 0)
|
zcmd_write_conf_nvlist(hdl, &zc, newconfig);
|
||||||
goto out;
|
if (zc_props != NULL)
|
||||||
if (zc_props != NULL && zcmd_write_src_nvlist(hdl, &zc, zc_props) != 0)
|
zcmd_write_src_nvlist(hdl, &zc, zc_props);
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (zfs_ioctl(hdl, ZFS_IOC_VDEV_SPLIT, &zc) != 0) {
|
if (zfs_ioctl(hdl, ZFS_IOC_VDEV_SPLIT, &zc) != 0) {
|
||||||
retval = zpool_standard_error(hdl, errno, msg);
|
retval = zpool_standard_error(hdl, errno, msg);
|
||||||
|
@ -4020,19 +3992,12 @@ zpool_clear(zpool_handle_t *zhp, const char *path, nvlist_t *rewindnvl)
|
||||||
zpool_get_load_policy(rewindnvl, &policy);
|
zpool_get_load_policy(rewindnvl, &policy);
|
||||||
zc.zc_cookie = policy.zlp_rewind;
|
zc.zc_cookie = policy.zlp_rewind;
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size * 2) != 0)
|
zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size * 2);
|
||||||
return (-1);
|
zcmd_write_src_nvlist(hdl, &zc, rewindnvl);
|
||||||
|
|
||||||
if (zcmd_write_src_nvlist(hdl, &zc, rewindnvl) != 0)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
while ((error = zfs_ioctl(hdl, ZFS_IOC_CLEAR, &zc)) != 0 &&
|
while ((error = zfs_ioctl(hdl, ZFS_IOC_CLEAR, &zc)) != 0 &&
|
||||||
errno == ENOMEM) {
|
errno == ENOMEM)
|
||||||
if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
|
zcmd_expand_dst_nvlist(hdl, &zc);
|
||||||
zcmd_free_nvlists(&zc);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!error || ((policy.zlp_rewind & ZPOOL_TRY_REWIND) &&
|
if (!error || ((policy.zlp_rewind & ZPOOL_TRY_REWIND) &&
|
||||||
errno != EPERM && errno != EACCES)) {
|
errno != EPERM && errno != EACCES)) {
|
||||||
|
@ -4408,13 +4373,11 @@ zpool_log_history(libzfs_handle_t *hdl, const char *message)
|
||||||
{
|
{
|
||||||
zfs_cmd_t zc = {"\0"};
|
zfs_cmd_t zc = {"\0"};
|
||||||
nvlist_t *args;
|
nvlist_t *args;
|
||||||
int err;
|
|
||||||
|
|
||||||
args = fnvlist_alloc();
|
args = fnvlist_alloc();
|
||||||
fnvlist_add_string(args, "message", message);
|
fnvlist_add_string(args, "message", message);
|
||||||
err = zcmd_write_src_nvlist(hdl, &zc, args);
|
zcmd_write_src_nvlist(hdl, &zc, args);
|
||||||
if (err == 0)
|
int err = zfs_ioctl(hdl, ZFS_IOC_LOG_HISTORY, &zc);
|
||||||
err = zfs_ioctl(hdl, ZFS_IOC_LOG_HISTORY, &zc);
|
|
||||||
nvlist_free(args);
|
nvlist_free(args);
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_free_nvlists(&zc);
|
||||||
return (err);
|
return (err);
|
||||||
|
@ -4556,8 +4519,7 @@ zpool_events_next(libzfs_handle_t *hdl, nvlist_t **nvp,
|
||||||
if (flags & ZEVENT_NONBLOCK)
|
if (flags & ZEVENT_NONBLOCK)
|
||||||
zc.zc_guid = ZEVENT_NONBLOCK;
|
zc.zc_guid = ZEVENT_NONBLOCK;
|
||||||
|
|
||||||
if (zcmd_alloc_dst_nvlist(hdl, &zc, ZEVENT_SIZE) != 0)
|
zcmd_alloc_dst_nvlist(hdl, &zc, ZEVENT_SIZE);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
if (zfs_ioctl(hdl, ZFS_IOC_EVENTS_NEXT, &zc) != 0) {
|
if (zfs_ioctl(hdl, ZFS_IOC_EVENTS_NEXT, &zc) != 0) {
|
||||||
|
@ -4574,13 +4536,8 @@ retry:
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
|
zcmd_expand_dst_nvlist(hdl, &zc);
|
||||||
error = zfs_error_fmt(hdl, EZFS_NOMEM,
|
goto retry;
|
||||||
dgettext(TEXT_DOMAIN, "cannot get event"));
|
|
||||||
goto out;
|
|
||||||
} else {
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
error = zpool_standard_error_fmt(hdl, errno,
|
error = zpool_standard_error_fmt(hdl, errno,
|
||||||
dgettext(TEXT_DOMAIN, "cannot get event"));
|
dgettext(TEXT_DOMAIN, "cannot get event"));
|
||||||
|
|
|
@ -2778,8 +2778,6 @@ recv_read_nvlist(libzfs_handle_t *hdl, int fd, int len, nvlist_t **nvp,
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
buf = zfs_alloc(hdl, len);
|
buf = zfs_alloc(hdl, len);
|
||||||
if (buf == NULL)
|
|
||||||
return (ENOMEM);
|
|
||||||
|
|
||||||
if (len > hdl->libzfs_max_nvlist) {
|
if (len > hdl->libzfs_max_nvlist) {
|
||||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "nvlist too large"));
|
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "nvlist too large"));
|
||||||
|
@ -3521,12 +3519,10 @@ again:
|
||||||
zc.zc_cookie = B_TRUE; /* received */
|
zc.zc_cookie = B_TRUE; /* received */
|
||||||
(void) snprintf(zc.zc_name, sizeof (zc.zc_name),
|
(void) snprintf(zc.zc_name, sizeof (zc.zc_name),
|
||||||
"%s@%s", fsname, nvpair_name(snapelem));
|
"%s@%s", fsname, nvpair_name(snapelem));
|
||||||
if (zcmd_write_src_nvlist(hdl, &zc,
|
zcmd_write_src_nvlist(hdl, &zc, props);
|
||||||
props) == 0) {
|
(void) zfs_ioctl(hdl,
|
||||||
(void) zfs_ioctl(hdl,
|
ZFS_IOC_SET_PROP, &zc);
|
||||||
ZFS_IOC_SET_PROP, &zc);
|
zcmd_free_nvlists(&zc);
|
||||||
zcmd_free_nvlists(&zc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for different snapname */
|
/* check for different snapname */
|
||||||
|
@ -4879,10 +4875,9 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||||
|
|
||||||
(void) strcpy(zc.zc_name, destsnap);
|
(void) strcpy(zc.zc_name, destsnap);
|
||||||
zc.zc_cookie = B_TRUE; /* received */
|
zc.zc_cookie = B_TRUE; /* received */
|
||||||
if (zcmd_write_src_nvlist(hdl, &zc, snapprops_nvlist) == 0) {
|
zcmd_write_src_nvlist(hdl, &zc, snapprops_nvlist);
|
||||||
(void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
|
(void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_free_nvlists(&zc);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (err == 0 && snapholds_nvlist) {
|
if (err == 0 && snapholds_nvlist) {
|
||||||
nvpair_t *pair;
|
nvpair_t *pair;
|
||||||
|
|
|
@ -1149,7 +1149,7 @@ zfs_path_to_zhandle(libzfs_handle_t *hdl, const char *path, zfs_type_t argtype)
|
||||||
* Initialize the zc_nvlist_dst member to prepare for receiving an nvlist from
|
* Initialize the zc_nvlist_dst member to prepare for receiving an nvlist from
|
||||||
* an ioctl().
|
* an ioctl().
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len)
|
zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len)
|
||||||
{
|
{
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
|
@ -1157,10 +1157,6 @@ zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len)
|
||||||
zc->zc_nvlist_dst_size = len;
|
zc->zc_nvlist_dst_size = len;
|
||||||
zc->zc_nvlist_dst =
|
zc->zc_nvlist_dst =
|
||||||
(uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size);
|
(uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size);
|
||||||
if (zc->zc_nvlist_dst == 0)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1168,16 +1164,12 @@ zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len)
|
||||||
* expand the nvlist to the size specified in 'zc_nvlist_dst_size', which was
|
* expand the nvlist to the size specified in 'zc_nvlist_dst_size', which was
|
||||||
* filled in by the kernel to indicate the actual required size.
|
* filled in by the kernel to indicate the actual required size.
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
zcmd_expand_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc)
|
zcmd_expand_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc)
|
||||||
{
|
{
|
||||||
free((void *)(uintptr_t)zc->zc_nvlist_dst);
|
free((void *)(uintptr_t)zc->zc_nvlist_dst);
|
||||||
zc->zc_nvlist_dst =
|
zc->zc_nvlist_dst =
|
||||||
(uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size);
|
(uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size);
|
||||||
if (zc->zc_nvlist_dst == 0)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1194,36 +1186,33 @@ zcmd_free_nvlists(zfs_cmd_t *zc)
|
||||||
zc->zc_nvlist_dst = 0;
|
zc->zc_nvlist_dst = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
zcmd_write_nvlist_com(libzfs_handle_t *hdl, uint64_t *outnv, uint64_t *outlen,
|
zcmd_write_nvlist_com(libzfs_handle_t *hdl, uint64_t *outnv, uint64_t *outlen,
|
||||||
nvlist_t *nvl)
|
nvlist_t *nvl)
|
||||||
{
|
{
|
||||||
char *packed;
|
char *packed;
|
||||||
|
|
||||||
size_t len = fnvlist_size(nvl);
|
size_t len = fnvlist_size(nvl);
|
||||||
if ((packed = zfs_alloc(hdl, len)) == NULL)
|
packed = zfs_alloc(hdl, len);
|
||||||
return (-1);
|
|
||||||
|
|
||||||
verify(nvlist_pack(nvl, &packed, &len, NV_ENCODE_NATIVE, 0) == 0);
|
verify(nvlist_pack(nvl, &packed, &len, NV_ENCODE_NATIVE, 0) == 0);
|
||||||
|
|
||||||
*outnv = (uint64_t)(uintptr_t)packed;
|
*outnv = (uint64_t)(uintptr_t)packed;
|
||||||
*outlen = len;
|
*outlen = len;
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
zcmd_write_conf_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl)
|
zcmd_write_conf_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl)
|
||||||
{
|
{
|
||||||
return (zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_conf,
|
zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_conf,
|
||||||
&zc->zc_nvlist_conf_size, nvl));
|
&zc->zc_nvlist_conf_size, nvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
zcmd_write_src_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl)
|
zcmd_write_src_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl)
|
||||||
{
|
{
|
||||||
return (zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_src,
|
zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_src,
|
||||||
&zc->zc_nvlist_src_size, nvl));
|
&zc->zc_nvlist_src_size, nvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1863,8 +1852,7 @@ zprop_expand_list_cb(int prop, void *cb)
|
||||||
zprop_list_t *entry;
|
zprop_list_t *entry;
|
||||||
expand_data_t *edp = cb;
|
expand_data_t *edp = cb;
|
||||||
|
|
||||||
if ((entry = zfs_alloc(edp->hdl, sizeof (zprop_list_t))) == NULL)
|
entry = zfs_alloc(edp->hdl, sizeof (zprop_list_t));
|
||||||
return (ZPROP_INVAL);
|
|
||||||
|
|
||||||
entry->pl_prop = prop;
|
entry->pl_prop = prop;
|
||||||
entry->pl_width = zprop_width(prop, &entry->pl_fixed, edp->type);
|
entry->pl_width = zprop_width(prop, &entry->pl_fixed, edp->type);
|
||||||
|
|
|
@ -338,15 +338,13 @@ zpool_nextboot(libzfs_handle_t *hdl, uint64_t pool_guid, uint64_t dev_guid,
|
||||||
{
|
{
|
||||||
zfs_cmd_t zc = {"\0"};
|
zfs_cmd_t zc = {"\0"};
|
||||||
nvlist_t *args;
|
nvlist_t *args;
|
||||||
int error;
|
|
||||||
|
|
||||||
args = fnvlist_alloc();
|
args = fnvlist_alloc();
|
||||||
fnvlist_add_uint64(args, ZPOOL_CONFIG_POOL_GUID, pool_guid);
|
fnvlist_add_uint64(args, ZPOOL_CONFIG_POOL_GUID, pool_guid);
|
||||||
fnvlist_add_uint64(args, ZPOOL_CONFIG_GUID, dev_guid);
|
fnvlist_add_uint64(args, ZPOOL_CONFIG_GUID, dev_guid);
|
||||||
fnvlist_add_string(args, "command", command);
|
fnvlist_add_string(args, "command", command);
|
||||||
error = zcmd_write_src_nvlist(hdl, &zc, args);
|
zcmd_write_src_nvlist(hdl, &zc, args);
|
||||||
if (error == 0)
|
int error = zfs_ioctl(hdl, ZFS_IOC_NEXTBOOT, &zc);
|
||||||
error = zfs_ioctl(hdl, ZFS_IOC_NEXTBOOT, &zc);
|
|
||||||
zcmd_free_nvlists(&zc);
|
zcmd_free_nvlists(&zc);
|
||||||
nvlist_free(args);
|
nvlist_free(args);
|
||||||
return (error);
|
return (error);
|
||||||
|
|
Loading…
Reference in New Issue