MFV r272493:
Show individual disk capacity when doing zpool list -v. Illumos issue: 5147 zpool list -v should show individual disk capacity MFC after: 1 week
This commit is contained in:
commit
7c2f66bb3b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=272502
@ -2857,10 +2857,7 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
|
|||||||
|
|
||||||
right_justify = B_FALSE;
|
right_justify = B_FALSE;
|
||||||
if (pl->pl_prop != ZPROP_INVAL) {
|
if (pl->pl_prop != ZPROP_INVAL) {
|
||||||
if (pl->pl_prop == ZPOOL_PROP_EXPANDSZ &&
|
if (zpool_get_prop(zhp, pl->pl_prop, property,
|
||||||
zpool_get_prop_int(zhp, pl->pl_prop, NULL) == 0)
|
|
||||||
propstr = "-";
|
|
||||||
else if (zpool_get_prop(zhp, pl->pl_prop, property,
|
|
||||||
sizeof (property), NULL, cb->cb_literal) != 0)
|
sizeof (property), NULL, cb->cb_literal) != 0)
|
||||||
propstr = "-";
|
propstr = "-";
|
||||||
else
|
else
|
||||||
@ -2894,21 +2891,37 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted)
|
print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted,
|
||||||
|
boolean_t valid)
|
||||||
{
|
{
|
||||||
char propval[64];
|
char propval[64];
|
||||||
boolean_t fixed;
|
boolean_t fixed;
|
||||||
size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL);
|
size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL);
|
||||||
|
|
||||||
|
switch (prop) {
|
||||||
if (prop == ZPOOL_PROP_EXPANDSZ && value == 0)
|
case ZPOOL_PROP_EXPANDSZ:
|
||||||
(void) strlcpy(propval, "-", sizeof (propval));
|
if (value == 0)
|
||||||
else if (prop == ZPOOL_PROP_FRAGMENTATION && value == ZFS_FRAG_INVALID)
|
(void) strlcpy(propval, "-", sizeof (propval));
|
||||||
(void) strlcpy(propval, "-", sizeof (propval));
|
else
|
||||||
else if (prop == ZPOOL_PROP_FRAGMENTATION)
|
zfs_nicenum(value, propval, sizeof (propval));
|
||||||
|
break;
|
||||||
|
case ZPOOL_PROP_FRAGMENTATION:
|
||||||
|
if (value == ZFS_FRAG_INVALID) {
|
||||||
|
(void) strlcpy(propval, "-", sizeof (propval));
|
||||||
|
} else {
|
||||||
|
(void) snprintf(propval, sizeof (propval), "%llu%%",
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ZPOOL_PROP_CAPACITY:
|
||||||
(void) snprintf(propval, sizeof (propval), "%llu%%", value);
|
(void) snprintf(propval, sizeof (propval), "%llu%%", value);
|
||||||
else
|
break;
|
||||||
|
default:
|
||||||
zfs_nicenum(value, propval, sizeof (propval));
|
zfs_nicenum(value, propval, sizeof (propval));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!valid)
|
||||||
|
(void) strlcpy(propval, "-", sizeof (propval));
|
||||||
|
|
||||||
if (scripted)
|
if (scripted)
|
||||||
(void) printf("\t%s", propval);
|
(void) printf("\t%s", propval);
|
||||||
@ -2930,6 +2943,9 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
|
|||||||
(uint64_t **)&vs, &c) == 0);
|
(uint64_t **)&vs, &c) == 0);
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
|
boolean_t toplevel = (vs->vs_space != 0);
|
||||||
|
uint64_t cap;
|
||||||
|
|
||||||
if (scripted)
|
if (scripted)
|
||||||
(void) printf("\t%s", name);
|
(void) printf("\t%s", name);
|
||||||
else if (strlen(name) + depth > cb->cb_namewidth)
|
else if (strlen(name) + depth > cb->cb_namewidth)
|
||||||
@ -2938,24 +2954,26 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
|
|||||||
(void) printf("%*s%s%*s", depth, "", name,
|
(void) printf("%*s%s%*s", depth, "", name,
|
||||||
(int)(cb->cb_namewidth - strlen(name) - depth), "");
|
(int)(cb->cb_namewidth - strlen(name) - depth), "");
|
||||||
|
|
||||||
/* only toplevel vdevs have capacity stats */
|
/*
|
||||||
if (vs->vs_space == 0) {
|
* Print the properties for the individual vdevs. Some
|
||||||
if (scripted)
|
* properties are only applicable to toplevel vdevs. The
|
||||||
(void) printf("\t-\t-\t-\t-");
|
* 'toplevel' boolean value is passed to the print_one_column()
|
||||||
else
|
* to indicate that the value is valid.
|
||||||
(void) printf(" - - - -");
|
*/
|
||||||
} else {
|
print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, scripted,
|
||||||
print_one_column(ZPOOL_PROP_SIZE, vs->vs_space,
|
toplevel);
|
||||||
scripted);
|
print_one_column(ZPOOL_PROP_ALLOCATED, vs->vs_alloc, scripted,
|
||||||
print_one_column(ZPOOL_PROP_CAPACITY, vs->vs_alloc,
|
toplevel);
|
||||||
scripted);
|
print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc,
|
||||||
print_one_column(ZPOOL_PROP_FREE,
|
scripted, toplevel);
|
||||||
vs->vs_space - vs->vs_alloc, scripted);
|
print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, scripted,
|
||||||
print_one_column(ZPOOL_PROP_FRAGMENTATION,
|
B_TRUE);
|
||||||
vs->vs_fragmentation, scripted);
|
print_one_column(ZPOOL_PROP_FRAGMENTATION,
|
||||||
}
|
vs->vs_fragmentation, scripted,
|
||||||
print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize,
|
(vs->vs_fragmentation != ZFS_FRAG_INVALID && toplevel));
|
||||||
scripted);
|
cap = (vs->vs_space == 0) ? 0 :
|
||||||
|
(vs->vs_alloc * 100 / vs->vs_space);
|
||||||
|
print_one_column(ZPOOL_PROP_CAPACITY, cap, scripted, toplevel);
|
||||||
(void) printf("\n");
|
(void) printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3024,7 +3042,8 @@ list_callback(zpool_handle_t *zhp, void *data)
|
|||||||
* -H Scripted mode. Don't display headers, and separate properties
|
* -H Scripted mode. Don't display headers, and separate properties
|
||||||
* by a single tab.
|
* by a single tab.
|
||||||
* -o List of properties to display. Defaults to
|
* -o List of properties to display. Defaults to
|
||||||
* "name,size,allocated,free,capacity,health,altroot"
|
* "name,size,allocated,free,expandsize,fragmentation,capacity,"
|
||||||
|
* "dedupratio,health,altroot"
|
||||||
* -p Diplay values in parsable (exact) format.
|
* -p Diplay values in parsable (exact) format.
|
||||||
* -T Display a timestamp in date(1) or Unix format
|
* -T Display a timestamp in date(1) or Unix format
|
||||||
*
|
*
|
||||||
@ -3038,7 +3057,7 @@ zpool_do_list(int argc, char **argv)
|
|||||||
int ret;
|
int ret;
|
||||||
list_cbdata_t cb = { 0 };
|
list_cbdata_t cb = { 0 };
|
||||||
static char default_props[] =
|
static char default_props[] =
|
||||||
"name,size,allocated,free,fragmentation,expandsize,capacity,"
|
"name,size,allocated,free,expandsize,fragmentation,capacity,"
|
||||||
"dedupratio,health,altroot";
|
"dedupratio,health,altroot";
|
||||||
char *props = default_props;
|
char *props = default_props;
|
||||||
unsigned long interval = 0, count = 0;
|
unsigned long interval = 0, count = 0;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
|
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
|
||||||
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
|
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -304,7 +304,6 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
|
|||||||
case ZPOOL_PROP_FREE:
|
case ZPOOL_PROP_FREE:
|
||||||
case ZPOOL_PROP_FREEING:
|
case ZPOOL_PROP_FREEING:
|
||||||
case ZPOOL_PROP_LEAKED:
|
case ZPOOL_PROP_LEAKED:
|
||||||
case ZPOOL_PROP_EXPANDSZ:
|
|
||||||
if (literal) {
|
if (literal) {
|
||||||
(void) snprintf(buf, len, "%llu",
|
(void) snprintf(buf, len, "%llu",
|
||||||
(u_longlong_t)intval);
|
(u_longlong_t)intval);
|
||||||
@ -312,7 +311,16 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
|
|||||||
(void) zfs_nicenum(intval, buf, len);
|
(void) zfs_nicenum(intval, buf, len);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ZPOOL_PROP_EXPANDSZ:
|
||||||
|
if (intval == 0) {
|
||||||
|
(void) strlcpy(buf, "-", len);
|
||||||
|
} else if (literal) {
|
||||||
|
(void) snprintf(buf, len, "%llu",
|
||||||
|
(u_longlong_t)intval);
|
||||||
|
} else {
|
||||||
|
(void) zfs_nicenum(intval, buf, len);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ZPOOL_PROP_CAPACITY:
|
case ZPOOL_PROP_CAPACITY:
|
||||||
if (literal) {
|
if (literal) {
|
||||||
(void) snprintf(buf, len, "%llu",
|
(void) snprintf(buf, len, "%llu",
|
||||||
@ -330,13 +338,11 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
|
|||||||
(u_longlong_t)intval);
|
(u_longlong_t)intval);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZPOOL_PROP_DEDUPRATIO:
|
case ZPOOL_PROP_DEDUPRATIO:
|
||||||
(void) snprintf(buf, len, "%llu.%02llux",
|
(void) snprintf(buf, len, "%llu.%02llux",
|
||||||
(u_longlong_t)(intval / 100),
|
(u_longlong_t)(intval / 100),
|
||||||
(u_longlong_t)(intval % 100));
|
(u_longlong_t)(intval % 100));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZPOOL_PROP_HEALTH:
|
case ZPOOL_PROP_HEALTH:
|
||||||
verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL),
|
verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL),
|
||||||
ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0);
|
ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user