Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zpool: correctly align columns with -p, also manpage typo #11202

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cmd/zpool/zpool_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ typedef struct zpool_node {

struct zpool_list {
boolean_t zl_findall;
boolean_t zl_literal;
uu_avl_t *zl_avl;
uu_avl_pool_t *zl_pool;
zprop_list_t **zl_proplist;
Expand Down Expand Up @@ -88,7 +89,9 @@ add_pool(zpool_handle_t *zhp, void *data)
uu_avl_node_init(node, &node->zn_avlnode, zlp->zl_pool);
if (uu_avl_find(zlp->zl_avl, node, NULL, &idx) == NULL) {
if (zlp->zl_proplist &&
zpool_expand_proplist(zhp, zlp->zl_proplist) != 0) {
zpool_expand_proplist(zhp, zlp->zl_proplist,
zlp->zl_literal)
!= 0) {
zpool_close(zhp);
free(node);
return (-1);
Expand All @@ -110,7 +113,8 @@ add_pool(zpool_handle_t *zhp, void *data)
* line.
*/
zpool_list_t *
pool_list_get(int argc, char **argv, zprop_list_t **proplist, int *err)
pool_list_get(int argc, char **argv, zprop_list_t **proplist,
boolean_t literal, int *err)
{
zpool_list_t *zlp;

Expand All @@ -128,6 +132,8 @@ pool_list_get(int argc, char **argv, zprop_list_t **proplist, int *err)

zlp->zl_proplist = proplist;

zlp->zl_literal = literal;

if (argc == 0) {
(void) zpool_iter(g_zfs, add_pool, zlp);
zlp->zl_findall = B_TRUE;
Expand Down Expand Up @@ -242,12 +248,12 @@ pool_list_count(zpool_list_t *zlp)
*/
int
for_each_pool(int argc, char **argv, boolean_t unavail,
zprop_list_t **proplist, zpool_iter_f func, void *data)
zprop_list_t **proplist, boolean_t literal, zpool_iter_f func, void *data)
{
zpool_list_t *list;
int ret = 0;

if ((list = pool_list_get(argc, argv, proplist, &ret)) == NULL)
if ((list = pool_list_get(argc, argv, proplist, literal, &ret)) == NULL)
return (1);

if (pool_list_iter(list, unavail, func, data) != 0)
Expand Down Expand Up @@ -711,7 +717,7 @@ all_pools_for_each_vdev_run(int argc, char **argv, char *cmd,
vcdl->g_zfs = g_zfs;

/* Gather our list of all vdevs in all pools */
for_each_pool(argc, argv, B_TRUE, NULL,
for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE,
all_pools_for_each_vdev_gather_cb, vcdl);

/* Run command on all vdevs in all pools */
Expand Down
39 changes: 22 additions & 17 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ zpool_do_export(int argc, char **argv)
}

return (for_each_pool(argc, argv, B_TRUE, NULL,
zpool_export_one, &cb));
B_FALSE, zpool_export_one, &cb));
}

/* check arguments */
Expand All @@ -1771,7 +1771,8 @@ zpool_do_export(int argc, char **argv)
usage(B_FALSE);
}

ret = for_each_pool(argc, argv, B_TRUE, NULL, zpool_export_one, &cb);
ret = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, zpool_export_one,
&cb);

return (ret);
}
Expand Down Expand Up @@ -3613,7 +3614,8 @@ zpool_do_sync(int argc, char **argv)
argv += optind;

/* if argc == 0 we will execute zpool_sync_one on all pools */
ret = for_each_pool(argc, argv, B_FALSE, NULL, zpool_sync_one, &force);
ret = for_each_pool(argc, argv, B_FALSE, NULL, B_FALSE, zpool_sync_one,
&force);

return (ret);
}
Expand Down Expand Up @@ -4958,7 +4960,7 @@ are_vdevs_in_pool(int argc, char **argv, char *pool_name,

/* Is this name a vdev in our pools? */
ret = for_each_pool(pool_count, &pool_name, B_TRUE, NULL,
is_vdev, cb);
B_FALSE, is_vdev, cb);
if (!ret) {
/* No match */
break;
Expand Down Expand Up @@ -4986,7 +4988,8 @@ is_pool_cb(zpool_handle_t *zhp, void *data)
static int
is_pool(char *name)
{
return (for_each_pool(0, NULL, B_TRUE, NULL, is_pool_cb, name));
return (for_each_pool(0, NULL, B_TRUE, NULL, B_FALSE, is_pool_cb,
name));
}

/* Are all our argv[] strings pool names? If so return 1, 0 otherwise. */
Expand Down Expand Up @@ -5438,7 +5441,7 @@ zpool_do_iostat(int argc, char **argv)
* Construct the list of all interesting pools.
*/
ret = 0;
if ((list = pool_list_get(argc, argv, NULL, &ret)) == NULL)
if ((list = pool_list_get(argc, argv, NULL, parsable, &ret)) == NULL)
return (1);

if (pool_list_count(list) == 0 && argc != 0) {
Expand Down Expand Up @@ -6112,7 +6115,7 @@ zpool_do_list(int argc, char **argv)

for (;;) {
if ((list = pool_list_get(argc, argv, &cb.cb_proplist,
&ret)) == NULL)
cb.cb_literal, &ret)) == NULL)
return (1);

if (pool_list_count(list) == 0)
Expand Down Expand Up @@ -6864,7 +6867,7 @@ zpool_do_reopen(int argc, char **argv)
argv += optind;

/* if argc == 0 we will execute zpool_reopen_one on all pools */
ret = for_each_pool(argc, argv, B_TRUE, NULL, zpool_reopen_one,
ret = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, zpool_reopen_one,
&scrub_restart);

return (ret);
Expand Down Expand Up @@ -6994,12 +6997,13 @@ zpool_do_scrub(int argc, char **argv)
usage(B_FALSE);
}

error = for_each_pool(argc, argv, B_TRUE, NULL, scrub_callback, &cb);
error = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE,
scrub_callback, &cb);

if (wait && !error) {
zpool_wait_activity_t act = ZPOOL_WAIT_SCRUB;
error = for_each_pool(argc, argv, B_TRUE, NULL, wait_callback,
&act);
error = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE,
wait_callback, &act);
}

return (error);
Expand Down Expand Up @@ -7037,7 +7041,8 @@ zpool_do_resilver(int argc, char **argv)
usage(B_FALSE);
}

return (for_each_pool(argc, argv, B_TRUE, NULL, scrub_callback, &cb));
return (for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE,
scrub_callback, &cb));
}

/*
Expand Down Expand Up @@ -8431,7 +8436,7 @@ zpool_do_status(int argc, char **argv)
cb.vcdl = all_pools_for_each_vdev_run(argc, argv, cmd,
NULL, NULL, 0, 0);

ret = for_each_pool(argc, argv, B_TRUE, NULL,
ret = for_each_pool(argc, argv, B_TRUE, NULL, cb.cb_literal,
status_callback, &cb);

if (cb.vcdl != NULL)
Expand Down Expand Up @@ -8950,7 +8955,7 @@ zpool_do_upgrade(int argc, char **argv)
(void) printf(gettext("\n"));
}
} else {
ret = for_each_pool(argc, argv, B_FALSE, NULL,
ret = for_each_pool(argc, argv, B_FALSE, NULL, B_FALSE,
upgrade_one, &cb);
}

Expand Down Expand Up @@ -9133,7 +9138,7 @@ zpool_do_history(int argc, char **argv)
argc -= optind;
argv += optind;

ret = for_each_pool(argc, argv, B_FALSE, NULL, get_history_one,
ret = for_each_pool(argc, argv, B_FALSE, NULL, B_FALSE, get_history_one,
&cbdata);

if (argc == 0 && cbdata.first == B_TRUE) {
Expand Down Expand Up @@ -9696,7 +9701,7 @@ zpool_do_get(int argc, char **argv)
cb.cb_proplist = &fake_name;
}

ret = for_each_pool(argc, argv, B_TRUE, &cb.cb_proplist,
ret = for_each_pool(argc, argv, B_TRUE, &cb.cb_proplist, cb.cb_literal,
get_callback, &cb);

if (cb.cb_proplist == &fake_name)
Expand Down Expand Up @@ -9766,7 +9771,7 @@ zpool_do_set(int argc, char **argv)
*(cb.cb_value) = '\0';
cb.cb_value++;

error = for_each_pool(argc - 2, argv + 2, B_TRUE, NULL,
error = for_each_pool(argc - 2, argv + 2, B_TRUE, NULL, B_FALSE,
set_callback, &cb);

return (error);
Expand Down
4 changes: 2 additions & 2 deletions cmd/zpool/zpool_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ nvlist_t *split_mirror_vdev(zpool_handle_t *zhp, char *newname,
* Pool list functions
*/
int for_each_pool(int, char **, boolean_t unavail, zprop_list_t **,
zpool_iter_f, void *);
boolean_t, zpool_iter_f, void *);

/* Vdev list functions */
typedef int (*pool_vdev_iter_f)(zpool_handle_t *, nvlist_t *, void *);
int for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data);

typedef struct zpool_list zpool_list_t;

zpool_list_t *pool_list_get(int, char **, zprop_list_t **, int *);
zpool_list_t *pool_list_get(int, char **, zprop_list_t **, boolean_t, int *);
void pool_list_update(zpool_list_t *);
int pool_list_iter(zpool_list_t *, int unavail, zpool_iter_f, void *);
void pool_list_free(zpool_list_t *);
Expand Down
2 changes: 1 addition & 1 deletion include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ extern void zfs_prune_proplist(zfs_handle_t *, uint8_t *);
/*
* zpool property management
*/
extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **);
extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **, boolean_t);
extern int zpool_prop_get_feature(zpool_handle_t *, const char *, char *,
size_t);
extern const char *zpool_prop_default_string(zpool_prop_t);
Expand Down
8 changes: 4 additions & 4 deletions lib/libzfs/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,8 @@ zpool_set_prop(zpool_handle_t *zhp, const char *propname, const char *propval)
}

int
zpool_expand_proplist(zpool_handle_t *zhp, zprop_list_t **plp)
zpool_expand_proplist(zpool_handle_t *zhp, zprop_list_t **plp,
boolean_t literal)
{
libzfs_handle_t *hdl = zhp->zpool_hdl;
zprop_list_t *entry;
Expand Down Expand Up @@ -862,13 +863,12 @@ zpool_expand_proplist(zpool_handle_t *zhp, zprop_list_t **plp)
}

for (entry = *plp; entry != NULL; entry = entry->pl_next) {

if (entry->pl_fixed)
if (entry->pl_fixed && !literal)
continue;

if (entry->pl_prop != ZPROP_INVAL &&
zpool_get_prop(zhp, entry->pl_prop, buf, sizeof (buf),
NULL, B_FALSE) == 0) {
NULL, literal) == 0) {
if (strlen(buf) > entry->pl_width)
entry->pl_width = strlen(buf);
}
Expand Down
2 changes: 1 addition & 1 deletion man/man8/zpool-list.8
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ See
.It Fl v
Verbose statistics.
Reports usage statistics for individual vdevs within the pool, in addition to
the pool-wise statistics.
the pool-wide statistics.
.El
.El
.Sh SEE ALSO
Expand Down