This commit is contained in:
Brooks Davis 2024-08-27 15:51:00 +02:00 committed by GitHub
commit fea5af528d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 29 additions and 9 deletions

View File

@ -312,7 +312,9 @@ _SYS_NVPAIR_H int nvpair_value_double(const nvpair_t *, double *);
_SYS_NVPAIR_H nvlist_t *fnvlist_alloc(void);
_SYS_NVPAIR_H void fnvlist_free(nvlist_t *);
_SYS_NVPAIR_H size_t fnvlist_size(nvlist_t *);
_SYS_NVPAIR_H size_t fnvlist_size_xdr(nvlist_t *);
_SYS_NVPAIR_H char *fnvlist_pack(nvlist_t *, size_t *);
_SYS_NVPAIR_H char *fnvlist_pack_xdr(nvlist_t *, size_t *);
_SYS_NVPAIR_H void fnvlist_pack_free(char *, size_t);
_SYS_NVPAIR_H nvlist_t *fnvlist_unpack(char *, size_t);
_SYS_NVPAIR_H nvlist_t *fnvlist_dup(const nvlist_t *);

View File

@ -5287,12 +5287,12 @@ zfs_set_fsacl(zfs_handle_t *zhp, boolean_t un, nvlist_t *nvl)
assert(zhp->zfs_type == ZFS_TYPE_VOLUME ||
zhp->zfs_type == ZFS_TYPE_FILESYSTEM);
err = nvlist_size(nvl, &nvsz, NV_ENCODE_NATIVE);
err = nvlist_size(nvl, &nvsz, NV_ENCODE_XDR);
assert(err == 0);
nvbuf = malloc(nvsz);
err = nvlist_pack(nvl, &nvbuf, &nvsz, NV_ENCODE_NATIVE, 0);
err = nvlist_pack(nvl, &nvbuf, &nvsz, NV_ENCODE_XDR, 0);
assert(err == 0);
zc.zc_nvlist_src_size = nvsz;

View File

@ -1225,11 +1225,12 @@ zcmd_write_nvlist_com(libzfs_handle_t *hdl, uint64_t *outnv, uint64_t *outlen,
nvlist_t *nvl)
{
char *packed;
size_t len;
size_t len = fnvlist_size(nvl);
verify(nvlist_size(nvl, &len, NV_ENCODE_XDR) == 0);
packed = zfs_alloc(hdl, len);
verify(nvlist_pack(nvl, &packed, &len, NV_ENCODE_NATIVE, 0) == 0);
verify(nvlist_pack(nvl, &packed, &len, NV_ENCODE_XDR, 0) == 0);
*outnv = (uint64_t)(uintptr_t)packed;
*outlen = len;

View File

@ -69,6 +69,14 @@ fnvlist_size(nvlist_t *nvl)
return (size);
}
size_t
fnvlist_size_xdr(nvlist_t *nvl)
{
size_t size;
VERIFY0(nvlist_size(nvl, &size, NV_ENCODE_XDR));
return (size);
}
/*
* Returns allocated buffer of size *sizep. Caller must free the buffer with
* fnvlist_pack_free().
@ -82,6 +90,15 @@ fnvlist_pack(nvlist_t *nvl, size_t *sizep)
return (packed);
}
char *
fnvlist_pack_xdr(nvlist_t *nvl, size_t *sizep)
{
char *packed = 0;
VERIFY3U(nvlist_pack(nvl, &packed, sizep, NV_ENCODE_XDR,
KM_SLEEP), ==, 0);
return (packed);
}
void
fnvlist_pack_free(char *pack, size_t size)
{

View File

@ -2757,8 +2757,7 @@ nvlist_xunpack(char *buf, size_t buflen, nvlist_t **nvlp, nv_alloc_t *nva)
if ((err = nvlist_xalloc(&nvl, 0, nva)) != 0)
return (err);
if ((err = nvlist_common(nvl, buf, &buflen, NV_ENCODE_NATIVE,
NVS_OP_DECODE)) != 0)
if ((err = nvlist_common(nvl, buf, &buflen, -1, NVS_OP_DECODE)) != 0)
nvlist_free(nvl);
else
*nvlp = nvl;

View File

@ -2530,7 +2530,7 @@ dmu_send_impl(struct dmu_send_params *dspp)
}
if (!nvlist_empty(nvl)) {
payload = fnvlist_pack(nvl, &payload_len);
payload = fnvlist_pack_xdr(nvl, &payload_len);
drr->drr_payloadlen = payload_len;
}

View File

@ -2421,6 +2421,7 @@ get_receive_resume_token_impl(dsl_dataset_t *ds)
redact_snaps, num_redact_snaps);
kmem_free(redact_snaps, int_size * num_redact_snaps);
}
/* XXX: using XDR seems to cause performace problems */
packed = fnvlist_pack(token_nv, &packed_size);
fnvlist_free(token_nv);
compressed = kmem_alloc(packed_size, KM_SLEEP);

View File

@ -206,7 +206,7 @@ spa_config_write(spa_config_dirent_t *dp, nvlist_t *nvl)
/*
* Pack the configuration into a buffer.
*/
buf = fnvlist_pack(nvl, &buflen);
buf = fnvlist_pack_xdr(nvl, &buflen);
temp = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
/*

View File

@ -330,7 +330,7 @@ spa_history_log_sync(void *arg, dmu_tx_t *tx)
fnvlist_lookup_string(nvl, ZPOOL_HIST_IOCTL));
}
VERIFY3U(nvlist_pack(nvl, &record_packed, &reclen, NV_ENCODE_NATIVE,
VERIFY3U(nvlist_pack(nvl, &record_packed, &reclen, NV_ENCODE_XDR,
KM_SLEEP), ==, 0);
mutex_enter(&spa->spa_history_lock);