Merge commit 'refs/top-bases/linux-zfs-branch' into linux-zfs-branch

This commit is contained in:
Brian Behlendorf 2008-12-05 12:42:27 -08:00
commit a60b52ed41
7 changed files with 44 additions and 6 deletions

View File

@ -100,7 +100,9 @@ typedef struct nvlist {
/* nvlist pack encoding */ /* nvlist pack encoding */
#define NV_ENCODE_NATIVE 0 #define NV_ENCODE_NATIVE 0
#if defined(HAVE_XDR)
#define NV_ENCODE_XDR 1 #define NV_ENCODE_XDR 1
#endif
/* nvlist persistent unique name flags, stored in nvl_nvflags */ /* nvlist persistent unique name flags, stored in nvl_nvflags */
#define NV_UNIQUE_NAME 0x1 #define NV_UNIQUE_NAME 0x1

View File

@ -33,7 +33,9 @@
#include <sys/nvpair.h> #include <sys/nvpair.h>
#include <sys/nvpair_impl.h> #include <sys/nvpair_impl.h>
#include <rpc/types.h> #include <rpc/types.h>
#ifdef HAVE_XDR
#include <rpc/xdr.h> #include <rpc/xdr.h>
#endif /* HAVE_XDR */
#if defined(_KERNEL) && !defined(_BOOT) #if defined(_KERNEL) && !defined(_BOOT)
#include <sys/varargs.h> #include <sys/varargs.h>
@ -2191,7 +2193,9 @@ nvs_embedded_nvl_array(nvstream_t *nvs, nvpair_t *nvp, size_t *size)
} }
static int nvs_native(nvstream_t *, nvlist_t *, char *, size_t *); static int nvs_native(nvstream_t *, nvlist_t *, char *, size_t *);
#if defined(HAVE_XDR)
static int nvs_xdr(nvstream_t *, nvlist_t *, char *, size_t *); static int nvs_xdr(nvstream_t *, nvlist_t *, char *, size_t *);
#endif /* HAVE_XDR */
/* /*
* Common routine for nvlist operations: * Common routine for nvlist operations:
@ -2268,9 +2272,11 @@ nvlist_common(nvlist_t *nvl, char *buf, size_t *buflen, int encoding,
return (ENOTSUP); return (ENOTSUP);
err = nvs_native(&nvs, nvl, buf, buflen); err = nvs_native(&nvs, nvl, buf, buflen);
break; break;
#if defined(HAVE_XDR)
case NV_ENCODE_XDR: case NV_ENCODE_XDR:
err = nvs_xdr(&nvs, nvl, buf, buflen); err = nvs_xdr(&nvs, nvl, buf, buflen);
break; break;
#endif /* HAVE_XDR */
default: default:
err = ENOTSUP; err = ENOTSUP;
break; break;
@ -2758,6 +2764,7 @@ nvs_native(nvstream_t *nvs, nvlist_t *nvl, char *buf, size_t *buflen)
return (err); return (err);
} }
#if defined(HAVE_XDR)
/* /*
* XDR encoding functions * XDR encoding functions
* *
@ -3244,6 +3251,7 @@ nvs_xdr(nvstream_t *nvs, nvlist_t *nvl, char *buf, size_t *buflen)
return (err); return (err);
} }
#endif /* HAVE_XDR */
#if defined(_KERNEL) && defined(HAVE_SPL) #if defined(_KERNEL) && defined(HAVE_SPL)
static int __init nvpair_init(void) static int __init nvpair_init(void)

View File

@ -729,8 +729,13 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
if (err) if (err)
return (err); return (err);
VERIFY(0 == nvlist_add_nvlist(hdrnv, "fss", fss)); VERIFY(0 == nvlist_add_nvlist(hdrnv, "fss", fss));
#if defined(HAVE_XDR)
err = nvlist_pack(hdrnv, &packbuf, &buflen, err = nvlist_pack(hdrnv, &packbuf, &buflen,
NV_ENCODE_XDR, 0); NV_ENCODE_XDR, 0);
#else
err = nvlist_pack(hdrnv, &packbuf, &buflen,
NV_ENCODE_NATIVE, 0);
#endif /* HAVE_XDR */
nvlist_free(hdrnv); nvlist_free(hdrnv);
if (err) { if (err) {
fsavl_destroy(fsavl); fsavl_destroy(fsavl);

View File

@ -3669,9 +3669,14 @@ spa_sync_nvlist(spa_t *spa, uint64_t obj, nvlist_t *nv, dmu_tx_t *tx)
char *packed = NULL; char *packed = NULL;
size_t bufsize; size_t bufsize;
size_t nvsize = 0; size_t nvsize = 0;
int nv_encode = NV_ENCODE_NATIVE;
dmu_buf_t *db; dmu_buf_t *db;
VERIFY(nvlist_size(nv, &nvsize, NV_ENCODE_XDR) == 0); #if defined(HAVE_XDR)
nv_encode = NV_ENCODE_XDR;
#endif
VERIFY(nvlist_size(nv, &nvsize, nv_encode) == 0);
/* /*
* Write full (SPA_CONFIG_BLOCKSIZE) blocks of configuration * Write full (SPA_CONFIG_BLOCKSIZE) blocks of configuration
@ -3681,8 +3686,7 @@ spa_sync_nvlist(spa_t *spa, uint64_t obj, nvlist_t *nv, dmu_tx_t *tx)
bufsize = P2ROUNDUP(nvsize, SPA_CONFIG_BLOCKSIZE); bufsize = P2ROUNDUP(nvsize, SPA_CONFIG_BLOCKSIZE);
packed = kmem_alloc(bufsize, KM_SLEEP); packed = kmem_alloc(bufsize, KM_SLEEP);
VERIFY(nvlist_pack(nv, &packed, &nvsize, NV_ENCODE_XDR, VERIFY(nvlist_pack(nv, &packed, &nvsize, nv_encode, KM_SLEEP) == 0);
KM_SLEEP) == 0);
bzero(packed + nvsize, bufsize - nvsize); bzero(packed + nvsize, bufsize - nvsize);
dmu_write(spa->spa_meta_objset, obj, 0, bufsize, packed, tx); dmu_write(spa->spa_meta_objset, obj, 0, bufsize, packed, tx);

View File

@ -152,6 +152,7 @@ spa_config_write(spa_config_dirent_t *dp, nvlist_t *nvl)
char *buf; char *buf;
vnode_t *vp; vnode_t *vp;
int oflags = FWRITE | FTRUNC | FCREAT | FOFFMAX; int oflags = FWRITE | FTRUNC | FCREAT | FOFFMAX;
int nv_encode = NV_ENCODE_NATIVE;
char *temp; char *temp;
/* /*
@ -165,13 +166,15 @@ spa_config_write(spa_config_dirent_t *dp, nvlist_t *nvl)
/* /*
* Pack the configuration into a buffer. * Pack the configuration into a buffer.
*/ */
VERIFY(nvlist_size(nvl, &buflen, NV_ENCODE_XDR) == 0); #if defined(HAVE_XDR)
nv_encode = NV_ENCODE_XDR;
#endif
VERIFY(nvlist_size(nvl, &buflen, nv_encode) == 0);
buf = kmem_alloc(buflen, KM_SLEEP); buf = kmem_alloc(buflen, KM_SLEEP);
temp = kmem_zalloc(MAXPATHLEN, KM_SLEEP); temp = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
VERIFY(nvlist_pack(nvl, &buf, &buflen, NV_ENCODE_XDR, VERIFY(nvlist_pack(nvl, &buf, &buflen, nv_encode, KM_SLEEP) == 0);
KM_SLEEP) == 0);
/* /*
* Write the configuration to disk. We need to do the traditional * Write the configuration to disk. We need to do the traditional

View File

@ -258,11 +258,19 @@ spa_history_log_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx)
history_str) == 0); history_str) == 0);
} }
#if defined(HAVE_XDR)
VERIFY(nvlist_size(nvrecord, &reclen, NV_ENCODE_XDR) == 0); VERIFY(nvlist_size(nvrecord, &reclen, NV_ENCODE_XDR) == 0);
record_packed = kmem_alloc(reclen, KM_SLEEP); record_packed = kmem_alloc(reclen, KM_SLEEP);
VERIFY(nvlist_pack(nvrecord, &record_packed, &reclen, VERIFY(nvlist_pack(nvrecord, &record_packed, &reclen,
NV_ENCODE_XDR, KM_SLEEP) == 0); NV_ENCODE_XDR, KM_SLEEP) == 0);
#else
VERIFY(nvlist_size(nvrecord, &reclen, NV_ENCODE_NATIVE) == 0);
record_packed = kmem_alloc(reclen, KM_SLEEP);
VERIFY(nvlist_pack(nvrecord, &record_packed, &reclen,
NV_ENCODE_NATIVE, KM_SLEEP) == 0);
#endif
mutex_enter(&spa->spa_history_lock); mutex_enter(&spa->spa_history_lock);
if (hap->ha_log_type == LOG_CMD_POOL_CREATE) if (hap->ha_log_type == LOG_CMD_POOL_CREATE)

View File

@ -626,7 +626,11 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
buf = vp->vp_nvlist; buf = vp->vp_nvlist;
buflen = sizeof (vp->vp_nvlist); buflen = sizeof (vp->vp_nvlist);
#ifdef HAVE_XDR
error = nvlist_pack(label, &buf, &buflen, NV_ENCODE_XDR, KM_SLEEP); error = nvlist_pack(label, &buf, &buflen, NV_ENCODE_XDR, KM_SLEEP);
#else
error = nvlist_pack(label, &buf, &buflen, NV_ENCODE_NATIVE, KM_SLEEP);
#endif
if (error != 0) { if (error != 0) {
nvlist_free(label); nvlist_free(label);
zio_buf_free(vp, sizeof (vdev_phys_t)); zio_buf_free(vp, sizeof (vdev_phys_t));
@ -930,7 +934,11 @@ vdev_label_sync(zio_t *zio, vdev_t *vd, int l, uint64_t txg, int flags)
buf = vp->vp_nvlist; buf = vp->vp_nvlist;
buflen = sizeof (vp->vp_nvlist); buflen = sizeof (vp->vp_nvlist);
#ifdef HAVE_XDR
if (nvlist_pack(label, &buf, &buflen, NV_ENCODE_XDR, KM_SLEEP) == 0) { if (nvlist_pack(label, &buf, &buflen, NV_ENCODE_XDR, KM_SLEEP) == 0) {
#else
if (nvlist_pack(label, &buf, &buflen, NV_ENCODE_NATIVE, KM_SLEEP) == 0) {
#endif
for (; l < VDEV_LABELS; l += 2) { for (; l < VDEV_LABELS; l += 2) {
vdev_label_write(zio, vd, l, vp, vdev_label_write(zio, vd, l, vp,
offsetof(vdev_label_t, vl_vdev_phys), offsetof(vdev_label_t, vl_vdev_phys),