Skip to content

Commit 947465b

Browse files
author
Ryan Moeller
authored
libzfs: Remove unused zpool_get_physpath()
This is an oddly specific function that has never had any consumers in the history of this repo. Get rid of it and the pile of helper functions that exist for it. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #13724
1 parent 4fc1ea9 commit 947465b

File tree

3 files changed

+0
-156
lines changed

3 files changed

+0
-156
lines changed

include/libzfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ _LIBZFS_H void zpool_obj_to_path_ds(zpool_handle_t *, uint64_t, uint64_t,
475475
_LIBZFS_H void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *,
476476
size_t);
477477
_LIBZFS_H int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *);
478-
_LIBZFS_H int zpool_get_physpath(zpool_handle_t *, char *, size_t);
479478
_LIBZFS_H void zpool_explain_recover(libzfs_handle_t *, const char *, int,
480479
nvlist_t *);
481480
_LIBZFS_H int zpool_checkpoint(zpool_handle_t *);

lib/libzfs/libzfs.abi

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@
476476
<elf-symbol name='zpool_get_history' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
477477
<elf-symbol name='zpool_get_load_policy' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
478478
<elf-symbol name='zpool_get_name' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
479-
<elf-symbol name='zpool_get_physpath' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
480479
<elf-symbol name='zpool_get_prop' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
481480
<elf-symbol name='zpool_get_prop_int' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
482481
<elf-symbol name='zpool_get_state' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
@@ -3468,12 +3467,6 @@
34683467
<parameter type-id='37e3bd22' name='log'/>
34693468
<return type-id='5ce45b60'/>
34703469
</function-decl>
3471-
<function-decl name='zpool_get_physpath' mangled-name='zpool_get_physpath' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_get_physpath'>
3472-
<parameter type-id='4c81de99' name='zhp'/>
3473-
<parameter type-id='26a90f95' name='physpath'/>
3474-
<parameter type-id='b59d7dce' name='phypath_size'/>
3475-
<return type-id='95e97e5e'/>
3476-
</function-decl>
34773470
<function-decl name='zpool_vdev_path_to_guid' mangled-name='zpool_vdev_path_to_guid' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_vdev_path_to_guid'>
34783471
<parameter type-id='4c81de99' name='zhp'/>
34793472
<parameter type-id='80f4b756' name='path'/>

lib/libzfs/libzfs_pool.c

Lines changed: 0 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,154 +2898,6 @@ zpool_find_vdev(zpool_handle_t *zhp, const char *path, boolean_t *avail_spare,
28982898
return (ret);
28992899
}
29002900

2901-
static int
2902-
vdev_is_online(nvlist_t *nv)
2903-
{
2904-
uint64_t ival;
2905-
2906-
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_OFFLINE, &ival) == 0 ||
2907-
nvlist_lookup_uint64(nv, ZPOOL_CONFIG_FAULTED, &ival) == 0 ||
2908-
nvlist_lookup_uint64(nv, ZPOOL_CONFIG_REMOVED, &ival) == 0)
2909-
return (0);
2910-
2911-
return (1);
2912-
}
2913-
2914-
/*
2915-
* Helper function for zpool_get_physpaths().
2916-
*/
2917-
static int
2918-
vdev_get_one_physpath(nvlist_t *config, char *physpath, size_t physpath_size,
2919-
size_t *bytes_written)
2920-
{
2921-
size_t bytes_left, pos, rsz;
2922-
char *tmppath;
2923-
const char *format;
2924-
2925-
if (nvlist_lookup_string(config, ZPOOL_CONFIG_PHYS_PATH,
2926-
&tmppath) != 0)
2927-
return (EZFS_NODEVICE);
2928-
2929-
pos = *bytes_written;
2930-
bytes_left = physpath_size - pos;
2931-
format = (pos == 0) ? "%s" : " %s";
2932-
2933-
rsz = snprintf(physpath + pos, bytes_left, format, tmppath);
2934-
*bytes_written += rsz;
2935-
2936-
if (rsz >= bytes_left) {
2937-
/* if physpath was not copied properly, clear it */
2938-
if (bytes_left != 0) {
2939-
physpath[pos] = 0;
2940-
}
2941-
return (EZFS_NOSPC);
2942-
}
2943-
return (0);
2944-
}
2945-
2946-
static int
2947-
vdev_get_physpaths(nvlist_t *nv, char *physpath, size_t phypath_size,
2948-
size_t *rsz, boolean_t is_spare)
2949-
{
2950-
char *type;
2951-
int ret;
2952-
2953-
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) != 0)
2954-
return (EZFS_INVALCONFIG);
2955-
2956-
if (strcmp(type, VDEV_TYPE_DISK) == 0) {
2957-
/*
2958-
* An active spare device has ZPOOL_CONFIG_IS_SPARE set.
2959-
* For a spare vdev, we only want to boot from the active
2960-
* spare device.
2961-
*/
2962-
if (is_spare) {
2963-
uint64_t spare = 0;
2964-
(void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_IS_SPARE,
2965-
&spare);
2966-
if (!spare)
2967-
return (EZFS_INVALCONFIG);
2968-
}
2969-
2970-
if (vdev_is_online(nv)) {
2971-
if ((ret = vdev_get_one_physpath(nv, physpath,
2972-
phypath_size, rsz)) != 0)
2973-
return (ret);
2974-
}
2975-
} else if (strcmp(type, VDEV_TYPE_MIRROR) == 0 ||
2976-
strcmp(type, VDEV_TYPE_RAIDZ) == 0 ||
2977-
strcmp(type, VDEV_TYPE_REPLACING) == 0 ||
2978-
(is_spare = (strcmp(type, VDEV_TYPE_SPARE) == 0))) {
2979-
nvlist_t **child;
2980-
uint_t count;
2981-
int i, ret;
2982-
2983-
if (nvlist_lookup_nvlist_array(nv,
2984-
ZPOOL_CONFIG_CHILDREN, &child, &count) != 0)
2985-
return (EZFS_INVALCONFIG);
2986-
2987-
for (i = 0; i < count; i++) {
2988-
ret = vdev_get_physpaths(child[i], physpath,
2989-
phypath_size, rsz, is_spare);
2990-
if (ret == EZFS_NOSPC)
2991-
return (ret);
2992-
}
2993-
}
2994-
2995-
return (EZFS_POOL_INVALARG);
2996-
}
2997-
2998-
/*
2999-
* Get phys_path for a root pool config.
3000-
* Return 0 on success; non-zero on failure.
3001-
*/
3002-
static int
3003-
zpool_get_config_physpath(nvlist_t *config, char *physpath, size_t phypath_size)
3004-
{
3005-
size_t rsz;
3006-
nvlist_t *vdev_root;
3007-
nvlist_t **child;
3008-
uint_t count;
3009-
char *type;
3010-
3011-
rsz = 0;
3012-
3013-
if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
3014-
&vdev_root) != 0)
3015-
return (EZFS_INVALCONFIG);
3016-
3017-
if (nvlist_lookup_string(vdev_root, ZPOOL_CONFIG_TYPE, &type) != 0 ||
3018-
nvlist_lookup_nvlist_array(vdev_root, ZPOOL_CONFIG_CHILDREN,
3019-
&child, &count) != 0)
3020-
return (EZFS_INVALCONFIG);
3021-
3022-
/*
3023-
* root pool can only have a single top-level vdev.
3024-
*/
3025-
if (strcmp(type, VDEV_TYPE_ROOT) != 0 || count != 1)
3026-
return (EZFS_POOL_INVALARG);
3027-
3028-
(void) vdev_get_physpaths(child[0], physpath, phypath_size, &rsz,
3029-
B_FALSE);
3030-
3031-
/* No online devices */
3032-
if (rsz == 0)
3033-
return (EZFS_NODEVICE);
3034-
3035-
return (0);
3036-
}
3037-
3038-
/*
3039-
* Get phys_path for a root pool
3040-
* Return 0 on success; non-zero on failure.
3041-
*/
3042-
int
3043-
zpool_get_physpath(zpool_handle_t *zhp, char *physpath, size_t phypath_size)
3044-
{
3045-
return (zpool_get_config_physpath(zhp->zpool_config, physpath,
3046-
phypath_size));
3047-
}
3048-
30492901
/*
30502902
* Convert a vdev path to a GUID. Returns GUID or 0 on error.
30512903
*

0 commit comments

Comments
 (0)