mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-04-17 08:54:52 +03:00
zpool: fix conflict with -v and -o options
Right now, the -v and -o options for `zpool list` work independently, but when paired, the -v "wins out" and the -o effect is lost. This commit fixes that problem. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Rob Norris <robn@despairlabs.com> Signed-off-by: Shreshth Srivastava <shreshthsrivastava2@gmail.com> Closes #11040 Closes #17839
This commit is contained in:
parent
22b959d2e5
commit
c4ad5e2938
@ -7005,7 +7005,6 @@ collect_vdev_prop(zpool_prop_t prop, uint64_t value, const char *str,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* print static default line per vdev
|
* print static default line per vdev
|
||||||
* not compatible with '-o' <proplist> option
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
collect_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
|
collect_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
|
||||||
@ -7059,48 +7058,98 @@ collect_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
|
|||||||
* 'toplevel' boolean value is passed to the print_one_column()
|
* 'toplevel' boolean value is passed to the print_one_column()
|
||||||
* to indicate that the value is valid.
|
* to indicate that the value is valid.
|
||||||
*/
|
*/
|
||||||
if (VDEV_STAT_VALID(vs_pspace, c) && vs->vs_pspace) {
|
for (zprop_list_t *pl = cb->cb_proplist; pl != NULL;
|
||||||
collect_vdev_prop(ZPOOL_PROP_SIZE, vs->vs_pspace, NULL,
|
pl = pl->pl_next) {
|
||||||
scripted, B_TRUE, format, cb->cb_json, props,
|
switch (pl->pl_prop) {
|
||||||
cb->cb_json_as_int);
|
case ZPOOL_PROP_SIZE:
|
||||||
} else {
|
if (VDEV_STAT_VALID(vs_pspace, c) &&
|
||||||
collect_vdev_prop(ZPOOL_PROP_SIZE, vs->vs_space, NULL,
|
vs->vs_pspace) {
|
||||||
scripted, toplevel, format, cb->cb_json, props,
|
collect_vdev_prop(
|
||||||
cb->cb_json_as_int);
|
ZPOOL_PROP_SIZE, vs->vs_pspace,
|
||||||
|
NULL, scripted, B_TRUE, format,
|
||||||
|
cb->cb_json, props,
|
||||||
|
cb->cb_json_as_int);
|
||||||
|
} else {
|
||||||
|
collect_vdev_prop(
|
||||||
|
ZPOOL_PROP_SIZE, vs->vs_space, NULL,
|
||||||
|
scripted, toplevel, format,
|
||||||
|
cb->cb_json, props,
|
||||||
|
cb->cb_json_as_int);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ZPOOL_PROP_ALLOCATED:
|
||||||
|
collect_vdev_prop(ZPOOL_PROP_ALLOCATED,
|
||||||
|
vs->vs_alloc, NULL, scripted, toplevel,
|
||||||
|
format, cb->cb_json, props,
|
||||||
|
cb->cb_json_as_int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZPOOL_PROP_FREE:
|
||||||
|
collect_vdev_prop(ZPOOL_PROP_FREE,
|
||||||
|
vs->vs_space - vs->vs_alloc, NULL, scripted,
|
||||||
|
toplevel, format, cb->cb_json, props,
|
||||||
|
cb->cb_json_as_int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZPOOL_PROP_CHECKPOINT:
|
||||||
|
collect_vdev_prop(ZPOOL_PROP_CHECKPOINT,
|
||||||
|
vs->vs_checkpoint_space, NULL, scripted,
|
||||||
|
toplevel, format, cb->cb_json, props,
|
||||||
|
cb->cb_json_as_int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZPOOL_PROP_EXPANDSZ:
|
||||||
|
collect_vdev_prop(ZPOOL_PROP_EXPANDSZ,
|
||||||
|
vs->vs_esize, NULL, scripted, B_TRUE,
|
||||||
|
format, cb->cb_json, props,
|
||||||
|
cb->cb_json_as_int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZPOOL_PROP_FRAGMENTATION:
|
||||||
|
collect_vdev_prop(
|
||||||
|
ZPOOL_PROP_FRAGMENTATION,
|
||||||
|
vs->vs_fragmentation, NULL, scripted,
|
||||||
|
(vs->vs_fragmentation != ZFS_FRAG_INVALID &&
|
||||||
|
toplevel),
|
||||||
|
format, cb->cb_json, props,
|
||||||
|
cb->cb_json_as_int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZPOOL_PROP_CAPACITY:
|
||||||
|
cap = (vs->vs_space == 0) ?
|
||||||
|
0 : (vs->vs_alloc * 10000 / vs->vs_space);
|
||||||
|
collect_vdev_prop(ZPOOL_PROP_CAPACITY, cap,
|
||||||
|
NULL, scripted, toplevel, format,
|
||||||
|
cb->cb_json, props, cb->cb_json_as_int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZPOOL_PROP_HEALTH:
|
||||||
|
state = zpool_state_to_name(vs->vs_state,
|
||||||
|
vs->vs_aux);
|
||||||
|
if (isspare) {
|
||||||
|
if (vs->vs_aux == VDEV_AUX_SPARED)
|
||||||
|
state = "INUSE";
|
||||||
|
else if (vs->vs_state ==
|
||||||
|
VDEV_STATE_HEALTHY)
|
||||||
|
state = "AVAIL";
|
||||||
|
}
|
||||||
|
collect_vdev_prop(ZPOOL_PROP_HEALTH, 0, state,
|
||||||
|
scripted, B_TRUE, format, cb->cb_json,
|
||||||
|
props, cb->cb_json_as_int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZPOOL_PROP_NAME:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
collect_vdev_prop(pl->pl_prop, 0,
|
||||||
|
NULL, scripted, B_FALSE, format,
|
||||||
|
cb->cb_json, props, cb->cb_json_as_int);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
collect_vdev_prop(ZPOOL_PROP_ALLOCATED, vs->vs_alloc, NULL,
|
|
||||||
scripted, toplevel, format, cb->cb_json, props,
|
|
||||||
cb->cb_json_as_int);
|
|
||||||
collect_vdev_prop(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc,
|
|
||||||
NULL, scripted, toplevel, format, cb->cb_json, props,
|
|
||||||
cb->cb_json_as_int);
|
|
||||||
collect_vdev_prop(ZPOOL_PROP_CHECKPOINT,
|
|
||||||
vs->vs_checkpoint_space, NULL, scripted, toplevel, format,
|
|
||||||
cb->cb_json, props, cb->cb_json_as_int);
|
|
||||||
collect_vdev_prop(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, NULL,
|
|
||||||
scripted, B_TRUE, format, cb->cb_json, props,
|
|
||||||
cb->cb_json_as_int);
|
|
||||||
collect_vdev_prop(ZPOOL_PROP_FRAGMENTATION,
|
|
||||||
vs->vs_fragmentation, NULL, scripted,
|
|
||||||
(vs->vs_fragmentation != ZFS_FRAG_INVALID && toplevel),
|
|
||||||
format, cb->cb_json, props, cb->cb_json_as_int);
|
|
||||||
cap = (vs->vs_space == 0) ? 0 :
|
|
||||||
(vs->vs_alloc * 10000 / vs->vs_space);
|
|
||||||
collect_vdev_prop(ZPOOL_PROP_CAPACITY, cap, NULL,
|
|
||||||
scripted, toplevel, format, cb->cb_json, props,
|
|
||||||
cb->cb_json_as_int);
|
|
||||||
collect_vdev_prop(ZPOOL_PROP_DEDUPRATIO, 0, NULL,
|
|
||||||
scripted, toplevel, format, cb->cb_json, props,
|
|
||||||
cb->cb_json_as_int);
|
|
||||||
state = zpool_state_to_name(vs->vs_state, vs->vs_aux);
|
|
||||||
if (isspare) {
|
|
||||||
if (vs->vs_aux == VDEV_AUX_SPARED)
|
|
||||||
state = "INUSE";
|
|
||||||
else if (vs->vs_state == VDEV_STATE_HEALTHY)
|
|
||||||
state = "AVAIL";
|
|
||||||
}
|
|
||||||
collect_vdev_prop(ZPOOL_PROP_HEALTH, 0, state, scripted,
|
|
||||||
B_TRUE, format, cb->cb_json, props, cb->cb_json_as_int);
|
|
||||||
|
|
||||||
if (cb->cb_json) {
|
if (cb->cb_json) {
|
||||||
fnvlist_add_nvlist(ent, "properties", props);
|
fnvlist_add_nvlist(ent, "properties", props);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user