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) { 133*5569Sck153898 if (need_rwlock) 134*5569Sck153898 rw_exit(&dd->dd_pool->dp_config_rwlock); 135789Sahrens return (err); 136789Sahrens } 137789Sahrens 138789Sahrens cbr = kmem_alloc(sizeof (dsl_prop_cb_record_t), KM_SLEEP); 1392082Seschrock cbr->cbr_ds = ds; 140789Sahrens cbr->cbr_propname = kmem_alloc(strlen(propname)+1, KM_SLEEP); 141789Sahrens (void) strcpy((char *)cbr->cbr_propname, propname); 142789Sahrens cbr->cbr_func = callback; 143789Sahrens cbr->cbr_arg = cbarg; 144789Sahrens mutex_enter(&dd->dd_lock); 145789Sahrens list_insert_head(&dd->dd_prop_cbs, cbr); 146789Sahrens mutex_exit(&dd->dd_lock); 147789Sahrens 148789Sahrens cbr->cbr_func(cbr->cbr_arg, value); 149789Sahrens 1501544Seschrock VERIFY(0 == dsl_dir_open_obj(dd->dd_pool, dd->dd_object, 1511544Seschrock NULL, cbr, &dd)); 1522199Sahrens if (need_rwlock) 1532199Sahrens rw_exit(&dd->dd_pool->dp_config_rwlock); 154789Sahrens /* Leave dataset open until this callback is unregistered */ 155789Sahrens return (0); 156789Sahrens } 157789Sahrens 158789Sahrens int 159789Sahrens dsl_prop_get_ds(dsl_dir_t *dd, const char *propname, 160789Sahrens int intsz, int numints, void *buf, char *setpoint) 161789Sahrens { 162789Sahrens int err; 163789Sahrens 164789Sahrens rw_enter(&dd->dd_pool->dp_config_rwlock, RW_READER); 1652082Seschrock err = dsl_prop_get_impl(dd, propname, intsz, numints, buf, setpoint); 166789Sahrens rw_exit(&dd->dd_pool->dp_config_rwlock); 167789Sahrens 168789Sahrens return (err); 169789Sahrens } 170789Sahrens 1714543Smarks /* 1724543Smarks * Get property when config lock is already held. 1734543Smarks */ 1744543Smarks int dsl_prop_get_ds_locked(dsl_dir_t *dd, const char *propname, 1754543Smarks int intsz, int numints, void *buf, char *setpoint) 1764543Smarks { 1774543Smarks ASSERT(RW_LOCK_HELD(&dd->dd_pool->dp_config_rwlock)); 1784543Smarks return (dsl_prop_get_impl(dd, propname, intsz, numints, buf, setpoint)); 1794543Smarks } 1804543Smarks 181789Sahrens int 182789Sahrens dsl_prop_get(const char *ddname, const char *propname, 183789Sahrens int intsz, int numints, void *buf, char *setpoint) 184789Sahrens { 185789Sahrens dsl_dir_t *dd; 186789Sahrens const char *tail; 187789Sahrens int err; 188789Sahrens 1891544Seschrock err = dsl_dir_open(ddname, FTAG, &dd, &tail); 1901544Seschrock if (err) 1911544Seschrock return (err); 192789Sahrens if (tail && tail[0] != '@') { 193789Sahrens dsl_dir_close(dd, FTAG); 194789Sahrens return (ENOENT); 195789Sahrens } 196789Sahrens 197789Sahrens err = dsl_prop_get_ds(dd, propname, intsz, numints, buf, setpoint); 198789Sahrens 199789Sahrens dsl_dir_close(dd, FTAG); 200789Sahrens return (err); 201789Sahrens } 202789Sahrens 203789Sahrens /* 204789Sahrens * Get the current property value. It may have changed by the time this 205789Sahrens * function returns, so it is NOT safe to follow up with 206789Sahrens * dsl_prop_register() and assume that the value has not changed in 207789Sahrens * between. 208789Sahrens * 209789Sahrens * Return 0 on success, ENOENT if ddname is invalid. 210789Sahrens */ 211789Sahrens int 212789Sahrens dsl_prop_get_integer(const char *ddname, const char *propname, 213789Sahrens uint64_t *valuep, char *setpoint) 214789Sahrens { 215789Sahrens return (dsl_prop_get(ddname, propname, 8, 1, valuep, setpoint)); 216789Sahrens } 217789Sahrens 218789Sahrens /* 219789Sahrens * Unregister this callback. Return 0 on success, ENOENT if ddname is 220789Sahrens * invalid, ENOMSG if no matching callback registered. 221789Sahrens */ 222789Sahrens int 223789Sahrens dsl_prop_unregister(dsl_dataset_t *ds, const char *propname, 224789Sahrens dsl_prop_changed_cb_t *callback, void *cbarg) 225789Sahrens { 2262082Seschrock dsl_dir_t *dd = ds->ds_dir; 227789Sahrens dsl_prop_cb_record_t *cbr; 228789Sahrens 229789Sahrens mutex_enter(&dd->dd_lock); 230789Sahrens for (cbr = list_head(&dd->dd_prop_cbs); 231789Sahrens cbr; cbr = list_next(&dd->dd_prop_cbs, cbr)) { 2322082Seschrock if (cbr->cbr_ds == ds && 233789Sahrens cbr->cbr_func == callback && 2342082Seschrock cbr->cbr_arg == cbarg && 2352082Seschrock strcmp(cbr->cbr_propname, propname) == 0) 236789Sahrens break; 237789Sahrens } 238789Sahrens 239789Sahrens if (cbr == NULL) { 240789Sahrens mutex_exit(&dd->dd_lock); 241789Sahrens return (ENOMSG); 242789Sahrens } 243789Sahrens 244789Sahrens list_remove(&dd->dd_prop_cbs, cbr); 245789Sahrens mutex_exit(&dd->dd_lock); 246789Sahrens kmem_free((void*)cbr->cbr_propname, strlen(cbr->cbr_propname)+1); 247789Sahrens kmem_free(cbr, sizeof (dsl_prop_cb_record_t)); 248789Sahrens 249789Sahrens /* Clean up from dsl_prop_register */ 250789Sahrens dsl_dir_close(dd, cbr); 251789Sahrens return (0); 252789Sahrens } 253789Sahrens 2542082Seschrock /* 2552082Seschrock * Return the number of callbacks that are registered for this dataset. 2562082Seschrock */ 2572082Seschrock int 2582082Seschrock dsl_prop_numcb(dsl_dataset_t *ds) 2592082Seschrock { 2602082Seschrock dsl_dir_t *dd = ds->ds_dir; 2612082Seschrock dsl_prop_cb_record_t *cbr; 2622082Seschrock int num = 0; 2632082Seschrock 2642082Seschrock mutex_enter(&dd->dd_lock); 2652082Seschrock for (cbr = list_head(&dd->dd_prop_cbs); 2662082Seschrock cbr; cbr = list_next(&dd->dd_prop_cbs, cbr)) { 2672082Seschrock if (cbr->cbr_ds == ds) 2682082Seschrock num++; 2692082Seschrock } 2702082Seschrock mutex_exit(&dd->dd_lock); 2712082Seschrock 2722082Seschrock return (num); 2732082Seschrock } 2742082Seschrock 275789Sahrens static void 276789Sahrens dsl_prop_changed_notify(dsl_pool_t *dp, uint64_t ddobj, 277789Sahrens const char *propname, uint64_t value, int first) 278789Sahrens { 279789Sahrens dsl_dir_t *dd; 280789Sahrens dsl_prop_cb_record_t *cbr; 281789Sahrens objset_t *mos = dp->dp_meta_objset; 2822199Sahrens zap_cursor_t zc; 2832199Sahrens zap_attribute_t za; 284789Sahrens int err; 285789Sahrens 286789Sahrens ASSERT(RW_WRITE_HELD(&dp->dp_config_rwlock)); 2871544Seschrock err = dsl_dir_open_obj(dp, ddobj, NULL, FTAG, &dd); 2881544Seschrock if (err) 2891544Seschrock return; 290789Sahrens 291789Sahrens if (!first) { 292789Sahrens /* 293789Sahrens * If the prop is set here, then this change is not 294789Sahrens * being inherited here or below; stop the recursion. 295789Sahrens */ 296789Sahrens err = zap_lookup(mos, dd->dd_phys->dd_props_zapobj, propname, 297789Sahrens 8, 1, &value); 298789Sahrens if (err == 0) { 299789Sahrens dsl_dir_close(dd, FTAG); 300789Sahrens return; 301789Sahrens } 302789Sahrens ASSERT3U(err, ==, ENOENT); 303789Sahrens } 304789Sahrens 305789Sahrens mutex_enter(&dd->dd_lock); 306789Sahrens for (cbr = list_head(&dd->dd_prop_cbs); 307789Sahrens cbr; cbr = list_next(&dd->dd_prop_cbs, cbr)) { 308789Sahrens if (strcmp(cbr->cbr_propname, propname) == 0) { 309789Sahrens cbr->cbr_func(cbr->cbr_arg, value); 310789Sahrens } 311789Sahrens } 312789Sahrens mutex_exit(&dd->dd_lock); 313789Sahrens 3142199Sahrens for (zap_cursor_init(&zc, mos, 3152199Sahrens dd->dd_phys->dd_child_dir_zapobj); 3162199Sahrens zap_cursor_retrieve(&zc, &za) == 0; 3172199Sahrens zap_cursor_advance(&zc)) { 3182199Sahrens /* XXX recursion could blow stack; esp. za! */ 3192199Sahrens dsl_prop_changed_notify(dp, za.za_first_integer, 3202199Sahrens propname, value, FALSE); 321789Sahrens } 3222199Sahrens zap_cursor_fini(&zc); 323789Sahrens dsl_dir_close(dd, FTAG); 324789Sahrens } 325789Sahrens 326789Sahrens struct prop_set_arg { 327789Sahrens const char *name; 328789Sahrens int intsz; 329789Sahrens int numints; 330789Sahrens const void *buf; 331789Sahrens }; 332789Sahrens 3332199Sahrens 3342199Sahrens static void 3354543Smarks dsl_prop_set_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) 336789Sahrens { 3372199Sahrens dsl_dir_t *dd = arg1; 3382199Sahrens struct prop_set_arg *psa = arg2; 339789Sahrens objset_t *mos = dd->dd_pool->dp_meta_objset; 340789Sahrens uint64_t zapobj = dd->dd_phys->dd_props_zapobj; 341789Sahrens uint64_t intval; 3422199Sahrens int isint; 3434543Smarks char valbuf[32]; 3444543Smarks char *valstr; 345789Sahrens 346789Sahrens isint = (dodefault(psa->name, 8, 1, &intval) == 0); 347789Sahrens 348789Sahrens if (psa->numints == 0) { 3492199Sahrens int err = zap_remove(mos, zapobj, psa->name, tx); 3502199Sahrens ASSERT(err == 0 || err == ENOENT); 3512199Sahrens if (isint) { 3522199Sahrens VERIFY(0 == dsl_prop_get_impl(dd->dd_parent, 3532199Sahrens psa->name, 8, 1, &intval, NULL)); 354789Sahrens } 355789Sahrens } else { 3562199Sahrens VERIFY(0 == zap_update(mos, zapobj, psa->name, 3572199Sahrens psa->intsz, psa->numints, psa->buf, tx)); 358789Sahrens if (isint) 359789Sahrens intval = *(uint64_t *)psa->buf; 360789Sahrens } 361789Sahrens 3622199Sahrens if (isint) { 363789Sahrens dsl_prop_changed_notify(dd->dd_pool, 364789Sahrens dd->dd_object, psa->name, intval, TRUE); 365789Sahrens } 3664543Smarks if (isint) { 3674543Smarks (void) snprintf(valbuf, sizeof (valbuf), 3684543Smarks "%lld", (longlong_t)intval); 3694543Smarks valstr = valbuf; 3704543Smarks } else { 3714543Smarks valstr = (char *)psa->buf; 3724543Smarks } 3734543Smarks spa_history_internal_log((psa->numints == 0) ? LOG_DS_INHERIT : 3744543Smarks LOG_DS_PROPSET, dd->dd_pool->dp_spa, tx, cr, 3754543Smarks "%s=%s dataset = %llu", psa->name, valstr, 3764543Smarks dd->dd_phys->dd_head_dataset_obj); 377789Sahrens } 378789Sahrens 3795378Sck153898 void 3805378Sck153898 dsl_prop_set_uint64_sync(dsl_dir_t *dd, const char *name, uint64_t val, 3815378Sck153898 cred_t *cr, dmu_tx_t *tx) 3825378Sck153898 { 3835378Sck153898 objset_t *mos = dd->dd_pool->dp_meta_objset; 3845378Sck153898 uint64_t zapobj = dd->dd_phys->dd_props_zapobj; 3855378Sck153898 3865378Sck153898 ASSERT(dmu_tx_is_syncing(tx)); 3875378Sck153898 3885378Sck153898 VERIFY(0 == zap_update(mos, zapobj, name, sizeof (val), 1, &val, tx)); 3895378Sck153898 3905378Sck153898 dsl_prop_changed_notify(dd->dd_pool, dd->dd_object, name, val, TRUE); 3915378Sck153898 3925378Sck153898 spa_history_internal_log(LOG_DS_PROPSET, dd->dd_pool->dp_spa, tx, cr, 3935378Sck153898 "%s=%llu dataset = %llu", name, (u_longlong_t)val, 3945378Sck153898 dd->dd_phys->dd_head_dataset_obj); 3955378Sck153898 } 3965378Sck153898 397789Sahrens int 3982885Sahrens dsl_prop_set_dd(dsl_dir_t *dd, const char *propname, 3992885Sahrens int intsz, int numints, const void *buf) 4002885Sahrens { 4012885Sahrens struct prop_set_arg psa; 4022885Sahrens 4032885Sahrens psa.name = propname; 4042885Sahrens psa.intsz = intsz; 4052885Sahrens psa.numints = numints; 4062885Sahrens psa.buf = buf; 4072885Sahrens 4082885Sahrens return (dsl_sync_task_do(dd->dd_pool, 4092885Sahrens NULL, dsl_prop_set_sync, dd, &psa, 2)); 4102885Sahrens } 4112885Sahrens 4122885Sahrens int 413789Sahrens dsl_prop_set(const char *ddname, const char *propname, 414789Sahrens int intsz, int numints, const void *buf) 415789Sahrens { 416789Sahrens dsl_dir_t *dd; 417789Sahrens int err; 418789Sahrens 4192641Sahrens /* 4202641Sahrens * We must do these checks before we get to the syncfunc, since 4212641Sahrens * it can't fail. 4222641Sahrens */ 4232641Sahrens if (strlen(propname) >= ZAP_MAXNAMELEN) 4242641Sahrens return (ENAMETOOLONG); 4252641Sahrens if (intsz * numints >= ZAP_MAXVALUELEN) 4262641Sahrens return (E2BIG); 4272641Sahrens 4281544Seschrock err = dsl_dir_open(ddname, FTAG, &dd, NULL); 4291544Seschrock if (err) 4301544Seschrock return (err); 4312885Sahrens err = dsl_prop_set_dd(dd, propname, intsz, numints, buf); 432789Sahrens dsl_dir_close(dd, FTAG); 433789Sahrens return (err); 434789Sahrens } 4351356Seschrock 4361356Seschrock /* 4371356Seschrock * Iterate over all properties for this dataset and return them in an nvlist. 4381356Seschrock */ 4391356Seschrock int 4401356Seschrock dsl_prop_get_all(objset_t *os, nvlist_t **nvp) 4411356Seschrock { 4421356Seschrock dsl_dataset_t *ds = os->os->os_dsl_dataset; 4432082Seschrock dsl_dir_t *dd = ds->ds_dir; 4445331Samw boolean_t snapshot; 4451356Seschrock int err = 0; 4461356Seschrock dsl_pool_t *dp; 4471356Seschrock objset_t *mos; 4481356Seschrock 4495331Samw snapshot = dsl_dataset_is_snapshot(ds); 4501356Seschrock 4511356Seschrock VERIFY(nvlist_alloc(nvp, NV_UNIQUE_NAME, KM_SLEEP) == 0); 4521356Seschrock 4531356Seschrock dp = dd->dd_pool; 4541356Seschrock mos = dp->dp_meta_objset; 4551356Seschrock 4561356Seschrock rw_enter(&dp->dp_config_rwlock, RW_READER); 4572082Seschrock for (; dd != NULL; dd = dd->dd_parent) { 4582885Sahrens char setpoint[MAXNAMELEN]; 4592885Sahrens zap_cursor_t zc; 4602885Sahrens zap_attribute_t za; 4612885Sahrens 4621356Seschrock dsl_dir_name(dd, setpoint); 4631356Seschrock 4641356Seschrock for (zap_cursor_init(&zc, mos, dd->dd_phys->dd_props_zapobj); 4651356Seschrock (err = zap_cursor_retrieve(&zc, &za)) == 0; 4661356Seschrock zap_cursor_advance(&zc)) { 4672885Sahrens nvlist_t *propval; 4682885Sahrens zfs_prop_t prop; 4692676Seschrock /* 4702676Seschrock * Skip non-inheritable properties. 4712676Seschrock */ 4722676Seschrock if ((prop = zfs_name_to_prop(za.za_name)) != 4735094Slling ZPROP_INVAL && !zfs_prop_inheritable(prop) && 4742676Seschrock dd != ds->ds_dir) 4751356Seschrock continue; 4761356Seschrock 4775331Samw if (snapshot && 4785331Samw !zfs_prop_valid_for_type(prop, ZFS_TYPE_SNAPSHOT)) 4795331Samw continue; 4805331Samw 4812676Seschrock if (nvlist_lookup_nvlist(*nvp, za.za_name, 4822676Seschrock &propval) == 0) 4832676Seschrock continue; 4842676Seschrock 4852676Seschrock VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, 4861356Seschrock KM_SLEEP) == 0); 4871356Seschrock if (za.za_integer_length == 1) { 4881356Seschrock /* 4891356Seschrock * String property 4901356Seschrock */ 4912885Sahrens char *tmp = kmem_alloc(za.za_num_integers, 4922885Sahrens KM_SLEEP); 4931356Seschrock err = zap_lookup(mos, 4941356Seschrock dd->dd_phys->dd_props_zapobj, 4951356Seschrock za.za_name, 1, za.za_num_integers, 4961356Seschrock tmp); 4971356Seschrock if (err != 0) { 4981356Seschrock kmem_free(tmp, za.za_num_integers); 4991356Seschrock break; 5001356Seschrock } 5015094Slling VERIFY(nvlist_add_string(propval, ZPROP_VALUE, 5025094Slling tmp) == 0); 5031356Seschrock kmem_free(tmp, za.za_num_integers); 5041356Seschrock } else { 5051356Seschrock /* 5061356Seschrock * Integer property 5071356Seschrock */ 5081356Seschrock ASSERT(za.za_integer_length == 8); 5095094Slling (void) nvlist_add_uint64(propval, ZPROP_VALUE, 5105094Slling za.za_first_integer); 5111356Seschrock } 5121356Seschrock 5135094Slling VERIFY(nvlist_add_string(propval, ZPROP_SOURCE, 5145094Slling setpoint) == 0); 5151356Seschrock VERIFY(nvlist_add_nvlist(*nvp, za.za_name, 5162676Seschrock propval) == 0); 5172676Seschrock nvlist_free(propval); 5181356Seschrock } 5191356Seschrock zap_cursor_fini(&zc); 5201356Seschrock 5212082Seschrock if (err != ENOENT) 5221356Seschrock break; 5232082Seschrock err = 0; 5241356Seschrock } 5251356Seschrock rw_exit(&dp->dp_config_rwlock); 5261356Seschrock 5271356Seschrock return (err); 5281356Seschrock } 5292885Sahrens 5302885Sahrens void 5312885Sahrens dsl_prop_nvlist_add_uint64(nvlist_t *nv, zfs_prop_t prop, uint64_t value) 5322885Sahrens { 5332885Sahrens nvlist_t *propval; 5342885Sahrens 5352885Sahrens VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, KM_SLEEP) == 0); 5365094Slling VERIFY(nvlist_add_uint64(propval, ZPROP_VALUE, value) == 0); 5372885Sahrens VERIFY(nvlist_add_nvlist(nv, zfs_prop_to_name(prop), propval) == 0); 5382885Sahrens nvlist_free(propval); 5392885Sahrens } 5402885Sahrens 5412885Sahrens void 5422885Sahrens dsl_prop_nvlist_add_string(nvlist_t *nv, zfs_prop_t prop, const char *value) 5432885Sahrens { 5442885Sahrens nvlist_t *propval; 5452885Sahrens 5462885Sahrens VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, KM_SLEEP) == 0); 5475094Slling VERIFY(nvlist_add_string(propval, ZPROP_VALUE, value) == 0); 5482885Sahrens VERIFY(nvlist_add_nvlist(nv, zfs_prop_to_name(prop), propval) == 0); 5492885Sahrens nvlist_free(propval); 5502885Sahrens } 551