diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs.abi | 67 | ||||
-rw-r--r-- | lib/libzfs/libzfs_pool.c | 28 | ||||
-rw-r--r-- | lib/libzfs_core/libzfs_core.abi | 15 | ||||
-rw-r--r-- | lib/libzfs_core/libzfs_core.c | 22 |
4 files changed, 120 insertions, 12 deletions
diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 87c5c4380..88dd8b3c6 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -183,8 +183,8 @@ <elf-symbol name='fsleep' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='get_dataset_depth' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='get_system_hostid' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> - <elf-symbol name='getexecname' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='get_timestamp' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> + <elf-symbol name='getexecname' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='getextmntent' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='getmntany' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='getprop_uint64' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> @@ -466,7 +466,9 @@ <elf-symbol name='zpool_clear' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_clear_label' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_close' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> + <elf-symbol name='zpool_collect_unsup_feat' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_create' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> + <elf-symbol name='zpool_ddt_prune' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_default_search_paths' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_destroy' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_disable_datasets' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> @@ -485,8 +487,8 @@ <elf-symbol name='zpool_export_force' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_feature_init' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_find_config' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> - <elf-symbol name='zpool_find_vdev' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_find_parent_vdev' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> + <elf-symbol name='zpool_find_vdev' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_find_vdev_by_physpath' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_free_handles' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_get_all_vdev_props' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> @@ -529,7 +531,6 @@ <elf-symbol name='zpool_prefetch' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_prepare_and_label_disk' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_prepare_disk' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> - <elf-symbol name='zpool_collect_unsup_feat' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_prop_align_right' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_prop_column_name' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='zpool_prop_default_numeric' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> @@ -5929,6 +5930,7 @@ <enumerator name='ZFS_IOC_VDEV_SET_PROPS' value='23126'/> <enumerator name='ZFS_IOC_POOL_SCRUB' value='23127'/> <enumerator name='ZFS_IOC_POOL_PREFETCH' value='23128'/> + <enumerator name='ZFS_IOC_DDT_PRUNE' value='23129'/> <enumerator name='ZFS_IOC_PLATFORM' value='23168'/> <enumerator name='ZFS_IOC_EVENTS_NEXT' value='23169'/> <enumerator name='ZFS_IOC_EVENTS_CLEAR' value='23170'/> @@ -5963,6 +5965,13 @@ <enumerator name='ZPOOL_PREFETCH_DDT' value='1'/> </enum-decl> <typedef-decl name='zpool_prefetch_type_t' type-id='0299ab50' id='e55ff6bc'/> + <enum-decl name='zpool_ddt_prune_unit_t' naming-typedef-id='02e25ab0' id='509ae11c'> + <underlying-type type-id='9cac1fee'/> + <enumerator name='ZPOOL_DDT_PRUNE_NONE' value='0'/> + <enumerator name='ZPOOL_DDT_PRUNE_AGE' value='1'/> + <enumerator name='ZPOOL_DDT_PRUNE_PERCENTAGE' value='2'/> + </enum-decl> + <typedef-decl name='zpool_ddt_prune_unit_t' type-id='509ae11c' id='02e25ab0'/> <enum-decl name='spa_feature' id='33ecb627'> <underlying-type type-id='9cac1fee'/> <enumerator name='SPA_FEATURE_NONE' value='-1'/> @@ -6139,6 +6148,12 @@ <parameter type-id='857bb57e'/> <return type-id='95e97e5e'/> </function-decl> + <function-decl name='lzc_ddt_prune' visibility='default' binding='global' size-in-bits='64'> + <parameter type-id='80f4b756'/> + <parameter type-id='02e25ab0'/> + <parameter type-id='9c313c2d'/> + <return type-id='95e97e5e'/> + </function-decl> <function-decl name='zfs_resolve_shortname' mangled-name='zfs_resolve_shortname' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_resolve_shortname'> <parameter type-id='80f4b756'/> <parameter type-id='26a90f95'/> @@ -6798,6 +6813,12 @@ <parameter type-id='80f4b756' name='propval'/> <return type-id='95e97e5e'/> </function-decl> + <function-decl name='zpool_ddt_prune' mangled-name='zpool_ddt_prune' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_ddt_prune'> + <parameter type-id='4c81de99' name='zhp'/> + <parameter type-id='02e25ab0' name='unit'/> + <parameter type-id='9c313c2d' name='amount'/> + <return type-id='95e97e5e'/> + </function-decl> </abi-instr> <abi-instr address-size='64' path='lib/libzfs/libzfs_sendrecv.c' language='LANG_C99'> <array-type-def dimensions='1' type-id='8901473c' size-in-bits='576' id='f5da478b'> @@ -7837,7 +7858,7 @@ </data-member> </class-decl> <typedef-decl name='vdev_cbdata_t' type-id='b8006be8' id='a9679c94'/> - <class-decl name='zprop_get_cbdata' size-in-bits='832' is-struct='yes' visibility='default' id='f3d3c319'> + <class-decl name='zprop_get_cbdata' size-in-bits='960' is-struct='yes' visibility='default' id='f3d3c319'> <data-member access='public' layout-offset-in-bits='0'> <var-decl name='cb_sources' type-id='95e97e5e' visibility='default'/> </data-member> @@ -7856,6 +7877,9 @@ <data-member access='public' layout-offset-in-bits='448'> <var-decl name='cb_first' type-id='c19b74c3' visibility='default'/> </data-member> + <data-member access='public' layout-offset-in-bits='480'> + <var-decl name='cb_json' type-id='c19b74c3' visibility='default'/> + </data-member> <data-member access='public' layout-offset-in-bits='512'> <var-decl name='cb_proplist' type-id='3a9b2288' visibility='default'/> </data-member> @@ -7865,6 +7889,15 @@ <data-member access='public' layout-offset-in-bits='640'> <var-decl name='cb_vdevs' type-id='a9679c94' visibility='default'/> </data-member> + <data-member access='public' layout-offset-in-bits='832'> + <var-decl name='cb_jsobj' type-id='5ce45b60' visibility='default'/> + </data-member> + <data-member access='public' layout-offset-in-bits='896'> + <var-decl name='cb_json_as_int' type-id='c19b74c3' visibility='default'/> + </data-member> + <data-member access='public' layout-offset-in-bits='928'> + <var-decl name='cb_json_pool_key_guid' type-id='c19b74c3' visibility='default'/> + </data-member> </class-decl> <typedef-decl name='zprop_get_cbdata_t' type-id='f3d3c319' id='f3d87113'/> <typedef-decl name='zprop_func' type-id='2e711a2a' id='1ec3747a'/> @@ -7968,6 +8001,11 @@ <qualified-type-def type-id='d33f11cb' restrict='yes' id='5c53ba29'/> <pointer-type-def type-id='ffa52b96' size-in-bits='64' id='76c8174b'/> <pointer-type-def type-id='f3d87113' size-in-bits='64' id='0d2a0670'/> + <function-decl name='nvlist_print_json' visibility='default' binding='global' size-in-bits='64'> + <parameter type-id='822cd80b'/> + <parameter type-id='5ce45b60'/> + <return type-id='95e97e5e'/> + </function-decl> <function-decl name='zpool_label_disk' mangled-name='zpool_label_disk' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_label_disk'> <parameter type-id='b0382bb3'/> <parameter type-id='4c81de99'/> @@ -8075,6 +8113,11 @@ <parameter type-id='d33f11cb'/> <return type-id='48b5725f'/> </function-decl> + <function-decl name='putc' visibility='default' binding='global' size-in-bits='64'> + <parameter type-id='95e97e5e'/> + <parameter type-id='822cd80b'/> + <return type-id='95e97e5e'/> + </function-decl> <function-decl name='puts' visibility='default' binding='global' size-in-bits='64'> <parameter type-id='80f4b756'/> <return type-id='95e97e5e'/> @@ -8093,6 +8136,11 @@ <parameter type-id='95e97e5e'/> <return type-id='48b5725f'/> </function-decl> + <function-decl name='strspn' visibility='default' binding='global' size-in-bits='64'> + <parameter type-id='80f4b756'/> + <parameter type-id='80f4b756'/> + <return type-id='b59d7dce'/> + </function-decl> <function-decl name='strnlen' visibility='default' binding='global' size-in-bits='64'> <parameter type-id='80f4b756'/> <parameter type-id='b59d7dce'/> @@ -8292,12 +8340,12 @@ <function-decl name='zfs_version_print' mangled-name='zfs_version_print' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_version_print'> <return type-id='95e97e5e'/> </function-decl> - <function-decl name='use_color' mangled-name='use_color' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='use_color'> - <return type-id='95e97e5e'/> - </function-decl> <function-decl name='zfs_version_nvlist' mangled-name='zfs_version_nvlist' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_version_nvlist'> <return type-id='5ce45b60'/> </function-decl> + <function-decl name='use_color' mangled-name='use_color' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='use_color'> + <return type-id='95e97e5e'/> + </function-decl> <function-decl name='printf_color' mangled-name='printf_color' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='printf_color'> <parameter type-id='80f4b756' name='color'/> <parameter type-id='80f4b756' name='format'/> @@ -8802,11 +8850,6 @@ <parameter type-id='78c01427'/> <return type-id='13956559'/> </function-decl> - <function-decl name='strspn' visibility='default' binding='global' size-in-bits='64'> - <parameter type-id='80f4b756'/> - <parameter type-id='80f4b756'/> - <return type-id='b59d7dce'/> - </function-decl> <function-decl name='zfs_dirnamelen' mangled-name='zfs_dirnamelen' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_dirnamelen'> <parameter type-id='80f4b756' name='path'/> <return type-id='79a0948f'/> diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index dfa7c4db6..14410b153 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -5649,3 +5649,31 @@ zpool_set_vdev_prop(zpool_handle_t *zhp, const char *vdevname, return (ret); } + +/* + * Prune older entries from the DDT to reclaim space under the quota + */ +int +zpool_ddt_prune(zpool_handle_t *zhp, zpool_ddt_prune_unit_t unit, + uint64_t amount) +{ + int error = lzc_ddt_prune(zhp->zpool_name, unit, amount); + if (error != 0) { + libzfs_handle_t *hdl = zhp->zpool_hdl; + char errbuf[ERRBUFLEN]; + + (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, + "cannot prune dedup table on '%s'"), zhp->zpool_name); + + if (error == EALREADY) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "a prune operation is already in progress")); + (void) zfs_error(hdl, EZFS_BUSY, errbuf); + } else { + (void) zpool_standard_error(hdl, errno, errbuf); + } + return (-1); + } + + return (0); +} diff --git a/lib/libzfs_core/libzfs_core.abi b/lib/libzfs_core/libzfs_core.abi index 1062a6b52..5ee6b8e09 100644 --- a/lib/libzfs_core/libzfs_core.abi +++ b/lib/libzfs_core/libzfs_core.abi @@ -162,6 +162,7 @@ <elf-symbol name='lzc_channel_program_nosync' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='lzc_clone' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='lzc_create' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> + <elf-symbol name='lzc_ddt_prune' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='lzc_destroy' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='lzc_destroy_bookmarks' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> <elf-symbol name='lzc_destroy_snaps' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> @@ -1444,6 +1445,7 @@ <enumerator name='ZFS_IOC_VDEV_SET_PROPS' value='23126'/> <enumerator name='ZFS_IOC_POOL_SCRUB' value='23127'/> <enumerator name='ZFS_IOC_POOL_PREFETCH' value='23128'/> + <enumerator name='ZFS_IOC_DDT_PRUNE' value='23129'/> <enumerator name='ZFS_IOC_PLATFORM' value='23168'/> <enumerator name='ZFS_IOC_EVENTS_NEXT' value='23169'/> <enumerator name='ZFS_IOC_EVENTS_CLEAR' value='23170'/> @@ -1484,6 +1486,13 @@ <enumerator name='ZPOOL_PREFETCH_DDT' value='1'/> </enum-decl> <typedef-decl name='zpool_prefetch_type_t' type-id='0299ab50' id='e55ff6bc'/> + <enum-decl name='zpool_ddt_prune_unit_t' naming-typedef-id='02e25ab0' id='509ae11c'> + <underlying-type type-id='9cac1fee'/> + <enumerator name='ZPOOL_DDT_PRUNE_NONE' value='0'/> + <enumerator name='ZPOOL_DDT_PRUNE_AGE' value='1'/> + <enumerator name='ZPOOL_DDT_PRUNE_PERCENTAGE' value='2'/> + </enum-decl> + <typedef-decl name='zpool_ddt_prune_unit_t' type-id='509ae11c' id='02e25ab0'/> <enum-decl name='data_type_t' naming-typedef-id='8d0687d2' id='aeeae136'> <underlying-type type-id='9cac1fee'/> <enumerator name='DATA_TYPE_DONTCARE' value='-1'/> @@ -3015,6 +3024,12 @@ <parameter type-id='857bb57e' name='outnvl'/> <return type-id='95e97e5e'/> </function-decl> + <function-decl name='lzc_ddt_prune' mangled-name='lzc_ddt_prune' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='lzc_ddt_prune'> + <parameter type-id='80f4b756' name='pool'/> + <parameter type-id='02e25ab0' name='unit'/> + <parameter type-id='9c313c2d' name='amount'/> + <return type-id='95e97e5e'/> + </function-decl> <function-type size-in-bits='64' id='c70fa2e8'> <parameter type-id='95e97e5e'/> <parameter type-id='eaa32e2f'/> diff --git a/lib/libzfs_core/libzfs_core.c b/lib/libzfs_core/libzfs_core.c index ec8b0ff4f..d07fca6ce 100644 --- a/lib/libzfs_core/libzfs_core.c +++ b/lib/libzfs_core/libzfs_core.c @@ -1927,3 +1927,25 @@ lzc_get_bootenv(const char *pool, nvlist_t **outnvl) { return (lzc_ioctl(ZFS_IOC_GET_BOOTENV, pool, NULL, outnvl)); } + +/* + * Prune the specified amount from the pool's dedup table. + */ +int +lzc_ddt_prune(const char *pool, zpool_ddt_prune_unit_t unit, uint64_t amount) +{ + int error; + + nvlist_t *result = NULL; + nvlist_t *args = fnvlist_alloc(); + + fnvlist_add_int32(args, DDT_PRUNE_UNIT, unit); + fnvlist_add_uint64(args, DDT_PRUNE_AMOUNT, amount); + + error = lzc_ioctl(ZFS_IOC_DDT_PRUNE, pool, args, &result); + + fnvlist_free(args); + fnvlist_free(result); + + return (error); +} |