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()
1735 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_pool_freeze()
1749 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_pool_upgrade()
1752 if (zc->zc_cookie < spa_version(spa) || in zfs_ioc_pool_upgrade()
1753 !SPA_VERSION_IS_SUPPORTED(zc->zc_cookie)) { in zfs_ioc_pool_upgrade()
1758 spa_upgrade(spa, zc->zc_cookie); in zfs_ioc_pool_upgrade()
1772 if ((size = zc->zc_history_len) == 0) in zfs_ioc_pool_get_history()
1775 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_pool_get_history()
1784 if ((error = spa_history_get(spa, &zc->zc_history_offset, in zfs_ioc_pool_get_history()
1785 &zc->zc_history_len, hist_buf)) == 0) { in zfs_ioc_pool_get_history()
1787 (void *)(uintptr_t)zc->zc_history, in zfs_ioc_pool_get_history()
1788 zc->zc_history_len, zc->zc_iflags); in zfs_ioc_pool_get_history()
1810 if (zc->zc_nvlist_src_size != 0) { in zfs_ioc_pool_reguid()
1811 error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_pool_reguid()
1812 zc->zc_iflags, &props); in zfs_ioc_pool_reguid()
1825 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_pool_reguid()
1841 return (dsl_dsobj_to_dsname(zc->zc_name, zc->zc_obj, zc->zc_value)); in zfs_ioc_dsobj_to_dsname()
1859 if ((error = dmu_objset_hold_flags(zc->zc_name, B_TRUE, in zfs_ioc_obj_to_path()
1866 error = zfs_obj_to_path(os, zc->zc_obj, zc->zc_value, in zfs_ioc_obj_to_path()
1867 sizeof (zc->zc_value)); in zfs_ioc_obj_to_path()
1889 if ((error = dmu_objset_hold_flags(zc->zc_name, B_TRUE, in zfs_ioc_obj_to_stats()
1896 error = zfs_obj_to_stats(os, zc->zc_obj, &zc->zc_stat, zc->zc_value, in zfs_ioc_obj_to_stats()
1897 sizeof (zc->zc_value)); in zfs_ioc_obj_to_stats()
1910 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_vdev_add()
1914 error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_vdev_add()
1915 zc->zc_iflags, &config); in zfs_ioc_vdev_add()
1917 error = spa_vdev_add(spa, config, zc->zc_flags); in zfs_ioc_vdev_add()
1936 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_vdev_remove()
1939 if (zc->zc_cookie != 0) { in zfs_ioc_vdev_remove()
1942 error = spa_vdev_remove(spa, zc->zc_guid, B_FALSE); in zfs_ioc_vdev_remove()
1955 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_vdev_set_state()
1957 switch (zc->zc_cookie) { in zfs_ioc_vdev_set_state()
1959 error = vdev_online(spa, zc->zc_guid, zc->zc_obj, &newstate); in zfs_ioc_vdev_set_state()
1963 error = vdev_offline(spa, zc->zc_guid, zc->zc_obj); in zfs_ioc_vdev_set_state()
1967 if (zc->zc_obj != VDEV_AUX_ERR_EXCEEDED && in zfs_ioc_vdev_set_state()
1968 zc->zc_obj != VDEV_AUX_EXTERNAL && in zfs_ioc_vdev_set_state()
1969 zc->zc_obj != VDEV_AUX_EXTERNAL_PERSIST) in zfs_ioc_vdev_set_state()
1970 zc->zc_obj = VDEV_AUX_ERR_EXCEEDED; in zfs_ioc_vdev_set_state()
1972 error = vdev_fault(spa, zc->zc_guid, zc->zc_obj); in zfs_ioc_vdev_set_state()
1976 if (zc->zc_obj != VDEV_AUX_ERR_EXCEEDED && in zfs_ioc_vdev_set_state()
1977 zc->zc_obj != VDEV_AUX_EXTERNAL) in zfs_ioc_vdev_set_state()
1978 zc->zc_obj = VDEV_AUX_ERR_EXCEEDED; in zfs_ioc_vdev_set_state()
1980 error = vdev_degrade(spa, zc->zc_guid, zc->zc_obj); in zfs_ioc_vdev_set_state()
1984 error = vdev_remove_wanted(spa, zc->zc_guid); in zfs_ioc_vdev_set_state()
1990 zc->zc_cookie = newstate; in zfs_ioc_vdev_set_state()
2000 int replacing = zc->zc_cookie; in zfs_ioc_vdev_attach()
2001 int rebuild = zc->zc_simple; in zfs_ioc_vdev_attach()
2004 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_vdev_attach()
2007 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_vdev_attach()
2008 zc->zc_iflags, &config)) == 0) { in zfs_ioc_vdev_attach()
2009 error = spa_vdev_attach(spa, zc->zc_guid, config, replacing, in zfs_ioc_vdev_attach()
2024 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_vdev_detach()
2027 error = spa_vdev_detach(spa, zc->zc_guid, 0, B_FALSE); in zfs_ioc_vdev_detach()
2039 boolean_t exp = !!(zc->zc_cookie & ZPOOL_EXPORT_AFTER_SPLIT); in zfs_ioc_vdev_split()
2041 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_vdev_split()
2044 if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_vdev_split()
2045 zc->zc_iflags, &config))) { in zfs_ioc_vdev_split()
2050 if (zc->zc_nvlist_src_size != 0 && (error = in zfs_ioc_vdev_split()
2051 get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_vdev_split()
2052 zc->zc_iflags, &props))) { in zfs_ioc_vdev_split()
2058 error = spa_vdev_split_mirror(spa, zc->zc_string, config, props, exp); in zfs_ioc_vdev_split()
2072 const char *path = zc->zc_value; in zfs_ioc_vdev_setpath()
2073 uint64_t guid = zc->zc_guid; in zfs_ioc_vdev_setpath()
2076 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_vdev_setpath()
2089 const char *fru = zc->zc_value; in zfs_ioc_vdev_setfru()
2090 uint64_t guid = zc->zc_guid; in zfs_ioc_vdev_setfru()
2093 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_vdev_setfru()
2108 dmu_objset_fast_stat(os, &zc->zc_objset_stats); in zfs_ioc_objset_stats_impl()
2110 if (!zc->zc_simple && zc->zc_nvlist_dst != 0 && in zfs_ioc_objset_stats_impl()
2120 if (!zc->zc_objset_stats.dds_inconsistent && in zfs_ioc_objset_stats_impl()
2153 error = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_objset_stats()
2186 if (!dsl_prop_get_hasrecvd(zc->zc_name)) in zfs_ioc_objset_recvd_props()
2189 if (zc->zc_nvlist_dst != 0 && in zfs_ioc_objset_recvd_props()
2190 (error = dsl_prop_get_received(zc->zc_name, &nv)) == 0) { in zfs_ioc_objset_recvd_props()
2230 if ((err = dmu_objset_hold(zc->zc_name, FTAG, &os))) in zfs_ioc_objset_zplprops()
2233 dmu_objset_fast_stat(os, &zc->zc_objset_stats); in zfs_ioc_objset_zplprops()
2240 if (zc->zc_nvlist_dst != 0 && in zfs_ioc_objset_zplprops()
2241 !zc->zc_objset_stats.dds_inconsistent && in zfs_ioc_objset_zplprops()
2278 size_t orig_len = strlen(zc->zc_name); in zfs_ioc_dataset_list_next()
2281 if ((error = dmu_objset_hold(zc->zc_name, FTAG, &os))) { in zfs_ioc_dataset_list_next()
2287 p = strrchr(zc->zc_name, '/'); in zfs_ioc_dataset_list_next()
2289 (void) strlcat(zc->zc_name, "/", sizeof (zc->zc_name)); in zfs_ioc_dataset_list_next()
2290 p = zc->zc_name + strlen(zc->zc_name); in zfs_ioc_dataset_list_next()
2294 sizeof (zc->zc_name) - (p - zc->zc_name), p, in zfs_ioc_dataset_list_next()
2295 NULL, &zc->zc_cookie); in zfs_ioc_dataset_list_next()
2298 } while (error == 0 && zfs_dataset_name_hidden(zc->zc_name)); in zfs_ioc_dataset_list_next()
2305 if (error == 0 && strchr(zc->zc_name, '$') == NULL) { in zfs_ioc_dataset_list_next()
2309 zc->zc_name[orig_len] = '\0'; in zfs_ioc_dataset_list_next()
2337 if (zc->zc_nvlist_src_size != 0) { in zfs_ioc_snapshot_list_next()
2339 error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_snapshot_list_next()
2340 zc->zc_iflags, &props); in zfs_ioc_snapshot_list_next()
2350 error = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_snapshot_list_next()
2359 if (strlcat(zc->zc_name, "@", sizeof (zc->zc_name)) >= in zfs_ioc_snapshot_list_next()
2372 sizeof (zc->zc_name) - strlen(zc->zc_name), in zfs_ioc_snapshot_list_next()
2373 zc->zc_name + strlen(zc->zc_name), &zc->zc_obj, in zfs_ioc_snapshot_list_next()
2374 &zc->zc_cookie, NULL); in zfs_ioc_snapshot_list_next()
2382 error = dsl_dataset_hold_obj(dmu_objset_pool(os), zc->zc_obj, in zfs_ioc_snapshot_list_next()
2391 *(strchr(zc->zc_name, '@') + 1) = '\0'; in zfs_ioc_snapshot_list_next()
2396 if (zc->zc_simple) { in zfs_ioc_snapshot_list_next()
2397 dsl_dataset_fast_stat(ds, &zc->zc_objset_stats); in zfs_ioc_snapshot_list_next()
2417 *strchr(zc->zc_name, '@') = '\0'; in zfs_ioc_snapshot_list_next()
2444 * userquota@<rid>-<domain>. in zfs_prop_set_userquota()
2446 if ((dash = strchr(propname, '-')) == NULL || in zfs_prop_set_userquota()
2468 * not one of the special properties handled by this function, return -1.
2481 int err = -1; in zfs_prop_set_special()
2486 return (-1); in zfs_prop_set_special()
2519 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2523 err = -1; in zfs_prop_set_special()
2529 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2533 err = -1; in zfs_prop_set_special()
2544 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2548 err = -1; in zfs_prop_set_special()
2556 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2560 err = -1; in zfs_prop_set_special()
2569 * Set err to -1 to force the zfs_set_prop_nvlist code down the in zfs_prop_set_special()
2573 err = -1; in zfs_prop_set_special()
2589 (void) strlcpy(zc->zc_name, dsname, in zfs_prop_set_special()
2590 sizeof (zc->zc_name)); in zfs_prop_set_special()
2609 err = -1; in zfs_prop_set_special()
2619 if (!spa_feature_is_enabled(zfsvfs->z_os->os_spa, in zfs_prop_set_special()
2624 * Set err to -1 to force the zfs_set_prop_nvlist code in zfs_prop_set_special()
2627 err = -1; in zfs_prop_set_special()
2633 err = -1; in zfs_prop_set_special()
2662 * encountered. If the caller provides a non-NULL errlist, it will be filled in
2752 err = -1; /* does not need special handling */ in zfs_set_prop_nvlist()
2756 if (err == -1) { in zfs_set_prop_nvlist()
2916 boolean_t received = zc->zc_cookie; in zfs_ioc_set_prop()
2922 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_set_prop()
2923 zc->zc_iflags, &nvl)) != 0) in zfs_ioc_set_prop()
2929 if (dsl_prop_get_received(zc->zc_name, &origprops) == 0) { in zfs_ioc_set_prop()
2930 (void) clear_received_props(zc->zc_name, in zfs_ioc_set_prop()
2935 error = dsl_prop_set_hasrecvd(zc->zc_name); in zfs_ioc_set_prop()
2940 error = zfs_set_prop_nvlist(zc->zc_name, source, nvl, errors); in zfs_ioc_set_prop()
2942 if (zc->zc_nvlist_dst != 0 && errors != NULL) { in zfs_ioc_set_prop()
2962 const char *propname = zc->zc_value; in zfs_ioc_inherit_prop()
2964 boolean_t received = zc->zc_cookie; in zfs_ioc_inherit_prop()
2975 * Only check this in the non-received case. We want to allow in zfs_ioc_inherit_prop()
2976 * 'inherit -S' to revert non-inheritable properties like quota in zfs_ioc_inherit_prop()
3018 err = zfs_prop_set_special(zc->zc_name, source, pair); in zfs_ioc_inherit_prop()
3019 if (err == -1) /* property is not "special", needs handling */ in zfs_ioc_inherit_prop()
3020 err = dsl_prop_inherit(zc->zc_name, zc->zc_value, in zfs_ioc_inherit_prop()
3037 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_pool_set_props()
3038 zc->zc_iflags, &props))) in zfs_ioc_pool_set_props()
3050 if ((spa = spa_lookup(zc->zc_name)) != NULL) { in zfs_ioc_pool_set_props()
3061 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) { in zfs_ioc_pool_set_props()
3124 * "vdevprops_set_vdev" -> guid
3125 * "vdevprops_set_props" -> { prop -> value }
3128 * outnvl: propname -> error code (int32)
3140 vdev_t *vd; in zfs_ioc_vdev_set_props() local
3156 if ((vd = spa_lookup_by_guid(spa, vdev_guid, B_TRUE)) == NULL) { in zfs_ioc_vdev_set_props()
3161 error = vdev_prop_set(vd, innvl, outnvl); in zfs_ioc_vdev_set_props()
3170 * "vdevprops_get_vdev" -> guid
3171 * (optional) "vdevprops_get_props" -> { propname -> propid }
3174 * outnvl: propname -> value
3186 vdev_t *vd; in zfs_ioc_vdev_get_props() local
3200 if ((vd = spa_lookup_by_guid(spa, vdev_guid, B_TRUE)) == NULL) { in zfs_ioc_vdev_get_props()
3205 error = vdev_prop_get(vd, innvl, outnvl); in zfs_ioc_vdev_get_props()
3226 if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_set_fsacl()
3227 zc->zc_iflags, &fsaclnv)) != 0) in zfs_ioc_set_fsacl()
3246 if (zc->zc_perm_action == B_FALSE) { in zfs_ioc_set_fsacl()
3247 error = dsl_deleg_can_allow(zc->zc_name, in zfs_ioc_set_fsacl()
3250 error = dsl_deleg_can_unallow(zc->zc_name, in zfs_ioc_set_fsacl()
3256 error = dsl_deleg_set(zc->zc_name, fsaclnv, zc->zc_perm_action); in zfs_ioc_set_fsacl()
3275 if ((error = dsl_deleg_get(zc->zc_name, &nvp)) == 0) { in zfs_ioc_get_fsacl()
3288 zfs_create_fs(os, cr, zct->zct_zplprops, tx); in zfs_create_cb()
3291 #define ZFS_PROP_UNDEFINED ((uint64_t)-1)
3302 * is_ci true if requested file system will be purely case-insensitive
3326 if (os != NULL && os->os_phys->os_type != DMU_OST_ZFS) in zfs_fill_zplprops_impl()
3376 * If we're normalizing, names must always be valid UTF-8 strings. in zfs_fill_zplprops_impl()
3454 * "type" -> dmu_objset_type_t (int32)
3455 * (optional) "props" -> { prop -> value }
3456 * (optional) "hidden_args" -> { "wkeydata" -> value }
3460 * outnvl: propname -> error code (int32)
3535 * case-folding flags correct when we do the in zfs_ioc_create()
3582 taskq_wait(spa->spa_zvol_taskq); in zfs_ioc_create()
3594 * "origin" -> name of origin snapshot
3595 * (optional) "props" -> { prop -> value }
3596 * (optional) "hidden_args" -> { "wkeydata" -> value }
3601 * outnvl: propname -> error code (int32)
3654 * "snaps" -> { snapshot1, snapshot2 }
3655 * (optional) "props" -> { prop -> value (string) }
3658 * outnvl: snapshot -> error code (int32)
3717 if (strncmp(name, nvpair_name(pair2), cp - name + 1) in zfs_ioc_snapshot()
3730 * innvl: "message" -> string
3798 error = vdev_label_write_bootenv(spa->spa_root_vdev, innvl); in zfs_ioc_set_bootenv()
3817 error = vdev_label_read_bootenv(spa->spa_root_vdev, outnvl); in zfs_ioc_get_bootenv()
3827 * This function is best-effort. Callers must deal gracefully if it
3866 if (dsl_dir_is_clone(ds->ds_dir) && DS_IS_DEFER_DESTROY(ds->ds_prev)) { in zfs_destroy_unmount_origin()
3868 dsl_dataset_name(ds->ds_prev, originname); in zfs_destroy_unmount_origin()
3878 * "snaps" -> { snapshot1, snapshot2 }
3882 * outnvl: snapshot -> error code (int32)
3930 * new_bookmark1 -> existing_snapshot,
3931 * new_bookmark2 -> existing_bookmark,
3934 * outnvl: bookmark -> error code (int32)
3954 * bookmark name 1 -> { property 1, property 2, ... },
3955 * bookmark name 2 -> { property 1, property 2, ... }
4005 * outnvl: bookmark -> error code (int32)
4117 * "prefetch_type" -> int32_t
4151 zfs_dbgmsg("pool '%s': loaded ddt into ARC in %llu ms", spa->spa_name, in zfs_ioc_pool_prefetch()
4152 (u_longlong_t)NSEC2MSEC(gethrtime() - start_time)); in zfs_ioc_pool_prefetch()
4173 err = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_destroy()
4180 zfs_unmount_snap(zc->zc_name); in zfs_ioc_destroy()
4182 if (strchr(zc->zc_name, '@')) { in zfs_ioc_destroy()
4183 err = dsl_destroy_snapshot(zc->zc_name, zc->zc_defer_destroy); in zfs_ioc_destroy()
4185 err = dsl_destroy_head(zc->zc_name); in zfs_ioc_destroy()
4189 * hidden child (%recv) datasets - "leftovers" in zfs_ioc_destroy()
4198 zc->zc_name, recv_clone_name) >= in zfs_ioc_destroy()
4210 err = dsl_destroy_head(zc->zc_name); in zfs_ioc_destroy()
4221 * "initialize_command" -> POOL_INITIALIZE_{CANCEL|START|SUSPEND} (uint64)
4222 * "initialize_vdevs": { -> guids to initialize (nvlist)
4230 * "initialize_vdevs": { -> initialization errors (nvlist)
4296 * "trim_command" -> POOL_TRIM_{CANCEL|START|SUSPEND} (uint64)
4297 * "trim_vdevs": { -> guids to TRIM (nvlist)
4302 * "trim_rate" -> Target TRIM rate in bytes/sec.
4303 * "trim_secure" -> Set to request a secure TRIM.
4307 * "trim_vdevs": { -> TRIM errors (nvlist)
4384 * "ddt_prune_unit" -> uint32_t
4385 * "ddt_prune_amount" -> uint64_t
4388 * outnvl: "waited" -> boolean_t
4441 * "wait_activity" -> int32_t
4442 * (optional) "wait_tag" -> uint64_t
4445 * outnvl: "waited" -> boolean_t
4485 * "wait_activity" -> int32_t
4488 * outnvl: "waited" -> boolean_t
4518 dd = ds->ds_dir; in zfs_ioc_wait_fs()
4519 mutex_enter(&dd->dd_activity_lock); in zfs_ioc_wait_fs()
4520 dd->dd_activity_waiters++; in zfs_ioc_wait_fs()
4523 * We get a long-hold here so that the dsl_dataset_t and dsl_dir_t in zfs_ioc_wait_fs()
4527 * of long-holds (e.g. preventing deletion) is unnecessary for this in zfs_ioc_wait_fs()
4538 dd->dd_activity_waiters--; in zfs_ioc_wait_fs()
4539 if (dd->dd_activity_waiters == 0) in zfs_ioc_wait_fs()
4540 cv_signal(&dd->dd_activity_cv); in zfs_ioc_wait_fs()
4541 mutex_exit(&dd->dd_activity_lock); in zfs_ioc_wait_fs()
4556 * outnvl: "target" -> name of most recent snapshot
4587 ds = dmu_objset_ds(zfsvfs->z_os); in zfs_ioc_rollback()
4625 * "bookname" -> (string)
4627 * "snapnv" -> (nvlist, values ignored)
4669 boolean_t recursive = zc->zc_cookie & 1; in zfs_ioc_rename()
4670 boolean_t nounmount = !!(zc->zc_cookie & 2); in zfs_ioc_rename()
4675 zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; in zfs_ioc_rename()
4676 zc->zc_value[sizeof (zc->zc_value) - 1] = '\0'; in zfs_ioc_rename()
4677 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 || in zfs_ioc_rename()
4678 dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || in zfs_ioc_rename()
4679 strchr(zc->zc_name, '%') || strchr(zc->zc_value, '%')) in zfs_ioc_rename()
4682 err = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_rename()
4688 at = strchr(zc->zc_name, '@'); in zfs_ioc_rename()
4693 if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1)) in zfs_ioc_rename()
4697 error = dmu_objset_find(zc->zc_name, in zfs_ioc_rename()
4705 error = dsl_dataset_rename_snapshot(zc->zc_name, in zfs_ioc_rename()
4706 at + 1, strchr(zc->zc_value, '@') + 1, recursive); in zfs_ioc_rename()
4711 return (dsl_dir_rename(zc->zc_name, zc->zc_value)); in zfs_ioc_rename()
4766 /* {USER|GROUP|PROJECT}USED are read-only */ in zfs_check_settable()
4964 * caller provides a non-NULL errlist, it also gives the complete list of names
4986 (void) strlcpy(zc->zc_name, dataset, sizeof (zc->zc_name)); in zfs_check_clearable()
4991 (void) strlcpy(zc->zc_value, nvpair_name(pair), in zfs_check_clearable()
4992 sizeof (zc->zc_value)); in zfs_check_clearable()
4997 zc->zc_value, err) == 0); in zfs_check_clearable()
5092 * refquota pre-receipt will set the dsl's ACTUAL quota, which will prevent
5273 /* -x property */ in zfs_ioc_recv_impl()
5283 /* -o property=value */ in zfs_ioc_recv_impl()
5310 begin_record->drr_u.drr_begin. in zfs_ioc_recv_impl()
5313 ds = dmu_objset_ds(zfsvfs->z_os); in zfs_ioc_recv_impl()
5376 *read_bytes = off - noff; in zfs_ioc_recv_impl()
5409 * first new-style receive. in zfs_ioc_recv_impl()
5517 if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || in zfs_ioc_recv()
5518 strchr(zc->zc_value, '@') == NULL || in zfs_ioc_recv()
5519 strchr(zc->zc_value, '%') != NULL) { in zfs_ioc_recv()
5523 (void) strlcpy(tofs, zc->zc_value, sizeof (tofs)); in zfs_ioc_recv()
5527 if (zc->zc_nvlist_src != 0 && in zfs_ioc_recv()
5528 (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfs_ioc_recv()
5529 zc->zc_iflags, &recvdprops)) != 0) { in zfs_ioc_recv()
5533 if (zc->zc_nvlist_conf != 0 && in zfs_ioc_recv()
5534 (error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size, in zfs_ioc_recv()
5535 zc->zc_iflags, &localprops)) != 0) { in zfs_ioc_recv()
5539 if (zc->zc_string[0]) in zfs_ioc_recv()
5540 origin = zc->zc_string; in zfs_ioc_recv()
5544 begin_record.drr_u.drr_begin = zc->zc_begin_record; in zfs_ioc_recv()
5547 NULL, zc->zc_guid, B_FALSE, B_FALSE, zc->zc_cookie, &begin_record, in zfs_ioc_recv()
5548 &zc->zc_cookie, &zc->zc_obj, &errors); in zfs_ioc_recv()
5554 if (zc->zc_nvlist_dst_size != 0 && errors != NULL && in zfs_ioc_recv()
5555 (nvlist_smush(errors, zc->zc_nvlist_dst_size) != 0 || in zfs_ioc_recv()
5558 * Caller made zc->zc_nvlist_dst less than the minimum expected in zfs_ioc_recv()
5574 * "snapname" -> full name of the snapshot to create
5575 * (optional) "props" -> received properties to set (nvlist)
5576 * (optional) "localprops" -> override and exclude properties (nvlist)
5577 * (optional) "origin" -> name of clone origin (DRR_FLAG_CLONE)
5578 * "begin_record" -> non-byteswapped dmu_replay_record_t
5579 * "input_fd" -> file descriptor to read stream from (int32)
5580 * (optional) "force" -> force flag (value ignored)
5581 * (optional) "heal" -> use send stream to heal data corruption
5582 * (optional) "resumable" -> resumable flag (value ignored)
5583 * (optional) "cleanup_fd" -> unused
5584 * (optional) "action_handle" -> unused
5585 * (optional) "hidden_args" -> { "wkeydata" -> value }
5589 * "read_bytes" -> number of bytes read
5590 * "error_flags" -> zprop_errflags_t
5591 * "errors" -> error for each unapplied received property (nvlist)
5627 int input_fd = -1; in zfs_ioc_recv_new()
5709 fp = dbi->dbi_fp; in dump_bytes_cb()
5710 buf = dbi->dbi_buf; in dump_bytes_cb()
5712 dbi->dbi_err = zfs_file_write(fp, buf, dbi->dbi_len, NULL); in dump_bytes_cb()
5729 dbi.dbi_fp = dba->dba_fp; in dump_bytes()
5734 taskq_dispatch_ent(dba->dba_tq, dump_bytes_cb, &dbi, TQ_SLEEP, in dump_bytes()
5735 &dba->dba_tqent); in dump_bytes()
5736 taskq_wait(dba->dba_tq); in dump_bytes()
5751 dba->dba_fp = fp; in dump_bytes_init()
5753 dba->dba_tq = taskq_create("z_send", 1, defclsyspri, 0, 0, 0); in dump_bytes_init()
5754 taskq_init_ent(&dba->dba_tqent); in dump_bytes_init()
5758 out->dso_outfunc = dump_bytes; in dump_bytes_init()
5759 out->dso_arg = dba; in dump_bytes_init()
5760 out->dso_dryrun = B_FALSE; in dump_bytes_init()
5768 zfs_file_put(dba->dba_fp); in dump_bytes_fini()
5770 taskq_destroy(dba->dba_tq); in dump_bytes_fini()
5796 boolean_t estimate = (zc->zc_guid != 0); in zfs_ioc_send()
5797 boolean_t embedok = (zc->zc_flags & 0x1); in zfs_ioc_send()
5798 boolean_t large_block_ok = (zc->zc_flags & 0x2); in zfs_ioc_send()
5799 boolean_t compressok = (zc->zc_flags & 0x4); in zfs_ioc_send()
5800 boolean_t rawok = (zc->zc_flags & 0x8); in zfs_ioc_send()
5801 boolean_t savedok = (zc->zc_flags & 0x10); in zfs_ioc_send()
5803 if (zc->zc_obj != 0) { in zfs_ioc_send()
5807 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_send()
5811 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &tosnap); in zfs_ioc_send()
5817 if (dsl_dir_is_clone(tosnap->ds_dir)) in zfs_ioc_send()
5818 zc->zc_fromobj = in zfs_ioc_send()
5819 dsl_dir_phys(tosnap->ds_dir)->dd_origin_obj; in zfs_ioc_send()
5829 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_send()
5833 error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, in zfs_ioc_send()
5840 if (zc->zc_fromobj != 0) { in zfs_ioc_send()
5841 error = dsl_dataset_hold_obj(dp, zc->zc_fromobj, in zfs_ioc_send()
5851 compressok || rawok, savedok, &zc->zc_objset_type); in zfs_ioc_send()
5860 error = dump_bytes_init(&dba, zc->zc_cookie, &out); in zfs_ioc_send()
5865 error = dmu_send_obj(zc->zc_name, zc->zc_sendobj, in zfs_ioc_send()
5866 zc->zc_fromobj, embedok, large_block_ok, compressok, in zfs_ioc_send()
5867 rawok, savedok, zc->zc_cookie, &off, &out); in zfs_ioc_send()
5891 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_send_progress()
5895 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &ds); in zfs_ioc_send_progress()
5901 mutex_enter(&ds->ds_sendstream_lock); in zfs_ioc_send_progress()
5910 for (dsp = list_head(&ds->ds_sendstreams); dsp != NULL; in zfs_ioc_send_progress()
5911 dsp = list_next(&ds->ds_sendstreams, dsp)) { in zfs_ioc_send_progress()
5912 if (dsp->dss_outfd == zc->zc_cookie && in zfs_ioc_send_progress()
5913 zfs_proc_is_caller(dsp->dss_proc)) in zfs_ioc_send_progress()
5918 zc->zc_cookie = atomic_cas_64((volatile uint64_t *)dsp->dss_off, in zfs_ioc_send_progress()
5921 zc->zc_objset_type = atomic_cas_64(&dsp->dss_blocks, 0, 0); in zfs_ioc_send_progress()
5926 mutex_exit(&ds->ds_sendstream_lock); in zfs_ioc_send_progress()
5937 error = zio_inject_fault(zc->zc_name, (int)zc->zc_guid, &id, in zfs_ioc_inject_fault()
5938 &zc->zc_inject_record); in zfs_ioc_inject_fault()
5941 zc->zc_guid = (uint64_t)id; in zfs_ioc_inject_fault()
5949 return (zio_clear_fault((int)zc->zc_guid)); in zfs_ioc_clear_fault()
5955 int id = (int)zc->zc_guid; in zfs_ioc_inject_list_next()
5958 error = zio_inject_list_next(&id, zc->zc_name, sizeof (zc->zc_name), in zfs_ioc_inject_list_next()
5959 &zc->zc_inject_record); in zfs_ioc_inject_list_next()
5961 zc->zc_guid = id; in zfs_ioc_inject_list_next()
5972 if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) in zfs_ioc_error_log()
5975 error = spa_get_errlog(spa, (void *)(uintptr_t)zc->zc_nvlist_dst, in zfs_ioc_error_log()
5976 &zc->zc_nvlist_dst_size); in zfs_ioc_error_log()
5987 vdev_t *vd; in zfs_ioc_clear() local
5994 spa = spa_lookup(zc->zc_name); in zfs_ioc_clear()
6003 spa->spa_last_open_failed = 0; in zfs_ioc_clear()
6006 if (zc->zc_cookie & ZPOOL_NO_REWIND) { in zfs_ioc_clear()
6007 error = spa_open(zc->zc_name, &spa, FTAG); in zfs_ioc_clear()
6012 if (zc->zc_nvlist_src == 0) in zfs_ioc_clear()
6015 if ((error = get_nvlist(zc->zc_nvlist_src, in zfs_ioc_clear()
6016 zc->zc_nvlist_src_size, zc->zc_iflags, &policy)) == 0) { in zfs_ioc_clear()
6017 error = spa_open_rewind(zc->zc_name, &spa, FTAG, in zfs_ioc_clear()
6045 if (zc->zc_guid == 0) { in zfs_ioc_clear()
6046 vd = NULL; in zfs_ioc_clear()
6048 vd = spa_lookup_by_guid(spa, zc->zc_guid, B_TRUE); in zfs_ioc_clear()
6049 if (vd == NULL) { in zfs_ioc_clear()
6057 vdev_clear(spa, vd); in zfs_ioc_clear()
6060 NULL : spa->spa_root_vdev, 0); in zfs_ioc_clear()
6077 * "scrub_restart" -> when true and scrub is running, allow to restart
6115 spa->spa_scrub_reopen = (!scrub_restart && in zfs_ioc_pool_reopen()
6116 dsl_scan_scrubbing(spa->spa_dsl_pool)); in zfs_ioc_pool_reopen()
6117 vdev_reopen(spa->spa_root_vdev); in zfs_ioc_pool_reopen()
6118 spa->spa_scrub_reopen = B_FALSE; in zfs_ioc_pool_reopen()
6141 zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; in zfs_ioc_promote()
6142 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 || in zfs_ioc_promote()
6143 strchr(zc->zc_name, '%')) in zfs_ioc_promote()
6146 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_promote()
6150 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &ds); in zfs_ioc_promote()
6156 if (!dsl_dir_is_clone(ds->ds_dir)) { in zfs_ioc_promote()
6163 dsl_dir_phys(ds->ds_dir)->dd_origin_obj, FTAG, &ods); in zfs_ioc_promote()
6184 return (dsl_dataset_promote(zc->zc_name, zc->zc_string)); in zfs_ioc_promote()
6193 * zc_value domain name (eg. "S-1-234-567-89")
6205 if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS) in zfs_ioc_userspace_one()
6208 error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE); in zfs_ioc_userspace_one()
6213 zc->zc_objset_type, zc->zc_value, zc->zc_guid, &zc->zc_cookie); in zfs_ioc_userspace_one()
6234 int bufsize = zc->zc_nvlist_dst_size; in zfs_ioc_userspace_many()
6239 int error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE); in zfs_ioc_userspace_many()
6245 error = zfs_userspace_many(zfsvfs, zc->zc_objset_type, &zc->zc_cookie, in zfs_ioc_userspace_many()
6246 buf, &zc->zc_nvlist_dst_size); in zfs_ioc_userspace_many()
6250 (void *)(uintptr_t)zc->zc_nvlist_dst, in zfs_ioc_userspace_many()
6251 zc->zc_nvlist_dst_size); in zfs_ioc_userspace_many()
6272 if (getzfsvfs(zc->zc_name, &zfsvfs) == 0) { in zfs_ioc_userspace_upgrade()
6273 if (!dmu_objset_userused_enabled(zfsvfs->z_os)) { in zfs_ioc_userspace_upgrade()
6281 ds = dmu_objset_ds(zfsvfs->z_os); in zfs_ioc_userspace_upgrade()
6290 mutex_enter(&zfsvfs->z_os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6291 if (zfsvfs->z_os->os_upgrade_id == 0) { in zfs_ioc_userspace_upgrade()
6293 zfsvfs->z_os->os_upgrade_status = 0; in zfs_ioc_userspace_upgrade()
6294 mutex_exit(&zfsvfs->z_os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6297 dmu_objset_pool(zfsvfs->z_os), FTAG); in zfs_ioc_userspace_upgrade()
6298 dmu_objset_userspace_upgrade(zfsvfs->z_os); in zfs_ioc_userspace_upgrade()
6300 dmu_objset_pool(zfsvfs->z_os), FTAG); in zfs_ioc_userspace_upgrade()
6302 mutex_exit(&zfsvfs->z_os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6305 taskq_wait_id(zfsvfs->z_os->os_spa->spa_upgrade_taskq, in zfs_ioc_userspace_upgrade()
6306 zfsvfs->z_os->os_upgrade_id); in zfs_ioc_userspace_upgrade()
6307 error = zfsvfs->z_os->os_upgrade_status; in zfs_ioc_userspace_upgrade()
6314 error = dmu_objset_hold_flags(zc->zc_name, B_TRUE, FTAG, &os); in zfs_ioc_userspace_upgrade()
6318 mutex_enter(&os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6319 if (os->os_upgrade_id == 0) { in zfs_ioc_userspace_upgrade()
6321 os->os_upgrade_status = 0; in zfs_ioc_userspace_upgrade()
6322 mutex_exit(&os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6326 mutex_exit(&os->os_upgrade_lock); in zfs_ioc_userspace_upgrade()
6331 taskq_wait_id(os->os_spa->spa_upgrade_taskq, os->os_upgrade_id); in zfs_ioc_userspace_upgrade()
6332 error = os->os_upgrade_status; in zfs_ioc_userspace_upgrade()
6353 error = dmu_objset_hold_flags(zc->zc_name, B_TRUE, FTAG, &os); in zfs_ioc_id_quota_upgrade()
6359 mutex_enter(&os->os_upgrade_lock); in zfs_ioc_id_quota_upgrade()
6360 if (os->os_upgrade_id == 0) { in zfs_ioc_id_quota_upgrade()
6362 os->os_upgrade_status = 0; in zfs_ioc_id_quota_upgrade()
6363 mutex_exit(&os->os_upgrade_lock); in zfs_ioc_id_quota_upgrade()
6367 mutex_exit(&os->os_upgrade_lock); in zfs_ioc_id_quota_upgrade()
6372 taskq_wait_id(os->os_spa->spa_upgrade_taskq, os->os_upgrade_id); in zfs_ioc_id_quota_upgrade()
6373 error = os->os_upgrade_status; in zfs_ioc_id_quota_upgrade()
6392 * zc_obj object # beyond which we want next in-use object #
6395 * zc_obj next in-use object #
6403 error = dmu_objset_hold(zc->zc_name, FTAG, &os); in zfs_ioc_next_obj()
6407 error = dmu_object_next(os, &zc->zc_obj, B_FALSE, 0); in zfs_ioc_next_obj()
6417 * zc_cleanup_fd cleanup-on-exit file descriptor for calling process
6429 zfs_file_t *fp = zfs_onexit_fd_hold(zc->zc_cleanup_fd, &minor); in zfs_ioc_tmp_snapshot()
6433 snap_name = kmem_asprintf("%s-%016llx", zc->zc_value, in zfs_ioc_tmp_snapshot()
6435 hold_name = kmem_asprintf("%%%s", zc->zc_value); in zfs_ioc_tmp_snapshot()
6437 int error = dsl_dataset_snapshot_tmp(zc->zc_name, snap_name, minor, in zfs_ioc_tmp_snapshot()
6440 (void) strlcpy(zc->zc_value, snap_name, in zfs_ioc_tmp_snapshot()
6441 sizeof (zc->zc_value)); in zfs_ioc_tmp_snapshot()
6464 if ((fp = zfs_file_get(zc->zc_cookie)) == NULL) in zfs_ioc_diff()
6468 error = dmu_diff(zc->zc_name, zc->zc_value, fp, &off); in zfs_ioc_diff()
6483 * "holds" -> { snapname -> holdname (string), ... }
6484 * (optional) "cleanup_fd" -> fd (int32)
6488 * snapname -> error value (int32)
6503 int cleanup_fd = -1; in zfs_ioc_hold()
6541 * holdname -> time added (uint64 seconds since epoch)
6558 * snapname -> { holdname, ... }
6563 * snapname -> error value (int32)
6596 zfs_file_t *fp = zfs_zevent_fd_hold(zc->zc_cleanup_fd, &minor, &ze); in zfs_ioc_events_next()
6602 &zc->zc_nvlist_dst_size, &dropped); in zfs_ioc_events_next()
6604 zc->zc_cookie = dropped; in zfs_ioc_events_next()
6609 if (zc->zc_guid & ZEVENT_NONBLOCK) in zfs_ioc_events_next()
6635 zc->zc_cookie = count; in zfs_ioc_events_clear()
6652 zfs_file_t *fp = zfs_zevent_fd_hold(zc->zc_cleanup_fd, &minor, &ze); in zfs_ioc_events_seek()
6656 error = zfs_zevent_seek(ze, zc->zc_guid); in zfs_ioc_events_seek()
6679 error = dsl_pool_hold(zc->zc_name, FTAG, &dp); in zfs_ioc_space_written()
6682 error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &new); in zfs_ioc_space_written()
6687 if (strchr(zc->zc_value, '#') != NULL) { in zfs_ioc_space_written()
6689 error = dsl_bookmark_lookup(dp, zc->zc_value, in zfs_ioc_space_written()
6693 &zc->zc_cookie, in zfs_ioc_space_written()
6694 &zc->zc_objset_type, &zc->zc_perm_action); in zfs_ioc_space_written()
6698 error = dsl_dataset_hold(dp, zc->zc_value, FTAG, &old); in zfs_ioc_space_written()
6702 &zc->zc_cookie, in zfs_ioc_space_written()
6703 &zc->zc_objset_type, &zc->zc_perm_action); in zfs_ioc_space_written()
6714 * "firstsnap" -> snapshot name
6718 * "used" -> space in bytes
6719 * "compressed" -> compressed space in bytes
6720 * "uncompressed" -> uncompressed space in bytes
6743 if (error == 0 && !new->ds_is_snapshot) { in zfs_ioc_space_snaps()
6752 if (error == 0 && !old->ds_is_snapshot) { in zfs_ioc_space_snaps()
6774 * "fd" -> file descriptor to write stream to (int32)
6775 * (optional) "fromsnap" -> full snap name to send an incremental from
6776 * (optional) "largeblockok" -> (value ignored)
6778 * (optional) "embedok" -> (value ignored)
6780 * (optional) "compressok" -> (value ignored)
6782 * (optional) "rawok" -> (value ignored)
6784 * (optional) "savedok" -> (value ignored)
6786 * (optional) "resume_object" and "resume_offset" -> (uint64)
6788 * (optional) "redactbook" -> (string)
6867 * Determine approximately how large a zfs send stream will be -- the number
6871 * (optional) "from" -> full snap or bookmark name to send an incremental
6873 * (optional) "largeblockok" -> (value ignored)
6875 * (optional) "embedok" -> (value ignored)
6877 * (optional) "compressok" -> (value ignored)
6879 * (optional) "rawok" -> (value ignored)
6881 * (optional) "resume_object" and "resume_offset" -> (uint64)
6883 * (optional) "fd" -> file descriptor to use as a cookie for progress
6888 * "space" -> bytes of space (uint64)
6924 int32_t fd = -1; in zfs_ioc_send_space()
6959 * the from-bookmark and tosnap are at the same txg. in zfs_ioc_send_space()
6969 dsl_dataset_phys(tosnap)->ds_guid) in zfs_ioc_send_space()
7023 space -= resume_bytes; in zfs_ioc_send_space()
7042 * "force" -> when true, force uberblock update even if there is no dirty data.
7072 vdev_config_dirty(spa->spa_root_vdev); in zfs_ioc_pool_sync()
7085 * "hidden_args" -> { "wkeydata" -> value }
7087 * (optional) "noop" -> (value ignored)
7163 * "hidden_args" (optional) -> { "wkeydata" -> value }
7165 * "props" (optional) -> { prop -> value }
7211 static zfs_ioc_vec_t zfs_ioc_vec[ZFS_IOC_LAST - ZFS_IOC_FIRST];
7218 zfs_ioc_vec_t *vec = &zfs_ioc_vec[ioc - ZFS_IOC_FIRST]; in zfs_ioctl_register_legacy()
7222 ASSERT3P(vec->zvec_legacy_func, ==, NULL); in zfs_ioctl_register_legacy()
7223 ASSERT3P(vec->zvec_func, ==, NULL); in zfs_ioctl_register_legacy()
7225 vec->zvec_legacy_func = func; in zfs_ioctl_register_legacy()
7226 vec->zvec_secpolicy = secpolicy; in zfs_ioctl_register_legacy()
7227 vec->zvec_namecheck = namecheck; in zfs_ioctl_register_legacy()
7228 vec->zvec_allow_log = log_history; in zfs_ioctl_register_legacy()
7229 vec->zvec_pool_check = pool_check; in zfs_ioctl_register_legacy()
7242 zfs_ioc_vec_t *vec = &zfs_ioc_vec[ioc - ZFS_IOC_FIRST]; in zfs_ioctl_register()
7246 ASSERT3P(vec->zvec_legacy_func, ==, NULL); in zfs_ioctl_register()
7247 ASSERT3P(vec->zvec_func, ==, NULL); in zfs_ioctl_register()
7252 vec->zvec_name = name; in zfs_ioctl_register()
7253 vec->zvec_func = func; in zfs_ioctl_register()
7254 vec->zvec_secpolicy = secpolicy; in zfs_ioctl_register()
7255 vec->zvec_namecheck = namecheck; in zfs_ioctl_register()
7256 vec->zvec_pool_check = pool_check; in zfs_ioctl_register()
7257 vec->zvec_smush_outnvlist = smush_outnvlist; in zfs_ioctl_register()
7258 vec->zvec_allow_log = allow_log; in zfs_ioctl_register()
7259 vec->zvec_nvl_keys = nvl_keys; in zfs_ioctl_register()
7260 vec->zvec_nvl_key_count = num_keys; in zfs_ioctl_register()
7411 zfs_ioctl_register("load-key", ZFS_IOC_LOAD_KEY, in zfs_ioctl_init()
7415 zfs_ioctl_register("unload-key", ZFS_IOC_UNLOAD_KEY, in zfs_ioctl_init()
7419 zfs_ioctl_register("change-key", ZFS_IOC_CHANGE_KEY, in zfs_ioctl_init()
7657 * Verify that for non-legacy ioctls the input nvlist
7668 const zfs_ioc_key_t *nvl_keys = vec->zvec_nvl_keys; in zfs_check_input_nvpairs()
7683 for (int k = 0; k < vec->zvec_nvl_key_count; k++) { in zfs_check_input_nvpairs()
7712 for (int k = 0; k < vec->zvec_nvl_key_count; k++) { in zfs_check_input_nvpairs()
7717 /* at least one non-optional key is expected here */ in zfs_check_input_nvpairs()
7767 for (zs = &zfsdev_state_listhead; zs != NULL; zs = zs->zs_next) { in zfsdev_getminor()
7769 if (zs->zs_minor == -1) in zfsdev_getminor()
7773 *minorp = fpd->zs_minor; in zfsdev_getminor()
7789 for (zs = &zfsdev_state_listhead; zs != NULL; zs = zs->zs_next) { in zfsdev_get_state()
7790 if (zs->zs_minor == minor) { in zfsdev_get_state()
7794 return (zs->zs_onexit); in zfsdev_get_state()
7796 return (zs->zs_zevent); in zfsdev_get_state()
7843 for (zs = &zfsdev_state_listhead; zs != NULL; zs = zs->zs_next) { in zfsdev_state_init()
7844 if (zs->zs_minor == -1) in zfsdev_state_init()
7856 zfs_onexit_init((zfs_onexit_t **)&zs->zs_onexit); in zfsdev_state_init()
7857 zfs_zevent_init((zfs_zevent_t **)&zs->zs_zevent); in zfsdev_state_init()
7860 * In order to provide for lock-free concurrent read access in zfsdev_state_init()
7864 * operation must be updating zs_minor (from -1 to the new in zfsdev_state_init()
7868 zs->zs_minor = minor; in zfsdev_state_init()
7870 zsprev->zs_next = zs; in zfsdev_state_init()
7873 zs->zs_minor = minor; in zfsdev_state_init()
7885 ASSERT3S(zs->zs_minor, >, 0); in zfsdev_state_destroy()
7891 * invalidated by setting zs_minor to -1. Invalidation must be done in zfsdev_state_destroy()
7895 zfs_onexit_destroy(zs->zs_onexit); in zfsdev_state_destroy()
7896 zfs_zevent_destroy(zs->zs_zevent); in zfsdev_state_destroy()
7897 zs->zs_onexit = NULL; in zfsdev_state_destroy()
7898 zs->zs_zevent = NULL; in zfsdev_state_destroy()
7900 zs->zs_minor = -1; in zfsdev_state_destroy()
7926 if (vec->zvec_func == NULL && vec->zvec_legacy_func == NULL) in zfsdev_ioctl_common()
7929 zc->zc_iflags = flag & FKIOCTL; in zfsdev_ioctl_common()
7931 if (zc->zc_nvlist_src_size > max_nvlist_src_size) { in zfsdev_ioctl_common()
7947 } else if (zc->zc_nvlist_src_size != 0) { in zfsdev_ioctl_common()
7948 error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, in zfsdev_ioctl_common()
7949 zc->zc_iflags, &innvl); in zfsdev_ioctl_common()
7958 zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; in zfsdev_ioctl_common()
7959 switch (vec->zvec_namecheck) { in zfsdev_ioctl_common()
7961 if (pool_namecheck(zc->zc_name, NULL, NULL) != 0) in zfsdev_ioctl_common()
7964 error = pool_status_check(zc->zc_name, in zfsdev_ioctl_common()
7965 vec->zvec_namecheck, vec->zvec_pool_check); in zfsdev_ioctl_common()
7969 if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0) in zfsdev_ioctl_common()
7972 error = pool_status_check(zc->zc_name, in zfsdev_ioctl_common()
7973 vec->zvec_namecheck, vec->zvec_pool_check); in zfsdev_ioctl_common()
7977 if (entity_namecheck(zc->zc_name, NULL, NULL) != 0) { in zfsdev_ioctl_common()
7980 error = pool_status_check(zc->zc_name, in zfsdev_ioctl_common()
7981 vec->zvec_namecheck, vec->zvec_pool_check); in zfsdev_ioctl_common()
7996 if (error == 0 && vec->zvec_func != NULL) { in zfsdev_ioctl_common()
8004 error = vec->zvec_secpolicy(zc, innvl, CRED()); in zfsdev_ioctl_common()
8016 saved_poolname_len = strlen(zc->zc_name) + 1; in zfsdev_ioctl_common()
8019 strlcpy(saved_poolname, zc->zc_name, saved_poolname_len); in zfsdev_ioctl_common()
8022 if (vec->zvec_func != NULL) { in zfsdev_ioctl_common()
8028 ASSERT(vec->zvec_legacy_func == NULL); in zfsdev_ioctl_common()
8034 if (vec->zvec_allow_log) { in zfsdev_ioctl_common()
8037 vec->zvec_name); in zfsdev_ioctl_common()
8046 error = vec->zvec_func(zc->zc_name, innvl, outnvl); in zfsdev_ioctl_common()
8056 vec->zvec_allow_log && in zfsdev_ioctl_common()
8057 spa_open(zc->zc_name, &spa, FTAG) == 0) { in zfsdev_ioctl_common()
8073 gethrtime() - start_time); in zfsdev_ioctl_common()
8079 if (!nvlist_empty(outnvl) || zc->zc_nvlist_dst_size != 0) { in zfsdev_ioctl_common()
8081 if (vec->zvec_smush_outnvlist) { in zfsdev_ioctl_common()
8083 zc->zc_nvlist_dst_size); in zfsdev_ioctl_common()
8095 error = vec->zvec_legacy_func(zc); in zfsdev_ioctl_common()
8101 if (error == 0 && vec->zvec_allow_log) { in zfsdev_ioctl_common()
8127 zfsdev_state_listhead.zs_minor = -1; in zfs_kmod_init()
8154 zsnext = zs->zs_next; in zfs_kmod_fini()
8155 if (zs->zs_onexit) in zfs_kmod_fini()
8156 zfs_onexit_destroy(zs->zs_onexit); in zfs_kmod_fini()
8157 if (zs->zs_zevent) in zfs_kmod_fini()
8158 zfs_zevent_destroy(zs->zs_zevent); in zfs_kmod_fini()