nvpair: Always use XDR encoding
Recievers are agnostic to stream format and just call nvpair_unpack or nvpair_xunpack which decode what ever stream type is received. It is easier to make a system with different unpacked sizes work with XDR than with native where streams are unpacked in place. This change provides forward compatability with systems were the size of pointers exceeds 64-bits. For example, a CheriBSD pure-capability kernel targeting Morello should be able to work with a FreeBSD aarch64 zfs or zpool command build with this change applied. Signed-off-by: Brooks Davis <brooks.davis@sri.com>
This commit is contained in:
parent
b0657a59ab
commit
0ae142b640
|
@ -5218,12 +5218,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;
|
||||
|
|
|
@ -1207,7 +1207,7 @@ zcmd_write_nvlist_com(libzfs_handle_t *hdl, uint64_t *outnv, uint64_t *outlen,
|
|||
size_t len = fnvlist_size(nvl);
|
||||
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;
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
* functions, which can return the requested value (rather than filling in
|
||||
* a pointer).
|
||||
*
|
||||
* These functions use NV_UNIQUE_NAME, encoding NV_ENCODE_NATIVE, and allocate
|
||||
* These functions use NV_UNIQUE_NAME, encoding NV_ENCODE_XDR, and allocate
|
||||
* with KM_SLEEP.
|
||||
*
|
||||
* More wrappers should be added as needed -- for example
|
||||
|
@ -65,7 +65,7 @@ size_t
|
|||
fnvlist_size(nvlist_t *nvl)
|
||||
{
|
||||
size_t size;
|
||||
VERIFY0(nvlist_size(nvl, &size, NV_ENCODE_NATIVE));
|
||||
VERIFY0(nvlist_size(nvl, &size, NV_ENCODE_XDR));
|
||||
return (size);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ char *
|
|||
fnvlist_pack(nvlist_t *nvl, size_t *sizep)
|
||||
{
|
||||
char *packed = 0;
|
||||
VERIFY3U(nvlist_pack(nvl, &packed, sizep, NV_ENCODE_NATIVE,
|
||||
VERIFY3U(nvlist_pack(nvl, &packed, sizep, NV_ENCODE_XDR,
|
||||
KM_SLEEP), ==, 0);
|
||||
return (packed);
|
||||
}
|
||||
|
|
|
@ -2753,8 +2753,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;
|
||||
|
|
|
@ -226,7 +226,7 @@ zfs_zevent_post(nvlist_t *nvl, nvlist_t *detector, zevent_cb_t *cb)
|
|||
goto out;
|
||||
}
|
||||
|
||||
error = nvlist_size(nvl, &nvl_size, NV_ENCODE_NATIVE);
|
||||
error = nvlist_size(nvl, &nvl_size, NV_ENCODE_XDR);
|
||||
if (error) {
|
||||
atomic_inc_64(&erpt_kstat_data.erpt_dropped.value.ui64);
|
||||
goto out;
|
||||
|
@ -337,7 +337,7 @@ zfs_zevent_next(zfs_zevent_t *ze, nvlist_t **event, uint64_t *event_size,
|
|||
}
|
||||
}
|
||||
|
||||
VERIFY(nvlist_size(ev->ev_nvl, &size, NV_ENCODE_NATIVE) == 0);
|
||||
VERIFY(nvlist_size(ev->ev_nvl, &size, NV_ENCODE_XDR) == 0);
|
||||
if (size > *event_size) {
|
||||
*event_size = size;
|
||||
error = ENOMEM;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue