1789Sahrens /* 2789Sahrens * CDDL HEADER START 3789Sahrens * 4789Sahrens * The contents of this file are subject to the terms of the 51544Seschrock * Common Development and Distribution License (the "License"). 61544Seschrock * You may not use this file except in compliance with the License. 7789Sahrens * 8789Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9789Sahrens * or http://www.opensolaris.org/os/licensing. 10789Sahrens * See the License for the specific language governing permissions 11789Sahrens * and limitations under the License. 12789Sahrens * 13789Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14789Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15789Sahrens * If applicable, add the following below this CDDL HEADER, with the 16789Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17789Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18789Sahrens * 19789Sahrens * CDDL HEADER END 20789Sahrens */ 21789Sahrens /* 224543Smarks * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23789Sahrens * Use is subject to license terms. 24789Sahrens */ 25789Sahrens 26789Sahrens #pragma ident "%Z%%M% %I% %E% SMI" 27789Sahrens 28789Sahrens #include <sys/dmu.h> 291356Seschrock #include <sys/dmu_objset.h> 30789Sahrens #include <sys/dmu_tx.h> 31789Sahrens #include <sys/dsl_dataset.h> 32789Sahrens #include <sys/dsl_dir.h> 33789Sahrens #include <sys/dsl_prop.h> 342199Sahrens #include <sys/dsl_synctask.h> 35789Sahrens #include <sys/spa.h> 36789Sahrens #include <sys/zio_checksum.h> /* for the default checksum value */ 37789Sahrens #include <sys/zap.h> 38789Sahrens #include <sys/fs/zfs.h> 39789Sahrens 40789Sahrens #include "zfs_prop.h" 41789Sahrens 42789Sahrens static int 43789Sahrens dodefault(const char *propname, int intsz, int numint, void *buf) 44789Sahrens { 45789Sahrens zfs_prop_t prop; 46789Sahrens 475331Samw /* 485331Samw * The setonce properties are read-only, BUT they still 495331Samw * have a default value that can be used as the initial 505331Samw * value. 515331Samw */ 525094Slling if ((prop = zfs_name_to_prop(propname)) == ZPROP_INVAL || 535331Samw (zfs_prop_readonly(prop) && !zfs_prop_setonce(prop))) 54789Sahrens return (ENOENT); 55789Sahrens 564787Sahrens if (zfs_prop_get_type(prop) == PROP_TYPE_STRING) { 57789Sahrens if (intsz != 1) 58789Sahrens return (EOVERFLOW); 595094Slling (void) strncpy(buf, zfs_prop_default_string(prop), 605094Slling numint); 61789Sahrens } else { 62789Sahrens if (intsz != 8 || numint < 1) 63789Sahrens return (EOVERFLOW); 64789Sahrens 65789Sahrens *(uint64_t *)buf = zfs_prop_default_numeric(prop); 66789Sahrens } 67789Sahrens 68789Sahrens return (0); 69789Sahrens } 70789Sahrens 71789Sahrens static int 722082Seschrock dsl_prop_get_impl(dsl_dir_t *dd, const char *propname, 73789Sahrens int intsz, int numint, void *buf, char *setpoint) 74789Sahrens { 752082Seschrock int err = ENOENT; 762676Seschrock zfs_prop_t prop; 77789Sahrens 78789Sahrens if (setpoint) 79789Sahrens setpoint[0] = '\0'; 80789Sahrens 812676Seschrock prop = zfs_name_to_prop(propname); 822676Seschrock 832082Seschrock /* 842082Seschrock * Note: dd may be NULL, therefore we shouldn't dereference it 852082Seschrock * ouside this loop. 862082Seschrock */ 872082Seschrock for (; dd != NULL; dd = dd->dd_parent) { 882082Seschrock objset_t *mos = dd->dd_pool->dp_meta_objset; 892082Seschrock ASSERT(RW_LOCK_HELD(&dd->dd_pool->dp_config_rwlock)); 90789Sahrens err = zap_lookup(mos, dd->dd_phys->dd_props_zapobj, 91789Sahrens propname, intsz, numint, buf); 92789Sahrens if (err != ENOENT) { 93789Sahrens if (setpoint) 94789Sahrens dsl_dir_name(dd, setpoint); 95789Sahrens break; 96789Sahrens } 972676Seschrock 982676Seschrock /* 992676Seschrock * Break out of this loop for non-inheritable properties. 1002676Seschrock */ 1015331Samw if (prop != ZPROP_INVAL && !zfs_prop_inheritable(prop)) 1022676Seschrock break; 103789Sahrens } 104789Sahrens if (err == ENOENT) 105789Sahrens err = dodefault(propname, intsz, numint, buf); 106789Sahrens 107789Sahrens return (err); 108789Sahrens } 109789Sahrens 110789Sahrens /* 111789Sahrens * Register interest in the named property. We'll call the callback 112789Sahrens * once to notify it of the current property value, and again each time 113789Sahrens * the property changes, until this callback is unregistered. 114789Sahrens * 115789Sahrens * Return 0 on success, errno if the prop is not an integer value. 116789Sahrens */ 117789Sahrens int 118789Sahrens dsl_prop_register(dsl_dataset_t *ds, const char *propname, 119789Sahrens dsl_prop_changed_cb_t *callback, void *cbarg) 120789Sahrens { 1212082Seschrock dsl_dir_t *dd = ds->ds_dir; 122789Sahrens uint64_t value; 123789Sahrens dsl_prop_cb_record_t *cbr; 124789Sahrens int err; 1252199Sahrens int need_rwlock; 126789Sahrens 1272199Sahrens need_rwlock = !RW_WRITE_HELD(&dd->dd_pool->dp_config_rwlock); 1282199Sahrens if (need_rwlock) 1292199Sahrens rw_enter(&dd->dd_pool->dp_config_rwlock, RW_READER); 130789Sahrens 1312082Seschrock err = dsl_prop_get_impl(dd, propname, 8, 1, &value, NULL); 132789Sahrens if (err != 0) { 133789Sahrens rw_exit(&dd->dd_pool->dp_config_rwlock); 134789Sahrens return (err); 135789Sahrens } 136789Sahrens 137789Sahrens cbr = kmem_alloc(sizeof (dsl_prop_cb_record_t), KM_SLEEP); 1382082Seschrock cbr->cbr_ds = ds; 139789Sahrens cbr->cbr_propname = kmem_alloc(strlen(propname)+1, KM_SLEEP); 140789Sahrens (void) strcpy((char *)cbr->cbr_propname, propname); 141789Sahrens cbr->cbr_func = callback; 142789Sahrens cbr->cbr_arg = cbarg; 143789Sahrens mutex_enter(&dd->dd_lock); 144789Sahrens list_insert_head(&dd->dd_prop_cbs, cbr); 145789Sahrens mutex_exit(&dd->dd_lock); 146789Sahrens 147789Sahrens cbr->cbr_func(cbr->cbr_arg, value); 148789Sahrens 1491544Seschrock VERIFY(0 == dsl_dir_open_obj(dd->dd_pool, dd->dd_object, 1501544Seschrock NULL, cbr, &dd)); 1512199Sahrens if (need_rwlock) 1522199Sahrens rw_exit(&dd->dd_pool->dp_config_rwlock); 153789Sahrens /* Leave dataset open until this callback is unregistered */ 154789Sahrens return (0); 155789Sahrens } 156789Sahrens 157789Sahrens int 158789Sahrens dsl_prop_get_ds(dsl_dir_t *dd, const char *propname, 159789Sahrens int intsz, int numints, void *buf, char *setpoint) 160789Sahrens { 161789Sahrens int err; 162789Sahrens 163789Sahrens rw_enter(&dd->dd_pool->dp_config_rwlock, RW_READER); 1642082Seschrock err = dsl_prop_get_impl(dd, propname, intsz, numints, buf, setpoint); 165789Sahrens rw_exit(&dd->dd_pool->dp_config_rwlock); 166789Sahrens 167789Sahrens return (err); 168789Sahrens } 169789Sahrens 1704543Smarks /* 1714543Smarks * Get property when config lock is already held. 1724543Smarks */ 1734543Smarks int dsl_prop_get_ds_locked(dsl_dir_t *dd, const char *propname, 1744543Smarks int intsz, int numints, void *buf, char *setpoint) 1754543Smarks { 1764543Smarks ASSERT(RW_LOCK_HELD(&dd->dd_pool->dp_config_rwlock)); 1774543Smarks return (dsl_prop_get_impl(dd, propname, intsz, numints, buf, setpoint)); 1784543Smarks } 1794543Smarks 180789Sahrens int 181789Sahrens dsl_prop_get(const char *ddname, const char *propname, 182789Sahrens int intsz, int numints, void *buf, char *setpoint) 183789Sahrens { 184789Sahrens dsl_dir_t *dd; 185789Sahrens const char *tail; 186789Sahrens int err; 187789Sahrens 1881544Seschrock err = dsl_dir_open(ddname, FTAG, &dd, &tail); 1891544Seschrock if (err) 1901544Seschrock return (err); 191789Sahrens if (tail && tail[0] != '@') { 192789Sahrens dsl_dir_close(dd, FTAG); 193789Sahrens return (ENOENT); 194789Sahrens } 195789Sahrens 196789Sahrens err = dsl_prop_get_ds(dd, propname, intsz, numints, buf, setpoint); 197789Sahrens 198789Sahrens dsl_dir_close(dd, FTAG); 199789Sahrens return (err); 200789Sahrens } 201789Sahrens 202789Sahrens /* 203789Sahrens * Get the current property value. It may have changed by the time this 204789Sahrens * function returns, so it is NOT safe to follow up with 205789Sahrens * dsl_prop_register() and assume that the value has not changed in 206789Sahrens * between. 207789Sahrens * 208789Sahrens * Return 0 on success, ENOENT if ddname is invalid. 209789Sahrens */ 210789Sahrens int 211789Sahrens dsl_prop_get_integer(const char *ddname, const char *propname, 212789Sahrens uint64_t *valuep, char *setpoint) 213789Sahrens { 214789Sahrens return (dsl_prop_get(ddname, propname, 8, 1, valuep, setpoint)); 215789Sahrens } 216789Sahrens 217789Sahrens /* 218789Sahrens * Unregister this callback. Return 0 on success, ENOENT if ddname is 219789Sahrens * invalid, ENOMSG if no matching callback registered. 220789Sahrens */ 221789Sahrens int 222789Sahrens dsl_prop_unregister(dsl_dataset_t *ds, const char *propname, 223789Sahrens dsl_prop_changed_cb_t *callback, void *cbarg) 224789Sahrens { 2252082Seschrock dsl_dir_t *dd = ds->ds_dir; 226789Sahrens dsl_prop_cb_record_t *cbr; 227789Sahrens 228789Sahrens mutex_enter(&dd->dd_lock); 229789Sahrens for (cbr = list_head(&dd->dd_prop_cbs); 230789Sahrens cbr; cbr = list_next(&dd->dd_prop_cbs, cbr)) { 2312082Seschrock if (cbr->cbr_ds == ds && 232789Sahrens cbr->cbr_func == callback && 2332082Seschrock cbr->cbr_arg == cbarg && 2342082Seschrock strcmp(cbr->cbr_propname, propname) == 0) 235789Sahrens break; 236789Sahrens } 237789Sahrens 238789Sahrens if (cbr == NULL) { 239789Sahrens mutex_exit(&dd->dd_lock); 240789Sahrens return (ENOMSG); 241789Sahrens } 242789Sahrens 243789Sahrens list_remove(&dd->dd_prop_cbs, cbr); 244789Sahrens mutex_exit(&dd->dd_lock); 245789Sahrens kmem_free((void*)cbr->cbr_propname, strlen(cbr->cbr_propname)+1); 246789Sahrens kmem_free(cbr, sizeof (dsl_prop_cb_record_t)); 247789Sahrens 248789Sahrens /* Clean up from dsl_prop_register */ 249789Sahrens dsl_dir_close(dd, cbr); 250789Sahrens return (0); 251789Sahrens } 252789Sahrens 2532082Seschrock /* 2542082Seschrock * Return the number of callbacks that are registered for this dataset. 2552082Seschrock */ 2562082Seschrock int 2572082Seschrock dsl_prop_numcb(dsl_dataset_t *ds) 2582082Seschrock { 2592082Seschrock dsl_dir_t *dd = ds->ds_dir; 2602082Seschrock dsl_prop_cb_record_t *cbr; 2612082Seschrock int num = 0; 2622082Seschrock 2632082Seschrock mutex_enter(&dd->dd_lock); 2642082Seschrock for (cbr = list_head(&dd->dd_prop_cbs); 2652082Seschrock cbr; cbr = list_next(&dd->dd_prop_cbs, cbr)) { 2662082Seschrock if (cbr->cbr_ds == ds) 2672082Seschrock num++; 2682082Seschrock } 2692082Seschrock mutex_exit(&dd->dd_lock); 2702082Seschrock 2712082Seschrock return (num); 2722082Seschrock } 2732082Seschrock 274789Sahrens static void 275789Sahrens dsl_prop_changed_notify(dsl_pool_t *dp, uint64_t ddobj, 276789Sahrens const char *propname, uint64_t value, int first) 277789Sahrens { 278789Sahrens dsl_dir_t *dd; 279789Sahrens dsl_prop_cb_record_t *cbr; 280789Sahrens objset_t *mos = dp->dp_meta_objset; 2812199Sahrens zap_cursor_t zc; 2822199Sahrens zap_attribute_t za; 283789Sahrens int err; 284789Sahrens 285789Sahrens ASSERT(RW_WRITE_HELD(&dp->dp_config_rwlock)); 2861544Seschrock err = dsl_dir_open_obj(dp, ddobj, NULL, FTAG, &dd); 2871544Seschrock if (err) 2881544Seschrock return; 289789Sahrens 290789Sahrens if (!first) { 291789Sahrens /* 292789Sahrens * If the prop is set here, then this change is not 293789Sahrens * being inherited here or below; stop the recursion. 294789Sahrens */ 295789Sahrens err = zap_lookup(mos, dd->dd_phys->dd_props_zapobj, propname, 296789Sahrens 8, 1, &value); 297789Sahrens if (err == 0) { 298789Sahrens dsl_dir_close(dd, FTAG); 299789Sahrens return; 300789Sahrens } 301789Sahrens ASSERT3U(err, ==, ENOENT); 302789Sahrens } 303789Sahrens 304789Sahrens mutex_enter(&dd->dd_lock); 305789Sahrens for (cbr = list_head(&dd->dd_prop_cbs); 306789Sahrens cbr; cbr = list_next(&dd->dd_prop_cbs, cbr)) { 307789Sahrens if (strcmp(cbr->cbr_propname, propname) == 0) { 308789Sahrens cbr->cbr_func(cbr->cbr_arg, value); 309789Sahrens } 310789Sahrens } 311789Sahrens mutex_exit(&dd->dd_lock); 312789Sahrens 3132199Sahrens for (zap_cursor_init(&zc, mos, 3142199Sahrens dd->dd_phys->dd_child_dir_zapobj); 3152199Sahrens zap_cursor_retrieve(&zc, &za) == 0; 3162199Sahrens zap_cursor_advance(&zc)) { 3172199Sahrens /* XXX recursion could blow stack; esp. za! */ 3182199Sahrens dsl_prop_changed_notify(dp, za.za_first_integer, 3192199Sahrens propname, value, FALSE); 320789Sahrens } 3212199Sahrens zap_cursor_fini(&zc); 322789Sahrens dsl_dir_close(dd, FTAG); 323789Sahrens } 324789Sahrens 325789Sahrens struct prop_set_arg { 326789Sahrens const char *name; 327789Sahrens int intsz; 328789Sahrens int numints; 329789Sahrens const void *buf; 330789Sahrens }; 331789Sahrens 3322199Sahrens 3332199Sahrens static void 3344543Smarks dsl_prop_set_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) 335789Sahrens { 3362199Sahrens dsl_dir_t *dd = arg1; 3372199Sahrens struct prop_set_arg *psa = arg2; 338789Sahrens objset_t *mos = dd->dd_pool->dp_meta_objset; 339789Sahrens uint64_t zapobj = dd->dd_phys->dd_props_zapobj; 340789Sahrens uint64_t intval; 3412199Sahrens int isint; 3424543Smarks char valbuf[32]; 3434543Smarks char *valstr; 344789Sahrens 345789Sahrens isint = (dodefault(psa->name, 8, 1, &intval) == 0); 346789Sahrens 347789Sahrens if (psa->numints == 0) { 3482199Sahrens int err = zap_remove(mos, zapobj, psa->name, tx); 3492199Sahrens ASSERT(err == 0 || err == ENOENT); 3502199Sahrens if (isint) { 3512199Sahrens VERIFY(0 == dsl_prop_get_impl(dd->dd_parent, 3522199Sahrens psa->name, 8, 1, &intval, NULL)); 353789Sahrens } 354789Sahrens } else { 3552199Sahrens VERIFY(0 == zap_update(mos, zapobj, psa->name, 3562199Sahrens psa->intsz, psa->numints, psa->buf, tx)); 357789Sahrens if (isint) 358789Sahrens intval = *(uint64_t *)psa->buf; 359789Sahrens } 360789Sahrens 3612199Sahrens if (isint) { 362789Sahrens dsl_prop_changed_notify(dd->dd_pool, 363789Sahrens dd->dd_object, psa->name, intval, TRUE); 364789Sahrens } 3654543Smarks if (isint) { 3664543Smarks (void) snprintf(valbuf, sizeof (valbuf), 3674543Smarks "%lld", (longlong_t)intval); 3684543Smarks valstr = valbuf; 3694543Smarks } else { 3704543Smarks valstr = (char *)psa->buf; 3714543Smarks } 3724543Smarks spa_history_internal_log((psa->numints == 0) ? LOG_DS_INHERIT : 3734543Smarks LOG_DS_PROPSET, dd->dd_pool->dp_spa, tx, cr, 3744543Smarks "%s=%s dataset = %llu", psa->name, valstr, 3754543Smarks dd->dd_phys->dd_head_dataset_obj); 376789Sahrens } 377789Sahrens 378*5378Sck153898 void 379*5378Sck153898 dsl_prop_set_uint64_sync(dsl_dir_t *dd, const char *name, uint64_t val, 380*5378Sck153898 cred_t *cr, dmu_tx_t *tx) 381*5378Sck153898 { 382*5378Sck153898 objset_t *mos = dd->dd_pool->dp_meta_objset; 383*5378Sck153898 uint64_t zapobj = dd->dd_phys->dd_props_zapobj; 384*5378Sck153898 385*5378Sck153898 ASSERT(dmu_tx_is_syncing(tx)); 386*5378Sck153898 387*5378Sck153898 VERIFY(0 == zap_update(mos, zapobj, name, sizeof (val), 1, &val, tx)); 388*5378Sck153898 389*5378Sck153898 dsl_prop_changed_notify(dd->dd_pool, dd->dd_object, name, val, TRUE); 390*5378Sck153898 391*5378Sck153898 spa_history_internal_log(LOG_DS_PROPSET, dd->dd_pool->dp_spa, tx, cr, 392*5378Sck153898 "%s=%llu dataset = %llu", name, (u_longlong_t)val, 393*5378Sck153898 dd->dd_phys->dd_head_dataset_obj); 394*5378Sck153898 } 395*5378Sck153898 396789Sahrens int 3972885Sahrens dsl_prop_set_dd(dsl_dir_t *dd, const char *propname, 3982885Sahrens int intsz, int numints, const void *buf) 3992885Sahrens { 4002885Sahrens struct prop_set_arg psa; 4012885Sahrens 4022885Sahrens psa.name = propname; 4032885Sahrens psa.intsz = intsz; 4042885Sahrens psa.numints = numints; 4052885Sahrens psa.buf = buf; 4062885Sahrens 4072885Sahrens return (dsl_sync_task_do(dd->dd_pool, 4082885Sahrens NULL, dsl_prop_set_sync, dd, &psa, 2)); 4092885Sahrens } 4102885Sahrens 4112885Sahrens int 412789Sahrens dsl_prop_set(const char *ddname, const char *propname, 413789Sahrens int intsz, int numints, const void *buf) 414789Sahrens { 415789Sahrens dsl_dir_t *dd; 416789Sahrens int err; 417789Sahrens 4182641Sahrens /* 4192641Sahrens * We must do these checks before we get to the syncfunc, since 4202641Sahrens * it can't fail. 4212641Sahrens */ 4222641Sahrens if (strlen(propname) >= ZAP_MAXNAMELEN) 4232641Sahrens return (ENAMETOOLONG); 4242641Sahrens if (intsz * numints >= ZAP_MAXVALUELEN) 4252641Sahrens return (E2BIG); 4262641Sahrens 4271544Seschrock err = dsl_dir_open(ddname, FTAG, &dd, NULL); 4281544Seschrock if (err) 4291544Seschrock return (err); 4302885Sahrens err = dsl_prop_set_dd(dd, propname, intsz, numints, buf); 431789Sahrens dsl_dir_close(dd, FTAG); 432789Sahrens return (err); 433789Sahrens } 4341356Seschrock 4351356Seschrock /* 4361356Seschrock * Iterate over all properties for this dataset and return them in an nvlist. 4371356Seschrock */ 4381356Seschrock int 4391356Seschrock dsl_prop_get_all(objset_t *os, nvlist_t **nvp) 4401356Seschrock { 4411356Seschrock dsl_dataset_t *ds = os->os->os_dsl_dataset; 4422082Seschrock dsl_dir_t *dd = ds->ds_dir; 4435331Samw boolean_t snapshot; 4441356Seschrock int err = 0; 4451356Seschrock dsl_pool_t *dp; 4461356Seschrock objset_t *mos; 4471356Seschrock 4485331Samw snapshot = dsl_dataset_is_snapshot(ds); 4491356Seschrock 4501356Seschrock VERIFY(nvlist_alloc(nvp, NV_UNIQUE_NAME, KM_SLEEP) == 0); 4511356Seschrock 4521356Seschrock dp = dd->dd_pool; 4531356Seschrock mos = dp->dp_meta_objset; 4541356Seschrock 4551356Seschrock rw_enter(&dp->dp_config_rwlock, RW_READER); 4562082Seschrock for (; dd != NULL; dd = dd->dd_parent) { 4572885Sahrens char setpoint[MAXNAMELEN]; 4582885Sahrens zap_cursor_t zc; 4592885Sahrens zap_attribute_t za; 4602885Sahrens 4611356Seschrock dsl_dir_name(dd, setpoint); 4621356Seschrock 4631356Seschrock for (zap_cursor_init(&zc, mos, dd->dd_phys->dd_props_zapobj); 4641356Seschrock (err = zap_cursor_retrieve(&zc, &za)) == 0; 4651356Seschrock zap_cursor_advance(&zc)) { 4662885Sahrens nvlist_t *propval; 4672885Sahrens zfs_prop_t prop; 4682676Seschrock /* 4692676Seschrock * Skip non-inheritable properties. 4702676Seschrock */ 4712676Seschrock if ((prop = zfs_name_to_prop(za.za_name)) != 4725094Slling ZPROP_INVAL && !zfs_prop_inheritable(prop) && 4732676Seschrock dd != ds->ds_dir) 4741356Seschrock continue; 4751356Seschrock 4765331Samw if (snapshot && 4775331Samw !zfs_prop_valid_for_type(prop, ZFS_TYPE_SNAPSHOT)) 4785331Samw continue; 4795331Samw 4802676Seschrock if (nvlist_lookup_nvlist(*nvp, za.za_name, 4812676Seschrock &propval) == 0) 4822676Seschrock continue; 4832676Seschrock 4842676Seschrock VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, 4851356Seschrock KM_SLEEP) == 0); 4861356Seschrock if (za.za_integer_length == 1) { 4871356Seschrock /* 4881356Seschrock * String property 4891356Seschrock */ 4902885Sahrens char *tmp = kmem_alloc(za.za_num_integers, 4912885Sahrens KM_SLEEP); 4921356Seschrock err = zap_lookup(mos, 4931356Seschrock dd->dd_phys->dd_props_zapobj, 4941356Seschrock za.za_name, 1, za.za_num_integers, 4951356Seschrock tmp); 4961356Seschrock if (err != 0) { 4971356Seschrock kmem_free(tmp, za.za_num_integers); 4981356Seschrock break; 4991356Seschrock } 5005094Slling VERIFY(nvlist_add_string(propval, ZPROP_VALUE, 5015094Slling tmp) == 0); 5021356Seschrock kmem_free(tmp, za.za_num_integers); 5031356Seschrock } else { 5041356Seschrock /* 5051356Seschrock * Integer property 5061356Seschrock */ 5071356Seschrock ASSERT(za.za_integer_length == 8); 5085094Slling (void) nvlist_add_uint64(propval, ZPROP_VALUE, 5095094Slling za.za_first_integer); 5101356Seschrock } 5111356Seschrock 5125094Slling VERIFY(nvlist_add_string(propval, ZPROP_SOURCE, 5135094Slling setpoint) == 0); 5141356Seschrock VERIFY(nvlist_add_nvlist(*nvp, za.za_name, 5152676Seschrock propval) == 0); 5162676Seschrock nvlist_free(propval); 5171356Seschrock } 5181356Seschrock zap_cursor_fini(&zc); 5191356Seschrock 5202082Seschrock if (err != ENOENT) 5211356Seschrock break; 5222082Seschrock err = 0; 5231356Seschrock } 5241356Seschrock rw_exit(&dp->dp_config_rwlock); 5251356Seschrock 5261356Seschrock return (err); 5271356Seschrock } 5282885Sahrens 5292885Sahrens void 5302885Sahrens dsl_prop_nvlist_add_uint64(nvlist_t *nv, zfs_prop_t prop, uint64_t value) 5312885Sahrens { 5322885Sahrens nvlist_t *propval; 5332885Sahrens 5342885Sahrens VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, KM_SLEEP) == 0); 5355094Slling VERIFY(nvlist_add_uint64(propval, ZPROP_VALUE, value) == 0); 5362885Sahrens VERIFY(nvlist_add_nvlist(nv, zfs_prop_to_name(prop), propval) == 0); 5372885Sahrens nvlist_free(propval); 5382885Sahrens } 5392885Sahrens 5402885Sahrens void 5412885Sahrens dsl_prop_nvlist_add_string(nvlist_t *nv, zfs_prop_t prop, const char *value) 5422885Sahrens { 5432885Sahrens nvlist_t *propval; 5442885Sahrens 5452885Sahrens VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, KM_SLEEP) == 0); 5465094Slling VERIFY(nvlist_add_string(propval, ZPROP_VALUE, value) == 0); 5472885Sahrens VERIFY(nvlist_add_nvlist(nv, zfs_prop_to_name(prop), propval) == 0); 5482885Sahrens nvlist_free(propval); 5492885Sahrens } 550