Lines Matching +full:vd +full:- +full:supply
9 * or https://opensource.org/licenses/CDDL-1.0.
38 * Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
56 * Non-legacy ioctls should be registered by calling
66 * output nvlists. The log entry can be printed with "zpool history -i".
83 * This specifies what to expect in the zfs_cmd_t:zc_name -- a pool
84 * name, a dataset name, or nothing. If the name is not well-formed,
86 * Therefore, the callback can assume that the name is well-formed
87 * (e.g. is null-terminated, doesn't have more than one '@' character,
95 * Multiple checks can be or-ed together (e.g. POOL_CHECK_SUSPENDED |
108 * outnvlist does not fit into the userland-provided buffer, then the
115 * failure. If the function fails, the userland ioctl will return -1,
133 * zfs_cmd_t:zc_nvlist_dst. If it is non-empty, and serialization
134 * fails (e.g. because the caller didn't supply a large enough
139 * - To return state, e.g. property values. In this case,
144 * - To return multiple errors from an ioctl which makes on-disk
146 * Ioctls which make on-disk modifications should generally not
229 * for zc->zc_nvlist_src_size, since we will need to allocate that much memory.
235 * When logging the output nvlist of an ioctl in the on-disk history, limit
297 if (zc->zc_history == 0) in history_str_get()
301 if (copyinstr((void *)(uintptr_t)zc->zc_history, in history_str_get()
307 buf[HIS_MAX_RECORD_LEN -1] = '\0'; in history_str_get()
313 * Return non-zero if the spa version is less than requested version.
346 /* XXX reading from non-owned objset */ in zpl_earlier_version()
363 if (spa_open(zc->zc_name, &spa, FTAG) == 0) { in zfs_log_history()
372 * Policy for top-level read operations (list pools). Requires no privileges,
391 zone_dataset_visible(zc->zc_name, NULL)) in zfs_secpolicy_read()
403 * The dataset must be visible by this zone -- check this first in zfs_dozonecheck_impl()
504 * Returns 0 for success, non-zero for access and other errors.
514 int needed_priv = -1; in zfs_set_slabel_policy()
531 * In a non-global zone, disallow attempts to set a label that in zfs_set_slabel_policy()
542 * For global-zone datasets (i.e., those whose zoned property is in zfs_set_slabel_policy()
594 if (needed_priv != -1) in zfs_set_slabel_policy()
666 return (zfs_dozonecheck(zc->zc_name, cr)); in zfs_secpolicy_set_fsacl()
673 return (zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_rollback()
690 cp = strchr(zc->zc_name, '@'); in zfs_secpolicy_send()
693 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_secpolicy_send()
697 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &ds); in zfs_secpolicy_send()
703 dsl_dataset_name(ds, zc->zc_name); in zfs_secpolicy_send()
705 error = zfs_secpolicy_write_perms_ds(zc->zc_name, ds, in zfs_secpolicy_send()
717 return (zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_send_new()
773 return (zfs_secpolicy_destroy_perms(zc->zc_name, cr)); in zfs_secpolicy_destroy()
846 return (zfs_secpolicy_rename_perms(zc->zc_name, zc->zc_value, cr)); in zfs_secpolicy_rename()
857 error = zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_promote()
862 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_secpolicy_promote()
866 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &clone); in zfs_secpolicy_promote()
872 dd = clone->ds_dir; in zfs_secpolicy_promote()
874 error = dsl_dataset_hold_obj(dd->dd_pool, in zfs_secpolicy_promote()
875 dsl_dir_phys(dd)->dd_origin_obj, FTAG, &origin); in zfs_secpolicy_promote()
882 error = zfs_secpolicy_write_perms_ds(zc->zc_name, clone, in zfs_secpolicy_promote()
903 if ((error = zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_recv()
907 if ((error = zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_recv()
911 return (zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_recv()
1042 if ((error = zfs_get_parent(zc->zc_name, parentname, in zfs_secpolicy_create_clone()
1060 * Policy for pool operations - create/destroy pools, add vdevs, etc. Requires
1086 error = zfs_secpolicy_write_perms(zc->zc_name, ZFS_DELEG_PERM_DIFF, cr); in zfs_secpolicy_diff()
1104 zfs_prop_t prop = zfs_name_to_prop(zc->zc_value); in zfs_secpolicy_inherit_prop()
1107 if (!zfs_prop_user(zc->zc_value)) in zfs_secpolicy_inherit_prop()
1109 return (zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_inherit_prop()
1112 return (zfs_secpolicy_setprop(zc->zc_name, prop, in zfs_secpolicy_inherit_prop()
1124 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) in zfs_secpolicy_userspace_one()
1127 if (zc->zc_value[0] == 0) { in zfs_secpolicy_userspace_one()
1132 if (zc->zc_objset_type == ZFS_PROP_USERUSED || in zfs_secpolicy_userspace_one()
1133 zc->zc_objset_type == ZFS_PROP_USERQUOTA || in zfs_secpolicy_userspace_one()
1134 zc->zc_objset_type == ZFS_PROP_USEROBJUSED || in zfs_secpolicy_userspace_one()
1135 zc->zc_objset_type == ZFS_PROP_USEROBJQUOTA) { in zfs_secpolicy_userspace_one()
1136 if (zc->zc_guid == crgetuid(cr)) in zfs_secpolicy_userspace_one()
1138 } else if (zc->zc_objset_type == ZFS_PROP_GROUPUSED || in zfs_secpolicy_userspace_one()
1139 zc->zc_objset_type == ZFS_PROP_GROUPQUOTA || in zfs_secpolicy_userspace_one()
1140 zc->zc_objset_type == ZFS_PROP_GROUPOBJUSED || in zfs_secpolicy_userspace_one()
1141 zc->zc_objset_type == ZFS_PROP_GROUPOBJQUOTA) { in zfs_secpolicy_userspace_one()
1142 if (groupmember(zc->zc_guid, cr)) in zfs_secpolicy_userspace_one()
1148 return (zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_userspace_one()
1149 userquota_perms[zc->zc_objset_type], cr)); in zfs_secpolicy_userspace_one()
1159 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) in zfs_secpolicy_userspace_many()
1162 return (zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_userspace_many()
1163 userquota_perms[zc->zc_objset_type], cr)); in zfs_secpolicy_userspace_many()
1170 return (zfs_secpolicy_setprop(zc->zc_name, ZFS_PROP_VERSION, in zfs_secpolicy_userspace_upgrade()
1232 if (zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_tmp_snapshot()
1236 error = zfs_secpolicy_snapshot_perms(zc->zc_name, cr); in zfs_secpolicy_tmp_snapshot()
1252 return (zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_load_key()
1259 return (zfs_secpolicy_write_perms(zc->zc_name, in zfs_secpolicy_change_key()
1274 * Read in and unpack the user-supplied nvlist. in get_nvlist()
1345 if (size > zc->zc_nvlist_dst_size) { in put_nvlist()
1349 if (ddi_copyout(packed, (void *)(uintptr_t)zc->zc_nvlist_dst, in put_nvlist()
1350 size, zc->zc_iflags) != 0) in put_nvlist()
1355 zc->zc_nvlist_dst_size = size; in put_nvlist()
1356 zc->zc_nvlist_dst_filled = B_TRUE; in put_nvlist()
1368 mutex_enter(&os->os_user_ptr_lock); in getzfsvfs_impl()
1370 /* bump s_active only when non-zero to prevent umount race */ in getzfsvfs_impl()
1372 mutex_exit(&os->os_user_ptr_lock); in getzfsvfs_impl()
1410 if ((*zfvp)->z_unmounted) { in zfsvfs_hold()
1431 dmu_objset_disown(zfsvfs->z_os, B_TRUE, zfsvfs); in zfsvfs_rele()
1444 const char *spa_name = zc->zc_name; in zfs_ioc_pool_create()
1447 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_pool_create()
1448 zc->zc_iflags, &config))) in zfs_ioc_pool_create()
1451 if (zc->zc_nvlist_src_size != 0 && (error = in zfs_ioc_pool_create()
1452 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_pool_create()
1453 zc->zc_iflags, &props))) { in zfs_ioc_pool_create()
1497 error = spa_create(zc->zc_name, config, props, zplprops, dcp); in zfs_ioc_pool_create()
1523 error = spa_destroy(zc->zc_name); in zfs_ioc_pool_destroy()
1535 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_pool_import()
1536 zc->zc_iflags, &config)) != 0) in zfs_ioc_pool_import()
1539 if (zc->zc_nvlist_src_size != 0 && (error = in zfs_ioc_pool_import()
1540 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_pool_import()
1541 zc->zc_iflags, &props))) { in zfs_ioc_pool_import()
1547 guid != zc->zc_guid) in zfs_ioc_pool_import()
1550 error = spa_import(zc->zc_name, config, props, zc->zc_cookie); in zfs_ioc_pool_import()
1552 if (zc->zc_nvlist_dst != 0) { in zfs_ioc_pool_import()
1569 boolean_t force = (boolean_t)zc->zc_cookie; in zfs_ioc_pool_export()
1570 boolean_t hardforce = (boolean_t)zc->zc_guid; in zfs_ioc_pool_export()
1573 error = spa_export(zc->zc_name, NULL, force, hardforce); in zfs_ioc_pool_export()
1584 error = spa_all_configs(&zc->zc_cookie, &configs); in zfs_ioc_pool_configs()
1611 error = spa_get_stats(zc->zc_name, &config, zc->zc_value, in zfs_ioc_pool_stats()
1612 sizeof (zc->zc_value)); in zfs_ioc_pool_stats()
1619 * The config may be present even if 'error' is non-zero. in zfs_ioc_pool_stats()
1623 zc->zc_cookie = error; in zfs_ioc_pool_stats()
1641 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_pool_tryimport()
1642 zc->zc_iflags, &tryconfig)) != 0) in zfs_ioc_pool_tryimport()
1670 if (zc->zc_flags >= POOL_SCRUB_FLAGS_END) in zfs_ioc_pool_scan()
1673 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_pool_scan()
1676 if (zc->zc_flags == POOL_SCRUB_PAUSE) in zfs_ioc_pool_scan()
1678 else if (zc->zc_cookie == POOL_SCAN_NONE) in zfs_ioc_pool_scan()
1681 error = spa_scan(spa, zc->zc_cookie); in zfs_ioc_pool_scan()
1738 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_pool_freeze()
1752 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_pool_upgrade()
1755 if (zc->zc_cookie < spa_version(spa) || in zfs_ioc_pool_upgrade()
1756 !SPA_VERSION_IS_SUPPORTED(zc->zc_cookie)) { in zfs_ioc_pool_upgrade()
1761 spa_upgrade(spa, zc->zc_cookie); in zfs_ioc_pool_upgrade()
1775 if ((size = zc->zc_history_len) == 0) in zfs_ioc_pool_get_history()
1778 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_pool_get_history()
1787 if ((error = spa_history_get(spa, &zc->zc_history_offset, in zfs_ioc_pool_get_history()
1788 &zc->zc_history_len, hist_buf)) == 0) { in zfs_ioc_pool_get_history()
1790 (void *)(uintptr_t)zc->zc_history, in zfs_ioc_pool_get_history()
1791 zc->zc_history_len, zc->zc_iflags); in zfs_ioc_pool_get_history()
1813 if (zc->zc_nvlist_src_size != 0) { in zfs_ioc_pool_reguid()
1814 error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_pool_reguid()
1815 zc->zc_iflags, &props); in zfs_ioc_pool_reguid()
1828 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_pool_reguid()
1844 return (dsl_dsobj_to_dsname(zc->zc_name, zc->zc_obj, zc->zc_value)); in zfs_ioc_dsobj_to_dsname()
1862 if ((error = dmu_objset_hold_flags(zc->zc_name, B_TRUE, in zfs_ioc_obj_to_path()
1869 error = zfs_obj_to_path(os, zc->zc_obj, zc->zc_value, in zfs_ioc_obj_to_path()
1870 sizeof (zc->zc_value)); in zfs_ioc_obj_to_path()
1892 if ((error = dmu_objset_hold_flags(zc->zc_name, B_TRUE, in zfs_ioc_obj_to_stats()
1899 error = zfs_obj_to_stats(os, zc->zc_obj, &zc->zc_stat, zc->zc_value, in zfs_ioc_obj_to_stats()
1900 sizeof (zc->zc_value)); in zfs_ioc_obj_to_stats()
1913 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_vdev_add()
1917 error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_vdev_add()
1918 zc->zc_iflags, &config); in zfs_ioc_vdev_add()
1920 error = spa_vdev_add(spa, config, zc->zc_flags); in zfs_ioc_vdev_add()
1939 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_vdev_remove()
1942 if (zc->zc_cookie != 0) { in zfs_ioc_vdev_remove()
1945 error = spa_vdev_remove(spa, zc->zc_guid, B_FALSE); in zfs_ioc_vdev_remove()
1958 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_vdev_set_state()
1960 switch (zc->zc_cookie) { in zfs_ioc_vdev_set_state()
1962 error = vdev_online(spa, zc->zc_guid, zc->zc_obj, &newstate); in zfs_ioc_vdev_set_state()
1966 error = vdev_offline(spa, zc->zc_guid, zc->zc_obj); in zfs_ioc_vdev_set_state()
1970 if (zc->zc_obj != VDEV_AUX_ERR_EXCEEDED && in zfs_ioc_vdev_set_state()
1971 zc->zc_obj != VDEV_AUX_EXTERNAL && in zfs_ioc_vdev_set_state()
1972 zc->zc_obj != VDEV_AUX_EXTERNAL_PERSIST) in zfs_ioc_vdev_set_state()
1973 zc->zc_obj = VDEV_AUX_ERR_EXCEEDED; in zfs_ioc_vdev_set_state()
1975 error = vdev_fault(spa, zc->zc_guid, zc->zc_obj); in zfs_ioc_vdev_set_state()
1979 if (zc->zc_obj != VDEV_AUX_ERR_EXCEEDED && in zfs_ioc_vdev_set_state()
1980 zc->zc_obj != VDEV_AUX_EXTERNAL) in zfs_ioc_vdev_set_state()
1981 zc->zc_obj = VDEV_AUX_ERR_EXCEEDED; in zfs_ioc_vdev_set_state()
1983 error = vdev_degrade(spa, zc->zc_guid, zc->zc_obj); in zfs_ioc_vdev_set_state()
1987 error = vdev_remove_wanted(spa, zc->zc_guid); in zfs_ioc_vdev_set_state()
1993 zc->zc_cookie = newstate; in zfs_ioc_vdev_set_state()
2003 int replacing = zc->zc_cookie; in zfs_ioc_vdev_attach()
2004 int rebuild = zc->zc_simple; in zfs_ioc_vdev_attach()
2007 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_vdev_attach()
2010 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_vdev_attach()
2011 zc->zc_iflags, &config)) == 0) { in zfs_ioc_vdev_attach()
2012 error = spa_vdev_attach(spa, zc->zc_guid, config, replacing, in zfs_ioc_vdev_attach()
2027 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_vdev_detach()
2030 error = spa_vdev_detach(spa, zc->zc_guid, 0, B_FALSE); in zfs_ioc_vdev_detach()
2042 boolean_t exp = !!(zc->zc_cookie & ZPOOL_EXPORT_AFTER_SPLIT); in zfs_ioc_vdev_split()
2044 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_vdev_split()
2047 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_vdev_split()
2048 zc->zc_iflags, &config))) { in zfs_ioc_vdev_split()
2053 if (zc->zc_nvlist_src_size != 0 && (error = in zfs_ioc_vdev_split()
2054 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_vdev_split()
2055 zc->zc_iflags, &props))) { in zfs_ioc_vdev_split()
2061 error = spa_vdev_split_mirror(spa, zc->zc_string, config, props, exp); in zfs_ioc_vdev_split()
2075 const char *path = zc->zc_value; in zfs_ioc_vdev_setpath()
2076 uint64_t guid = zc->zc_guid; in zfs_ioc_vdev_setpath()
2079 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_vdev_setpath()
2092 const char *fru = zc->zc_value; in zfs_ioc_vdev_setfru()
2093 uint64_t guid = zc->zc_guid; in zfs_ioc_vdev_setfru()
2096 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_vdev_setfru()
2111 dmu_objset_fast_stat(os, &zc->zc_objset_stats); in zfs_ioc_objset_stats_impl()
2113 if (!zc->zc_simple && zc->zc_nvlist_dst != 0 && in zfs_ioc_objset_stats_impl()
2123 if (!zc->zc_objset_stats.dds_inconsistent && in zfs_ioc_objset_stats_impl()
2156 error = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_objset_stats()
2189 if (!dsl_prop_get_hasrecvd(zc->zc_name)) in zfs_ioc_objset_recvd_props()
2192 if (zc->zc_nvlist_dst != 0 && in zfs_ioc_objset_recvd_props()
2193 (error = dsl_prop_get_received(zc->zc_name, &nv)) == 0) { in zfs_ioc_objset_recvd_props()
2233 if ((err = dmu_objset_hold(zc->zc_name, FTAG, &os))) in zfs_ioc_objset_zplprops()
2236 dmu_objset_fast_stat(os, &zc->zc_objset_stats); in zfs_ioc_objset_zplprops()
2243 if (zc->zc_nvlist_dst != 0 && in zfs_ioc_objset_zplprops()
2244 !zc->zc_objset_stats.dds_inconsistent && in zfs_ioc_objset_zplprops()
2281 size_t orig_len = strlen(zc->zc_name); in zfs_ioc_dataset_list_next()
2284 if ((error = dmu_objset_hold(zc->zc_name, FTAG, &os))) { in zfs_ioc_dataset_list_next()
2290 p = strrchr(zc->zc_name, '/'); in zfs_ioc_dataset_list_next()
2292 (void) strlcat(zc->zc_name, "/", sizeof (zc->zc_name)); in zfs_ioc_dataset_list_next()
2293 p = zc->zc_name + strlen(zc->zc_name); in zfs_ioc_dataset_list_next()
2297 sizeof (zc->zc_name) - (p - zc->zc_name), p, in zfs_ioc_dataset_list_next()
2298 NULL, &zc->zc_cookie); in zfs_ioc_dataset_list_next()
2301 } while (error == 0 && zfs_dataset_name_hidden(zc->zc_name)); in zfs_ioc_dataset_list_next()
2308 if (error == 0 && strchr(zc->zc_name, '$') == NULL) { in zfs_ioc_dataset_list_next()
2312 zc->zc_name[orig_len] = '\0'; in zfs_ioc_dataset_list_next()
2340 if (zc->zc_nvlist_src_size != 0) { in zfs_ioc_snapshot_list_next()
2342 error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_snapshot_list_next()
2343 zc->zc_iflags, &props); in zfs_ioc_snapshot_list_next()
2353 error = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_snapshot_list_next()
2362 if (strlcat(zc->zc_name, "@", sizeof (zc->zc_name)) >= in zfs_ioc_snapshot_list_next()
2375 sizeof (zc->zc_name) - strlen(zc->zc_name), in zfs_ioc_snapshot_list_next()
2376 zc->zc_name + strlen(zc->zc_name), &zc->zc_obj, in zfs_ioc_snapshot_list_next()
2377 &zc->zc_cookie, NULL); in zfs_ioc_snapshot_list_next()
2385 error = dsl_dataset_hold_obj(dmu_objset_pool(os), zc->zc_obj, in zfs_ioc_snapshot_list_next()
2394 *(strchr(zc->zc_name, '@') + 1) = '\0'; in zfs_ioc_snapshot_list_next()
2399 if (zc->zc_simple) { in zfs_ioc_snapshot_list_next()
2400 dsl_dataset_fast_stat(ds, &zc->zc_objset_stats); in zfs_ioc_snapshot_list_next()
2420 *strchr(zc->zc_name, '@') = '\0'; in zfs_ioc_snapshot_list_next()
2447 * userquota@<rid>-<domain>. in zfs_prop_set_userquota()
2449 if ((dash = strchr(propname, '-')) == NULL || in zfs_prop_set_userquota()
2471 * not one of the special properties handled by this function, return -1.
2484 int err = -1; in zfs_prop_set_special()
2489 return (-1); in zfs_prop_set_special()
2522 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2526 err = -1; in zfs_prop_set_special()
2532 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2536 err = -1; in zfs_prop_set_special()
2547 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2551 err = -1; in zfs_prop_set_special()
2559 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2563 err = -1; in zfs_prop_set_special()
2572 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2576 err = -1; in zfs_prop_set_special()
2592 (void) strlcpy(zc->zc_name, dsname, in zfs_prop_set_special()
2593 sizeof (zc->zc_name)); in zfs_prop_set_special()
2612 err = -1; in zfs_prop_set_special()
2622 if (!spa_feature_is_enabled(zfsvfs->z_os->os_spa, in zfs_prop_set_special()
2627 * Set err to -1 to force the zfs_set_prop_nvlist code in zfs_prop_set_special()
2630 err = -1; in zfs_prop_set_special()
2636 err = -1; in zfs_prop_set_special()
2665 * encountered. If the caller provides a non-NULL errlist, it will be filled in
2755 err = -1; /* does not need special handling */ in zfs_set_prop_nvlist()
2759 if (err == -1) { in zfs_set_prop_nvlist()
2919 boolean_t received = zc->zc_cookie; in zfs_ioc_set_prop()
2925 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_set_prop()
2926 zc->zc_iflags, &nvl)) != 0) in zfs_ioc_set_prop()
2932 if (dsl_prop_get_received(zc->zc_name, &origprops) == 0) { in zfs_ioc_set_prop()
2933 (void) clear_received_props(zc->zc_name, in zfs_ioc_set_prop()
2938 error = dsl_prop_set_hasrecvd(zc->zc_name); in zfs_ioc_set_prop()
2943 error = zfs_set_prop_nvlist(zc->zc_name, source, nvl, errors); in zfs_ioc_set_prop()
2945 if (zc->zc_nvlist_dst != 0 && errors != NULL) { in zfs_ioc_set_prop()
2965 const char *propname = zc->zc_value; in zfs_ioc_inherit_prop()
2967 boolean_t received = zc->zc_cookie; in zfs_ioc_inherit_prop()
2978 * Only check this in the non-received case. We want to allow in zfs_ioc_inherit_prop()
2979 * 'inherit -S' to revert non-inheritable properties like quota in zfs_ioc_inherit_prop()
3021 err = zfs_prop_set_special(zc->zc_name, source, pair); in zfs_ioc_inherit_prop()
3022 if (err == -1) /* property is not "special", needs handling */ in zfs_ioc_inherit_prop()
3023 err = dsl_prop_inherit(zc->zc_name, zc->zc_value, in zfs_ioc_inherit_prop()
3040 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_pool_set_props()
3041 zc->zc_iflags, &props))) in zfs_ioc_pool_set_props()
3053 if ((spa = spa_lookup(zc->zc_name)) != NULL) { in zfs_ioc_pool_set_props()
3064 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) { in zfs_ioc_pool_set_props()
3127 * "vdevprops_set_vdev" -> guid
3128 * "vdevprops_set_props" -> { prop -> value }
3131 * outnvl: propname -> error code (int32)
3143 vdev_t *vd; in zfs_ioc_vdev_set_props() local
3159 if ((vd = spa_lookup_by_guid(spa, vdev_guid, B_TRUE)) == NULL) { in zfs_ioc_vdev_set_props()
3164 error = vdev_prop_set(vd, innvl, outnvl); in zfs_ioc_vdev_set_props()
3173 * "vdevprops_get_vdev" -> guid
3174 * (optional) "vdevprops_get_props" -> { propname -> propid }
3177 * outnvl: propname -> value
3189 vdev_t *vd; in zfs_ioc_vdev_get_props() local
3203 if ((vd = spa_lookup_by_guid(spa, vdev_guid, B_TRUE)) == NULL) { in zfs_ioc_vdev_get_props()
3208 error = vdev_prop_get(vd, innvl, outnvl); in zfs_ioc_vdev_get_props()
3229 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_set_fsacl()
3230 zc->zc_iflags, &fsaclnv)) != 0) in zfs_ioc_set_fsacl()
3249 if (zc->zc_perm_action == B_FALSE) { in zfs_ioc_set_fsacl()
3250 error = dsl_deleg_can_allow(zc->zc_name, in zfs_ioc_set_fsacl()
3253 error = dsl_deleg_can_unallow(zc->zc_name, in zfs_ioc_set_fsacl()
3259 error = dsl_deleg_set(zc->zc_name, fsaclnv, zc->zc_perm_action); in zfs_ioc_set_fsacl()
3278 if ((error = dsl_deleg_get(zc->zc_name, &nvp)) == 0) { in zfs_ioc_get_fsacl()
3291 zfs_create_fs(os, cr, zct->zct_zplprops, tx); in zfs_create_cb()
3294 #define ZFS_PROP_UNDEFINED ((uint64_t)-1)
3305 * is_ci true if requested file system will be purely case-insensitive
3329 if (os != NULL && os->os_phys->os_type != DMU_OST_ZFS) in zfs_fill_zplprops_impl()
3379 * If we're normalizing, names must always be valid UTF-8 strings. in zfs_fill_zplprops_impl()
3457 * "type" -> dmu_objset_type_t (int32)
3458 * (optional) "props" -> { prop -> value }
3459 * (optional) "hidden_args" -> { "wkeydata" -> value }
3463 * outnvl: propname -> error code (int32)
3538 * case-folding flags correct when we do the in zfs_ioc_create()
3585 taskq_wait(spa->spa_zvol_taskq); in zfs_ioc_create()
3597 * "origin" -> name of origin snapshot
3598 * (optional) "props" -> { prop -> value }
3599 * (optional) "hidden_args" -> { "wkeydata" -> value }
3604 * outnvl: propname -> error code (int32)
3657 * "snaps" -> { snapshot1, snapshot2 }
3658 * (optional) "props" -> { prop -> value (string) }
3661 * outnvl: snapshot -> error code (int32)
3720 if (strncmp(name, nvpair_name(pair2), cp - name + 1) in zfs_ioc_snapshot()
3733 * innvl: "message" -> string
3801 error = vdev_label_write_bootenv(spa->spa_root_vdev, innvl); in zfs_ioc_set_bootenv()
3820 error = vdev_label_read_bootenv(spa->spa_root_vdev, outnvl); in zfs_ioc_get_bootenv()
3830 * This function is best-effort. Callers must deal gracefully if it
3869 if (dsl_dir_is_clone(ds->ds_dir) && DS_IS_DEFER_DESTROY(ds->ds_prev)) { in zfs_destroy_unmount_origin()
3871 dsl_dataset_name(ds->ds_prev, originname); in zfs_destroy_unmount_origin()
3881 * "snaps" -> { snapshot1, snapshot2 }
3885 * outnvl: snapshot -> error code (int32)
3933 * new_bookmark1 -> existing_snapshot,
3934 * new_bookmark2 -> existing_bookmark,
3937 * outnvl: bookmark -> error code (int32)
3957 * bookmark name 1 -> { property 1, property 2, ... },
3958 * bookmark name 2 -> { property 1, property 2, ... }
4008 * outnvl: bookmark -> error code (int32)
4120 * "prefetch_type" -> int32_t
4154 zfs_dbgmsg("pool '%s': loaded ddt into ARC in %llu ms", spa->spa_name, in zfs_ioc_pool_prefetch()
4155 (u_longlong_t)NSEC2MSEC(gethrtime() - start_time)); in zfs_ioc_pool_prefetch()
4176 err = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_destroy()
4183 zfs_unmount_snap(zc->zc_name); in zfs_ioc_destroy()
4185 if (strchr(zc->zc_name, '@')) { in zfs_ioc_destroy()
4186 err = dsl_destroy_snapshot(zc->zc_name, zc->zc_defer_destroy); in zfs_ioc_destroy()
4188 err = dsl_destroy_head(zc->zc_name); in zfs_ioc_destroy()
4192 * hidden child (%recv) datasets - "leftovers" in zfs_ioc_destroy()
4201 zc->zc_name, recv_clone_name) >= in zfs_ioc_destroy()
4213 err = dsl_destroy_head(zc->zc_name); in zfs_ioc_destroy()
4224 * "initialize_command" -> POOL_INITIALIZE_{CANCEL|START|SUSPEND} (uint64)
4225 * "initialize_vdevs": { -> guids to initialize (nvlist)
4233 * "initialize_vdevs": { -> initialization errors (nvlist)
4299 * "trim_command" -> POOL_TRIM_{CANCEL|START|SUSPEND} (uint64)
4300 * "trim_vdevs": { -> guids to TRIM (nvlist)
4305 * "trim_rate" -> Target TRIM rate in bytes/sec.
4306 * "trim_secure" -> Set to request a secure TRIM.
4310 * "trim_vdevs": { -> TRIM errors (nvlist)
4387 * "ddt_prune_unit" -> uint32_t
4388 * "ddt_prune_amount" -> uint64_t
4391 * outnvl: "waited" -> boolean_t
4444 * "wait_activity" -> int32_t
4445 * (optional) "wait_tag" -> uint64_t
4448 * outnvl: "waited" -> boolean_t
4488 * "wait_activity" -> int32_t
4491 * outnvl: "waited" -> boolean_t
4521 dd = ds->ds_dir; in zfs_ioc_wait_fs()
4522 mutex_enter(&dd->dd_activity_lock); in zfs_ioc_wait_fs()
4523 dd->dd_activity_waiters++; in zfs_ioc_wait_fs()
4526 * We get a long-hold here so that the dsl_dataset_t and dsl_dir_t in zfs_ioc_wait_fs()
4530 * of long-holds (e.g. preventing deletion) is unnecessary for this in zfs_ioc_wait_fs()
4541 dd->dd_activity_waiters--; in zfs_ioc_wait_fs()
4542 if (dd->dd_activity_waiters == 0) in zfs_ioc_wait_fs()
4543 cv_signal(&dd->dd_activity_cv); in zfs_ioc_wait_fs()
4544 mutex_exit(&dd->dd_activity_lock); in zfs_ioc_wait_fs()
4559 * outnvl: "target" -> name of most recent snapshot
4590 ds = dmu_objset_ds(zfsvfs->z_os); in zfs_ioc_rollback()
4628 * "bookname" -> (string)
4630 * "snapnv" -> (nvlist, values ignored)
4672 boolean_t recursive = zc->zc_cookie & 1; in zfs_ioc_rename()
4673 boolean_t nounmount = !!(zc->zc_cookie & 2); in zfs_ioc_rename()
4678 zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; in zfs_ioc_rename()
4679 zc->zc_value[sizeof (zc->zc_value) - 1] = '\0'; in zfs_ioc_rename()
4680 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 || in zfs_ioc_rename()
4681 dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || in zfs_ioc_rename()
4682 strchr(zc->zc_name, '%') || strchr(zc->zc_value, '%')) in zfs_ioc_rename()
4685 err = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_rename()
4691 at = strchr(zc->zc_name, '@'); in zfs_ioc_rename()
4696 if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1)) in zfs_ioc_rename()
4700 error = dmu_objset_find(zc->zc_name, in zfs_ioc_rename()
4708 error = dsl_dataset_rename_snapshot(zc->zc_name, in zfs_ioc_rename()
4709 at + 1, strchr(zc->zc_value, '@') + 1, recursive); in zfs_ioc_rename()
4714 return (dsl_dir_rename(zc->zc_name, zc->zc_value)); in zfs_ioc_rename()
4769 /* {USER|GROUP|PROJECT}USED are read-only */ in zfs_check_settable()
4967 * caller provides a non-NULL errlist, it also gives the complete list of names
4989 (void) strlcpy(zc->zc_name, dataset, sizeof (zc->zc_name)); in zfs_check_clearable()
4994 (void) strlcpy(zc->zc_value, nvpair_name(pair), in zfs_check_clearable()
4995 sizeof (zc->zc_value)); in zfs_check_clearable()
5000 zc->zc_value, err) == 0); in zfs_check_clearable()
5095 * refquota pre-receipt will set the dsl's ACTUAL quota, which will prevent
5276 /* -x property */ in zfs_ioc_recv_impl()
5286 /* -o property=value */ in zfs_ioc_recv_impl()
5313 begin_record->drr_u.drr_begin. in zfs_ioc_recv_impl()
5316 ds = dmu_objset_ds(zfsvfs->z_os); in zfs_ioc_recv_impl()
5379 *read_bytes = off - noff; in zfs_ioc_recv_impl()
5412 * first new-style receive. in zfs_ioc_recv_impl()
5520 if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || in zfs_ioc_recv()
5521 strchr(zc->zc_value, '@') == NULL || in zfs_ioc_recv()
5522 strchr(zc->zc_value, '%') != NULL) { in zfs_ioc_recv()
5526 (void) strlcpy(tofs, zc->zc_value, sizeof (tofs)); in zfs_ioc_recv()
5530 if (zc->zc_nvlist_src != 0 && in zfs_ioc_recv()
5531 (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_recv()
5532 zc->zc_iflags, &recvdprops)) != 0) { in zfs_ioc_recv()
5536 if (zc->zc_nvlist_conf != 0 && in zfs_ioc_recv()
5537 (error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_recv()
5538 zc->zc_iflags, &localprops)) != 0) { in zfs_ioc_recv()
5542 if (zc->zc_string[0]) in zfs_ioc_recv()
5543 origin = zc->zc_string; in zfs_ioc_recv()
5547 begin_record.drr_u.drr_begin = zc->zc_begin_record; in zfs_ioc_recv()
5550 NULL, zc->zc_guid, B_FALSE, B_FALSE, zc->zc_cookie, &begin_record, in zfs_ioc_recv()
5551 &zc->zc_cookie, &zc->zc_obj, &errors); in zfs_ioc_recv()
5557 if (zc->zc_nvlist_dst_size != 0 && errors != NULL && in zfs_ioc_recv()
5558 (nvlist_smush(errors, zc->zc_nvlist_dst_size) != 0 || in zfs_ioc_recv()
5561 * Caller made zc->zc_nvlist_dst less than the minimum expected in zfs_ioc_recv()
5577 * "snapname" -> full name of the snapshot to create
5578 * (optional) "props" -> received properties to set (nvlist)
5579 * (optional) "localprops" -> override and exclude properties (nvlist)
5580 * (optional) "origin" -> name of clone origin (DRR_FLAG_CLONE)
5581 * "begin_record" -> non-byteswapped dmu_replay_record_t
5582 * "input_fd" -> file descriptor to read stream from (int32)
5583 * (optional) "force" -> force flag (value ignored)
5584 * (optional) "heal" -> use send stream to heal data corruption
5585 * (optional) "resumable" -> resumable flag (value ignored)
5586 * (optional) "cleanup_fd" -> unused
5587 * (optional) "action_handle" -> unused
5588 * (optional) "hidden_args" -> { "wkeydata" -> value }
5592 * "read_bytes" -> number of bytes read
5593 * "error_flags" -> zprop_errflags_t
5594 * "errors" -> error for each unapplied received property (nvlist)
5630 int input_fd = -1; in zfs_ioc_recv_new()
5712 fp = dbi->dbi_fp; in dump_bytes_cb()
5713 buf = dbi->dbi_buf; in dump_bytes_cb()
5715 dbi->dbi_err = zfs_file_write(fp, buf, dbi->dbi_len, NULL); in dump_bytes_cb()
5732 dbi.dbi_fp = dba->dba_fp; in dump_bytes()
5737 taskq_dispatch_ent(dba->dba_tq, dump_bytes_cb, &dbi, TQ_SLEEP, in dump_bytes()
5738 &dba->dba_tqent); in dump_bytes()
5739 taskq_wait(dba->dba_tq); in dump_bytes()
5754 dba->dba_fp = fp; in dump_bytes_init()
5756 dba->dba_tq = taskq_create("z_send", 1, defclsyspri, 0, 0, 0); in dump_bytes_init()
5757 taskq_init_ent(&dba->dba_tqent); in dump_bytes_init()
5761 out->dso_outfunc = dump_bytes; in dump_bytes_init()
5762 out->dso_arg = dba; in dump_bytes_init()
5763 out->dso_dryrun = B_FALSE; in dump_bytes_init()
5771 zfs_file_put(dba->dba_fp); in dump_bytes_fini()
5773 taskq_destroy(dba->dba_tq); in dump_bytes_fini()
5799 boolean_t estimate = (zc->zc_guid != 0); in zfs_ioc_send()
5800 boolean_t embedok = (zc->zc_flags & 0x1); in zfs_ioc_send()
5801 boolean_t large_block_ok = (zc->zc_flags & 0x2); in zfs_ioc_send()
5802 boolean_t compressok = (zc->zc_flags & 0x4); in zfs_ioc_send()
5803 boolean_t rawok = (zc->zc_flags & 0x8); in zfs_ioc_send()
5804 boolean_t savedok = (zc->zc_flags & 0x10); in zfs_ioc_send()
5806 if (zc->zc_obj != 0) { in zfs_ioc_send()
5810 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_send()
5814 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &tosnap); in zfs_ioc_send()
5820 if (dsl_dir_is_clone(tosnap->ds_dir)) in zfs_ioc_send()
5821 zc->zc_fromobj = in zfs_ioc_send()
5822 dsl_dir_phys(tosnap->ds_dir)->dd_origin_obj; in zfs_ioc_send()
5832 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_send()
5836 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, in zfs_ioc_send()
5843 if (zc->zc_fromobj != 0) { in zfs_ioc_send()
5844 error = dsl_dataset_hold_obj(dp, zc->zc_fromobj, in zfs_ioc_send()
5854 compressok || rawok, savedok, &zc->zc_objset_type); in zfs_ioc_send()
5863 error = dump_bytes_init(&dba, zc->zc_cookie, &out); in zfs_ioc_send()
5868 error = dmu_send_obj(zc->zc_name, zc->zc_sendobj, in zfs_ioc_send()
5869 zc->zc_fromobj, embedok, large_block_ok, compressok, in zfs_ioc_send()
5870 rawok, savedok, zc->zc_cookie, &off, &out); in zfs_ioc_send()
5894 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_send_progress()
5898 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &ds); in zfs_ioc_send_progress()
5904 mutex_enter(&ds->ds_sendstream_lock); in zfs_ioc_send_progress()
5913 for (dsp = list_head(&ds->ds_sendstreams); dsp != NULL; in zfs_ioc_send_progress()
5914 dsp = list_next(&ds->ds_sendstreams, dsp)) { in zfs_ioc_send_progress()
5915 if (dsp->dss_outfd == zc->zc_cookie && in zfs_ioc_send_progress()
5916 zfs_proc_is_caller(dsp->dss_proc)) in zfs_ioc_send_progress()
5921 zc->zc_cookie = atomic_cas_64((volatile uint64_t *)dsp->dss_off, in zfs_ioc_send_progress()
5924 zc->zc_objset_type = atomic_cas_64(&dsp->dss_blocks, 0, 0); in zfs_ioc_send_progress()
5929 mutex_exit(&ds->ds_sendstream_lock); in zfs_ioc_send_progress()
5940 error = zio_inject_fault(zc->zc_name, (int)zc->zc_guid, &id, in zfs_ioc_inject_fault()
5941 &zc->zc_inject_record); in zfs_ioc_inject_fault()
5944 zc->zc_guid = (uint64_t)id; in zfs_ioc_inject_fault()
5952 return (zio_clear_fault((int)zc->zc_guid)); in zfs_ioc_clear_fault()
5958 int id = (int)zc->zc_guid; in zfs_ioc_inject_list_next()
5961 error = zio_inject_list_next(&id, zc->zc_name, sizeof (zc->zc_name), in zfs_ioc_inject_list_next()
5962 &zc->zc_inject_record); in zfs_ioc_inject_list_next()
5964 zc->zc_guid = id; in zfs_ioc_inject_list_next()
5975 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_error_log()
5978 error = spa_get_errlog(spa, (void *)(uintptr_t)zc->zc_nvlist_dst, in zfs_ioc_error_log()
5979 &zc->zc_nvlist_dst_size); in zfs_ioc_error_log()
5990 vdev_t *vd; in zfs_ioc_clear() local
5997 spa = spa_lookup(zc->zc_name); in zfs_ioc_clear()
6006 spa->spa_last_open_failed = 0; in zfs_ioc_clear()
6009 if (zc->zc_cookie & ZPOOL_NO_REWIND) { in zfs_ioc_clear()
6010 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_clear()
6015 if (zc->zc_nvlist_src == 0) in zfs_ioc_clear()
6018 if ((error = get_nvlist(zc->zc_nvlist_src, in zfs_ioc_clear()
6019 zc->zc_nvlist_src_size, zc->zc_iflags, &policy)) == 0) { in zfs_ioc_clear()
6020 error = spa_open_rewind(zc->zc_name, &spa, FTAG, in zfs_ioc_clear()
6048 if (zc->zc_guid == 0) { in zfs_ioc_clear()
6049 vd = NULL; in zfs_ioc_clear()
6051 vd = spa_lookup_by_guid(spa, zc->zc_guid, B_TRUE); in zfs_ioc_clear()
6052 if (vd == NULL) { in zfs_ioc_clear()
6060 vdev_clear(spa, vd); in zfs_ioc_clear()
6063 NULL : spa->spa_root_vdev, 0); in zfs_ioc_clear()
6080 * "scrub_restart" -> when true and scrub is running, allow to restart
6118 spa->spa_scrub_reopen = (!scrub_restart && in zfs_ioc_pool_reopen()
6119 dsl_scan_scrubbing(spa->spa_dsl_pool)); in zfs_ioc_pool_reopen()
6120 vdev_reopen(spa->spa_root_vdev); in zfs_ioc_pool_reopen()
6121 spa->spa_scrub_reopen = B_FALSE; in zfs_ioc_pool_reopen()
6144 zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; in zfs_ioc_promote()
6145 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 || in zfs_ioc_promote()
6146 strchr(zc->zc_name, '%')) in zfs_ioc_promote()
6149 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_promote()
6153 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &ds); in zfs_ioc_promote()
6159 if (!dsl_dir_is_clone(ds->ds_dir)) { in zfs_ioc_promote()
6166 dsl_dir_phys(ds->ds_dir)->dd_origin_obj, FTAG, &ods); in zfs_ioc_promote()
6187 return (dsl_dataset_promote(zc->zc_name, zc->zc_string)); in zfs_ioc_promote()
6196 * zc_value domain name (eg. "S-1-234-567-89")
6208 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) in zfs_ioc_userspace_one()
6211 error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE); in zfs_ioc_userspace_one()
6216 zc->zc_objset_type, zc->zc_value, zc->zc_guid, &zc->zc_cookie); in zfs_ioc_userspace_one()
6237 int bufsize = zc->zc_nvlist_dst_size; in zfs_ioc_userspace_many()
6242 int error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE); in zfs_ioc_userspace_many()
6248 error = zfs_userspace_many(zfsvfs, zc->zc_objset_type, &zc->zc_cookie, in zfs_ioc_userspace_many()
6249 buf, &zc->zc_nvlist_dst_size); in zfs_ioc_userspace_many()
6253 (void *)(uintptr_t)zc->zc_nvlist_dst, in zfs_ioc_userspace_many()
6254 zc->zc_nvlist_dst_size); in zfs_ioc_userspace_many()
6275 if (getzfsvfs(zc->zc_name, &zfsvfs) == 0) { in zfs_ioc_userspace_upgrade()
6276 if (!dmu_objset_userused_enabled(zfsvfs->z_os)) { in zfs_ioc_userspace_upgrade()
6284 ds = dmu_objset_ds(zfsvfs->z_os); in zfs_ioc_userspace_upgrade()
6293 mutex_enter(&zfsvfs->z_os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6294 if (zfsvfs->z_os->os_upgrade_id == 0) { in zfs_ioc_userspace_upgrade()
6296 zfsvfs->z_os->os_upgrade_status = 0; in zfs_ioc_userspace_upgrade()
6297 mutex_exit(&zfsvfs->z_os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6300 dmu_objset_pool(zfsvfs->z_os), FTAG); in zfs_ioc_userspace_upgrade()
6301 dmu_objset_userspace_upgrade(zfsvfs->z_os); in zfs_ioc_userspace_upgrade()
6303 dmu_objset_pool(zfsvfs->z_os), FTAG); in zfs_ioc_userspace_upgrade()
6305 mutex_exit(&zfsvfs->z_os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6308 taskq_wait_id(zfsvfs->z_os->os_spa->spa_upgrade_taskq, in zfs_ioc_userspace_upgrade()
6309 zfsvfs->z_os->os_upgrade_id); in zfs_ioc_userspace_upgrade()
6310 error = zfsvfs->z_os->os_upgrade_status; in zfs_ioc_userspace_upgrade()
6317 error = dmu_objset_hold_flags(zc->zc_name, B_TRUE, FTAG, &os); in zfs_ioc_userspace_upgrade()
6321 mutex_enter(&os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6322 if (os->os_upgrade_id == 0) { in zfs_ioc_userspace_upgrade()
6324 os->os_upgrade_status = 0; in zfs_ioc_userspace_upgrade()
6325 mutex_exit(&os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6329 mutex_exit(&os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6334 taskq_wait_id(os->os_spa->spa_upgrade_taskq, os->os_upgrade_id); in zfs_ioc_userspace_upgrade()
6335 error = os->os_upgrade_status; in zfs_ioc_userspace_upgrade()
6356 error = dmu_objset_hold_flags(zc->zc_name, B_TRUE, FTAG, &os); in zfs_ioc_id_quota_upgrade()
6362 mutex_enter(&os->os_upgrade_lock); in zfs_ioc_id_quota_upgrade()
6363 if (os->os_upgrade_id == 0) { in zfs_ioc_id_quota_upgrade()
6365 os->os_upgrade_status = 0; in zfs_ioc_id_quota_upgrade()
6366 mutex_exit(&os->os_upgrade_lock); in zfs_ioc_id_quota_upgrade()
6370 mutex_exit(&os->os_upgrade_lock); in zfs_ioc_id_quota_upgrade()
6375 taskq_wait_id(os->os_spa->spa_upgrade_taskq, os->os_upgrade_id); in zfs_ioc_id_quota_upgrade()
6376 error = os->os_upgrade_status; in zfs_ioc_id_quota_upgrade()
6395 * zc_obj object # beyond which we want next in-use object #
6398 * zc_obj next in-use object #
6406 error = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_next_obj()
6410 error = dmu_object_next(os, &zc->zc_obj, B_FALSE, 0); in zfs_ioc_next_obj()
6420 * zc_cleanup_fd cleanup-on-exit file descriptor for calling process
6432 zfs_file_t *fp = zfs_onexit_fd_hold(zc->zc_cleanup_fd, &minor); in zfs_ioc_tmp_snapshot()
6436 snap_name = kmem_asprintf("%s-%016llx", zc->zc_value, in zfs_ioc_tmp_snapshot()
6438 hold_name = kmem_asprintf("%%%s", zc->zc_value); in zfs_ioc_tmp_snapshot()
6440 int error = dsl_dataset_snapshot_tmp(zc->zc_name, snap_name, minor, in zfs_ioc_tmp_snapshot()
6443 (void) strlcpy(zc->zc_value, snap_name, in zfs_ioc_tmp_snapshot()
6444 sizeof (zc->zc_value)); in zfs_ioc_tmp_snapshot()
6467 if ((fp = zfs_file_get(zc->zc_cookie)) == NULL) in zfs_ioc_diff()
6471 error = dmu_diff(zc->zc_name, zc->zc_value, fp, &off); in zfs_ioc_diff()
6486 * "holds" -> { snapname -> holdname (string), ... }
6487 * (optional) "cleanup_fd" -> fd (int32)
6491 * snapname -> error value (int32)
6506 int cleanup_fd = -1; in zfs_ioc_hold()
6544 * holdname -> time added (uint64 seconds since epoch)
6561 * snapname -> { holdname, ... }
6566 * snapname -> error value (int32)
6599 zfs_file_t *fp = zfs_zevent_fd_hold(zc->zc_cleanup_fd, &minor, &ze); in zfs_ioc_events_next()
6605 &zc->zc_nvlist_dst_size, &dropped); in zfs_ioc_events_next()
6607 zc->zc_cookie = dropped; in zfs_ioc_events_next()
6612 if (zc->zc_guid & ZEVENT_NONBLOCK) in zfs_ioc_events_next()
6638 zc->zc_cookie = count; in zfs_ioc_events_clear()
6655 zfs_file_t *fp = zfs_zevent_fd_hold(zc->zc_cleanup_fd, &minor, &ze); in zfs_ioc_events_seek()
6659 error = zfs_zevent_seek(ze, zc->zc_guid); in zfs_ioc_events_seek()
6682 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_space_written()
6685 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &new); in zfs_ioc_space_written()
6690 if (strchr(zc->zc_value, '#') != NULL) { in zfs_ioc_space_written()
6692 error = dsl_bookmark_lookup(dp, zc->zc_value, in zfs_ioc_space_written()
6696 &zc->zc_cookie, in zfs_ioc_space_written()
6697 &zc->zc_objset_type, &zc->zc_perm_action); in zfs_ioc_space_written()
6701 error = dsl_dataset_hold(dp, zc->zc_value, FTAG, &old); in zfs_ioc_space_written()
6705 &zc->zc_cookie, in zfs_ioc_space_written()
6706 &zc->zc_objset_type, &zc->zc_perm_action); in zfs_ioc_space_written()
6717 * "firstsnap" -> snapshot name
6721 * "used" -> space in bytes
6722 * "compressed" -> compressed space in bytes
6723 * "uncompressed" -> uncompressed space in bytes
6746 if (error == 0 && !new->ds_is_snapshot) { in zfs_ioc_space_snaps()
6755 if (error == 0 && !old->ds_is_snapshot) { in zfs_ioc_space_snaps()
6777 * "fd" -> file descriptor to write stream to (int32)
6778 * (optional) "fromsnap" -> full snap name to send an incremental from
6779 * (optional) "largeblockok" -> (value ignored)
6781 * (optional) "embedok" -> (value ignored)
6783 * (optional) "compressok" -> (value ignored)
6785 * (optional) "rawok" -> (value ignored)
6787 * (optional) "savedok" -> (value ignored)
6789 * (optional) "resume_object" and "resume_offset" -> (uint64)
6791 * (optional) "redactbook" -> (string)
6870 * Determine approximately how large a zfs send stream will be -- the number
6874 * (optional) "from" -> full snap or bookmark name to send an incremental
6876 * (optional) "largeblockok" -> (value ignored)
6878 * (optional) "embedok" -> (value ignored)
6880 * (optional) "compressok" -> (value ignored)
6882 * (optional) "rawok" -> (value ignored)
6884 * (optional) "resume_object" and "resume_offset" -> (uint64)
6886 * (optional) "fd" -> file descriptor to use as a cookie for progress
6891 * "space" -> bytes of space (uint64)
6927 int32_t fd = -1; in zfs_ioc_send_space()
6962 * the from-bookmark and tosnap are at the same txg. in zfs_ioc_send_space()
6972 dsl_dataset_phys(tosnap)->ds_guid) in zfs_ioc_send_space()
7026 space -= resume_bytes; in zfs_ioc_send_space()
7045 * "force" -> when true, force uberblock update even if there is no dirty data.
7075 vdev_config_dirty(spa->spa_root_vdev); in zfs_ioc_pool_sync()
7088 * "hidden_args" -> { "wkeydata" -> value }
7090 * (optional) "noop" -> (value ignored)
7166 * "hidden_args" (optional) -> { "wkeydata" -> value }
7168 * "props" (optional) -> { prop -> value }
7214 static zfs_ioc_vec_t zfs_ioc_vec[ZFS_IOC_LAST - ZFS_IOC_FIRST];
7221 zfs_ioc_vec_t *vec = &zfs_ioc_vec[ioc - ZFS_IOC_FIRST]; in zfs_ioctl_register_legacy()
7225 ASSERT3P(vec->zvec_legacy_func, ==, NULL); in zfs_ioctl_register_legacy()
7226 ASSERT3P(vec->zvec_func, ==, NULL); in zfs_ioctl_register_legacy()
7228 vec->zvec_legacy_func = func; in zfs_ioctl_register_legacy()
7229 vec->zvec_secpolicy = secpolicy; in zfs_ioctl_register_legacy()
7230 vec->zvec_namecheck = namecheck; in zfs_ioctl_register_legacy()
7231 vec->zvec_allow_log = log_history; in zfs_ioctl_register_legacy()
7232 vec->zvec_pool_check = pool_check; in zfs_ioctl_register_legacy()
7245 zfs_ioc_vec_t *vec = &zfs_ioc_vec[ioc - ZFS_IOC_FIRST]; in zfs_ioctl_register()
7249 ASSERT3P(vec->zvec_legacy_func, ==, NULL); in zfs_ioctl_register()
7250 ASSERT3P(vec->zvec_func, ==, NULL); in zfs_ioctl_register()
7255 vec->zvec_name = name; in zfs_ioctl_register()
7256 vec->zvec_func = func; in zfs_ioctl_register()
7257 vec->zvec_secpolicy = secpolicy; in zfs_ioctl_register()
7258 vec->zvec_namecheck = namecheck; in zfs_ioctl_register()
7259 vec->zvec_pool_check = pool_check; in zfs_ioctl_register()
7260 vec->zvec_smush_outnvlist = smush_outnvlist; in zfs_ioctl_register()
7261 vec->zvec_allow_log = allow_log; in zfs_ioctl_register()
7262 vec->zvec_nvl_keys = nvl_keys; in zfs_ioctl_register()
7263 vec->zvec_nvl_key_count = num_keys; in zfs_ioctl_register()
7414 zfs_ioctl_register("load-key", ZFS_IOC_LOAD_KEY, in zfs_ioctl_init()
7418 zfs_ioctl_register("unload-key", ZFS_IOC_UNLOAD_KEY, in zfs_ioctl_init()
7422 zfs_ioctl_register("change-key", ZFS_IOC_CHANGE_KEY, in zfs_ioctl_init()
7660 * Verify that for non-legacy ioctls the input nvlist
7671 const zfs_ioc_key_t *nvl_keys = vec->zvec_nvl_keys; in zfs_check_input_nvpairs()
7686 for (int k = 0; k < vec->zvec_nvl_key_count; k++) { in zfs_check_input_nvpairs()
7715 for (int k = 0; k < vec->zvec_nvl_key_count; k++) { in zfs_check_input_nvpairs()
7720 /* at least one non-optional key is expected here */ in zfs_check_input_nvpairs()
7770 for (zs = &zfsdev_state_listhead; zs != NULL; zs = zs->zs_next) { in zfsdev_getminor()
7772 if (zs->zs_minor == -1) in zfsdev_getminor()
7776 *minorp = fpd->zs_minor; in zfsdev_getminor()
7792 for (zs = &zfsdev_state_listhead; zs != NULL; zs = zs->zs_next) { in zfsdev_get_state()
7793 if (zs->zs_minor == minor) { in zfsdev_get_state()
7797 return (zs->zs_onexit); in zfsdev_get_state()
7799 return (zs->zs_zevent); in zfsdev_get_state()
7846 for (zs = &zfsdev_state_listhead; zs != NULL; zs = zs->zs_next) { in zfsdev_state_init()
7847 if (zs->zs_minor == -1) in zfsdev_state_init()
7859 zfs_onexit_init((zfs_onexit_t **)&zs->zs_onexit); in zfsdev_state_init()
7860 zfs_zevent_init((zfs_zevent_t **)&zs->zs_zevent); in zfsdev_state_init()
7863 * In order to provide for lock-free concurrent read access in zfsdev_state_init()
7867 * operation must be updating zs_minor (from -1 to the new in zfsdev_state_init()
7871 zs->zs_minor = minor; in zfsdev_state_init()
7873 zsprev->zs_next = zs; in zfsdev_state_init()
7876 zs->zs_minor = minor; in zfsdev_state_init()
7888 ASSERT3S(zs->zs_minor, >, 0); in zfsdev_state_destroy()
7894 * invalidated by setting zs_minor to -1. Invalidation must be done in zfsdev_state_destroy()
7898 zfs_onexit_destroy(zs->zs_onexit); in zfsdev_state_destroy()
7899 zfs_zevent_destroy(zs->zs_zevent); in zfsdev_state_destroy()
7900 zs->zs_onexit = NULL; in zfsdev_state_destroy()
7901 zs->zs_zevent = NULL; in zfsdev_state_destroy()
7903 zs->zs_minor = -1; in zfsdev_state_destroy()
7929 if (vec->zvec_func == NULL && vec->zvec_legacy_func == NULL) in zfsdev_ioctl_common()
7932 zc->zc_iflags = flag & FKIOCTL; in zfsdev_ioctl_common()
7934 if (zc->zc_nvlist_src_size > max_nvlist_src_size) { in zfsdev_ioctl_common()
7950 } else if (zc->zc_nvlist_src_size != 0) { in zfsdev_ioctl_common()
7951 error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfsdev_ioctl_common()
7952 zc->zc_iflags, &innvl); in zfsdev_ioctl_common()
7961 zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; in zfsdev_ioctl_common()
7962 switch (vec->zvec_namecheck) { in zfsdev_ioctl_common()
7964 if (pool_namecheck(zc->zc_name, NULL, NULL) != 0) in zfsdev_ioctl_common()
7967 error = pool_status_check(zc->zc_name, in zfsdev_ioctl_common()
7968 vec->zvec_namecheck, vec->zvec_pool_check); in zfsdev_ioctl_common()
7972 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0) in zfsdev_ioctl_common()
7975 error = pool_status_check(zc->zc_name, in zfsdev_ioctl_common()
7976 vec->zvec_namecheck, vec->zvec_pool_check); in zfsdev_ioctl_common()
7980 if (entity_namecheck(zc->zc_name, NULL, NULL) != 0) { in zfsdev_ioctl_common()
7983 error = pool_status_check(zc->zc_name, in zfsdev_ioctl_common()
7984 vec->zvec_namecheck, vec->zvec_pool_check); in zfsdev_ioctl_common()
7999 if (error == 0 && vec->zvec_func != NULL) { in zfsdev_ioctl_common()
8007 error = vec->zvec_secpolicy(zc, innvl, CRED()); in zfsdev_ioctl_common()
8019 saved_poolname_len = strlen(zc->zc_name) + 1; in zfsdev_ioctl_common()
8022 strlcpy(saved_poolname, zc->zc_name, saved_poolname_len); in zfsdev_ioctl_common()
8025 if (vec->zvec_func != NULL) { in zfsdev_ioctl_common()
8031 ASSERT(vec->zvec_legacy_func == NULL); in zfsdev_ioctl_common()
8037 if (vec->zvec_allow_log) { in zfsdev_ioctl_common()
8040 vec->zvec_name); in zfsdev_ioctl_common()
8049 error = vec->zvec_func(zc->zc_name, innvl, outnvl); in zfsdev_ioctl_common()
8059 vec->zvec_allow_log && in zfsdev_ioctl_common()
8060 spa_open(zc->zc_name, &spa, FTAG) == 0) { in zfsdev_ioctl_common()
8076 gethrtime() - start_time); in zfsdev_ioctl_common()
8082 if (!nvlist_empty(outnvl) || zc->zc_nvlist_dst_size != 0) { in zfsdev_ioctl_common()
8084 if (vec->zvec_smush_outnvlist) { in zfsdev_ioctl_common()
8086 zc->zc_nvlist_dst_size); in zfsdev_ioctl_common()
8098 error = vec->zvec_legacy_func(zc); in zfsdev_ioctl_common()
8104 if (error == 0 && vec->zvec_allow_log) { in zfsdev_ioctl_common()
8130 zfsdev_state_listhead.zs_minor = -1; in zfs_kmod_init()
8157 zsnext = zs->zs_next; in zfs_kmod_fini()
8158 if (zs->zs_onexit) in zfs_kmod_fini()
8159 zfs_onexit_destroy(zs->zs_onexit); in zfs_kmod_fini()
8160 if (zs->zs_zevent) in zfs_kmod_fini()
8161 zfs_zevent_destroy(zs->zs_zevent); in zfs_kmod_fini()