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 /* 22*6047Sahrens * Copyright 2008 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) { 1335569Sck153898 if (need_rwlock) 1345569Sck153898 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; 283*6047Sahrens 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 314*6047Sahrens za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); 3152199Sahrens for (zap_cursor_init(&zc, mos, 3162199Sahrens dd->dd_phys->dd_child_dir_zapobj); 317*6047Sahrens zap_cursor_retrieve(&zc, za) == 0; 3182199Sahrens zap_cursor_advance(&zc)) { 319*6047Sahrens dsl_prop_changed_notify(dp, za->za_first_integer, 3202199Sahrens propname, value, FALSE); 321789Sahrens } 322*6047Sahrens kmem_free(za, sizeof (zap_attribute_t)); 3232199Sahrens zap_cursor_fini(&zc); 324789Sahrens dsl_dir_close(dd, FTAG); 325789Sahrens } 326789Sahrens 327789Sahrens struct prop_set_arg { 328789Sahrens const char *name; 329789Sahrens int intsz; 330789Sahrens int numints; 331789Sahrens const void *buf; 332789Sahrens }; 333789Sahrens 3342199Sahrens 3352199Sahrens static void 3364543Smarks dsl_prop_set_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) 337789Sahrens { 3382199Sahrens dsl_dir_t *dd = arg1; 3392199Sahrens struct prop_set_arg *psa = arg2; 340789Sahrens objset_t *mos = dd->dd_pool->dp_meta_objset; 341789Sahrens uint64_t zapobj = dd->dd_phys->dd_props_zapobj; 342789Sahrens uint64_t intval; 3432199Sahrens int isint; 3444543Smarks char valbuf[32]; 3454543Smarks char *valstr; 346789Sahrens 347789Sahrens isint = (dodefault(psa->name, 8, 1, &intval) == 0); 348789Sahrens 349789Sahrens if (psa->numints == 0) { 3502199Sahrens int err = zap_remove(mos, zapobj, psa->name, tx); 3512199Sahrens ASSERT(err == 0 || err == ENOENT); 3522199Sahrens if (isint) { 3532199Sahrens VERIFY(0 == dsl_prop_get_impl(dd->dd_parent, 3542199Sahrens psa->name, 8, 1, &intval, NULL)); 355789Sahrens } 356789Sahrens } else { 3572199Sahrens VERIFY(0 == zap_update(mos, zapobj, psa->name, 3582199Sahrens psa->intsz, psa->numints, psa->buf, tx)); 359789Sahrens if (isint) 360789Sahrens intval = *(uint64_t *)psa->buf; 361789Sahrens } 362789Sahrens 3632199Sahrens if (isint) { 364789Sahrens dsl_prop_changed_notify(dd->dd_pool, 365789Sahrens dd->dd_object, psa->name, intval, TRUE); 366789Sahrens } 3674543Smarks if (isint) { 3684543Smarks (void) snprintf(valbuf, sizeof (valbuf), 3694543Smarks "%lld", (longlong_t)intval); 3704543Smarks valstr = valbuf; 3714543Smarks } else { 3724543Smarks valstr = (char *)psa->buf; 3734543Smarks } 3744543Smarks spa_history_internal_log((psa->numints == 0) ? LOG_DS_INHERIT : 3754543Smarks LOG_DS_PROPSET, dd->dd_pool->dp_spa, tx, cr, 3764543Smarks "%s=%s dataset = %llu", psa->name, valstr, 3774543Smarks dd->dd_phys->dd_head_dataset_obj); 378789Sahrens } 379789Sahrens 3805378Sck153898 void 3815378Sck153898 dsl_prop_set_uint64_sync(dsl_dir_t *dd, const char *name, uint64_t val, 3825378Sck153898 cred_t *cr, dmu_tx_t *tx) 3835378Sck153898 { 3845378Sck153898 objset_t *mos = dd->dd_pool->dp_meta_objset; 3855378Sck153898 uint64_t zapobj = dd->dd_phys->dd_props_zapobj; 3865378Sck153898 3875378Sck153898 ASSERT(dmu_tx_is_syncing(tx)); 3885378Sck153898 3895378Sck153898 VERIFY(0 == zap_update(mos, zapobj, name, sizeof (val), 1, &val, tx)); 3905378Sck153898 3915378Sck153898 dsl_prop_changed_notify(dd->dd_pool, dd->dd_object, name, val, TRUE); 3925378Sck153898 3935378Sck153898 spa_history_internal_log(LOG_DS_PROPSET, dd->dd_pool->dp_spa, tx, cr, 3945378Sck153898 "%s=%llu dataset = %llu", name, (u_longlong_t)val, 3955378Sck153898 dd->dd_phys->dd_head_dataset_obj); 3965378Sck153898 } 3975378Sck153898 398789Sahrens int 3992885Sahrens dsl_prop_set_dd(dsl_dir_t *dd, const char *propname, 4002885Sahrens int intsz, int numints, const void *buf) 4012885Sahrens { 4022885Sahrens struct prop_set_arg psa; 4032885Sahrens 4042885Sahrens psa.name = propname; 4052885Sahrens psa.intsz = intsz; 4062885Sahrens psa.numints = numints; 4072885Sahrens psa.buf = buf; 4082885Sahrens 4092885Sahrens return (dsl_sync_task_do(dd->dd_pool, 4102885Sahrens NULL, dsl_prop_set_sync, dd, &psa, 2)); 4112885Sahrens } 4122885Sahrens 4132885Sahrens int 414789Sahrens dsl_prop_set(const char *ddname, const char *propname, 415789Sahrens int intsz, int numints, const void *buf) 416789Sahrens { 417789Sahrens dsl_dir_t *dd; 418789Sahrens int err; 419789Sahrens 4202641Sahrens /* 4212641Sahrens * We must do these checks before we get to the syncfunc, since 4222641Sahrens * it can't fail. 4232641Sahrens */ 4242641Sahrens if (strlen(propname) >= ZAP_MAXNAMELEN) 4252641Sahrens return (ENAMETOOLONG); 4262641Sahrens if (intsz * numints >= ZAP_MAXVALUELEN) 4272641Sahrens return (E2BIG); 4282641Sahrens 4291544Seschrock err = dsl_dir_open(ddname, FTAG, &dd, NULL); 4301544Seschrock if (err) 4311544Seschrock return (err); 4322885Sahrens err = dsl_prop_set_dd(dd, propname, intsz, numints, buf); 433789Sahrens dsl_dir_close(dd, FTAG); 434789Sahrens return (err); 435789Sahrens } 4361356Seschrock 4371356Seschrock /* 4381356Seschrock * Iterate over all properties for this dataset and return them in an nvlist. 4391356Seschrock */ 4401356Seschrock int 4411356Seschrock dsl_prop_get_all(objset_t *os, nvlist_t **nvp) 4421356Seschrock { 4431356Seschrock dsl_dataset_t *ds = os->os->os_dsl_dataset; 4442082Seschrock dsl_dir_t *dd = ds->ds_dir; 4455331Samw boolean_t snapshot; 4461356Seschrock int err = 0; 4471356Seschrock dsl_pool_t *dp; 4481356Seschrock objset_t *mos; 4491356Seschrock 4505331Samw snapshot = dsl_dataset_is_snapshot(ds); 4511356Seschrock 4521356Seschrock VERIFY(nvlist_alloc(nvp, NV_UNIQUE_NAME, KM_SLEEP) == 0); 4531356Seschrock 4541356Seschrock dp = dd->dd_pool; 4551356Seschrock mos = dp->dp_meta_objset; 4561356Seschrock 4571356Seschrock rw_enter(&dp->dp_config_rwlock, RW_READER); 4582082Seschrock for (; dd != NULL; dd = dd->dd_parent) { 4592885Sahrens char setpoint[MAXNAMELEN]; 4602885Sahrens zap_cursor_t zc; 4612885Sahrens zap_attribute_t za; 4622885Sahrens 4631356Seschrock dsl_dir_name(dd, setpoint); 4641356Seschrock 4651356Seschrock for (zap_cursor_init(&zc, mos, dd->dd_phys->dd_props_zapobj); 4661356Seschrock (err = zap_cursor_retrieve(&zc, &za)) == 0; 4671356Seschrock zap_cursor_advance(&zc)) { 4682885Sahrens nvlist_t *propval; 4692885Sahrens zfs_prop_t prop; 4702676Seschrock /* 4712676Seschrock * Skip non-inheritable properties. 4722676Seschrock */ 4732676Seschrock if ((prop = zfs_name_to_prop(za.za_name)) != 4745094Slling ZPROP_INVAL && !zfs_prop_inheritable(prop) && 4752676Seschrock dd != ds->ds_dir) 4761356Seschrock continue; 4771356Seschrock 4785331Samw if (snapshot && 4795331Samw !zfs_prop_valid_for_type(prop, ZFS_TYPE_SNAPSHOT)) 4805331Samw continue; 4815331Samw 4822676Seschrock if (nvlist_lookup_nvlist(*nvp, za.za_name, 4832676Seschrock &propval) == 0) 4842676Seschrock continue; 4852676Seschrock 4862676Seschrock VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, 4871356Seschrock KM_SLEEP) == 0); 4881356Seschrock if (za.za_integer_length == 1) { 4891356Seschrock /* 4901356Seschrock * String property 4911356Seschrock */ 4922885Sahrens char *tmp = kmem_alloc(za.za_num_integers, 4932885Sahrens KM_SLEEP); 4941356Seschrock err = zap_lookup(mos, 4951356Seschrock dd->dd_phys->dd_props_zapobj, 4961356Seschrock za.za_name, 1, za.za_num_integers, 4971356Seschrock tmp); 4981356Seschrock if (err != 0) { 4991356Seschrock kmem_free(tmp, za.za_num_integers); 5001356Seschrock break; 5011356Seschrock } 5025094Slling VERIFY(nvlist_add_string(propval, ZPROP_VALUE, 5035094Slling tmp) == 0); 5041356Seschrock kmem_free(tmp, za.za_num_integers); 5051356Seschrock } else { 5061356Seschrock /* 5071356Seschrock * Integer property 5081356Seschrock */ 5091356Seschrock ASSERT(za.za_integer_length == 8); 5105094Slling (void) nvlist_add_uint64(propval, ZPROP_VALUE, 5115094Slling za.za_first_integer); 5121356Seschrock } 5131356Seschrock 5145094Slling VERIFY(nvlist_add_string(propval, ZPROP_SOURCE, 5155094Slling setpoint) == 0); 5161356Seschrock VERIFY(nvlist_add_nvlist(*nvp, za.za_name, 5172676Seschrock propval) == 0); 5182676Seschrock nvlist_free(propval); 5191356Seschrock } 5201356Seschrock zap_cursor_fini(&zc); 5211356Seschrock 5222082Seschrock if (err != ENOENT) 5231356Seschrock break; 5242082Seschrock err = 0; 5251356Seschrock } 5261356Seschrock rw_exit(&dp->dp_config_rwlock); 5271356Seschrock 5281356Seschrock return (err); 5291356Seschrock } 5302885Sahrens 5312885Sahrens void 5322885Sahrens dsl_prop_nvlist_add_uint64(nvlist_t *nv, zfs_prop_t prop, uint64_t value) 5332885Sahrens { 5342885Sahrens nvlist_t *propval; 5352885Sahrens 5362885Sahrens VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, KM_SLEEP) == 0); 5375094Slling VERIFY(nvlist_add_uint64(propval, ZPROP_VALUE, value) == 0); 5382885Sahrens VERIFY(nvlist_add_nvlist(nv, zfs_prop_to_name(prop), propval) == 0); 5392885Sahrens nvlist_free(propval); 5402885Sahrens } 5412885Sahrens 5422885Sahrens void 5432885Sahrens dsl_prop_nvlist_add_string(nvlist_t *nv, zfs_prop_t prop, const char *value) 5442885Sahrens { 5452885Sahrens nvlist_t *propval; 5462885Sahrens 5472885Sahrens VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, KM_SLEEP) == 0); 5485094Slling VERIFY(nvlist_add_string(propval, ZPROP_VALUE, value) == 0); 5492885Sahrens VERIFY(nvlist_add_nvlist(nv, zfs_prop_to_name(prop), propval) == 0); 5502885Sahrens nvlist_free(propval); 5512885Sahrens } 552