From owner-svn-src-vendor@FreeBSD.ORG Sat Oct 4 07:24:36 2014 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8724D419; Sat, 4 Oct 2014 07:24:36 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 72D25D14; Sat, 4 Oct 2014 07:24:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s947Oa0n079328; Sat, 4 Oct 2014 07:24:36 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s947OapX079325; Sat, 4 Oct 2014 07:24:36 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201410040724.s947OapX079325@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sat, 4 Oct 2014 07:24:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r272493 - in vendor/illumos/dist: cmd/zpool lib/libzfs/common X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Oct 2014 07:24:36 -0000 Author: delphij Date: Sat Oct 4 07:24:35 2014 New Revision: 272493 URL: https://svnweb.freebsd.org/changeset/base/272493 Log: 5147 zpool list -v should show individual disk capacity Reviewed by: Adam Leventhal Reviewed by: Christopher Siden Reviewed by: Matthew Ahrens Reviewed by: Richard Elling Approved by: Dan McDonald Author: George Wilson illumos/illumos-gate@7a09f97bc0d52b763c580864e78a665b15be37f8 Modified: vendor/illumos/dist/cmd/zpool/zpool_main.c vendor/illumos/dist/lib/libzfs/common/libzfs_pool.c Modified: vendor/illumos/dist/cmd/zpool/zpool_main.c ============================================================================== --- vendor/illumos/dist/cmd/zpool/zpool_main.c Sat Oct 4 06:01:30 2014 (r272492) +++ vendor/illumos/dist/cmd/zpool/zpool_main.c Sat Oct 4 07:24:35 2014 (r272493) @@ -2711,10 +2711,7 @@ print_pool(zpool_handle_t *zhp, list_cbd right_justify = B_FALSE; if (pl->pl_prop != ZPROP_INVAL) { - if (pl->pl_prop == ZPOOL_PROP_EXPANDSZ && - zpool_get_prop_int(zhp, pl->pl_prop, NULL) == 0) - propstr = "-"; - else if (zpool_get_prop(zhp, pl->pl_prop, property, + if (zpool_get_prop(zhp, pl->pl_prop, property, sizeof (property), NULL, cb->cb_literal) != 0) propstr = "-"; else @@ -2748,21 +2745,37 @@ print_pool(zpool_handle_t *zhp, list_cbd } 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]; boolean_t fixed; size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL); - - if (prop == ZPOOL_PROP_EXPANDSZ && value == 0) - (void) strlcpy(propval, "-", sizeof (propval)); - else if (prop == ZPOOL_PROP_FRAGMENTATION && value == ZFS_FRAG_INVALID) - (void) strlcpy(propval, "-", sizeof (propval)); - else if (prop == ZPOOL_PROP_FRAGMENTATION) + switch (prop) { + case ZPOOL_PROP_EXPANDSZ: + if (value == 0) + (void) strlcpy(propval, "-", sizeof (propval)); + else + 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); - else + break; + default: zfs_nicenum(value, propval, sizeof (propval)); + } + + if (!valid) + (void) strlcpy(propval, "-", sizeof (propval)); if (scripted) (void) printf("\t%s", propval); @@ -2784,6 +2797,9 @@ print_list_stats(zpool_handle_t *zhp, co (uint64_t **)&vs, &c) == 0); if (name != NULL) { + boolean_t toplevel = (vs->vs_space != 0); + uint64_t cap; + if (scripted) (void) printf("\t%s", name); else if (strlen(name) + depth > cb->cb_namewidth) @@ -2792,24 +2808,26 @@ print_list_stats(zpool_handle_t *zhp, co (void) printf("%*s%s%*s", depth, "", name, (int)(cb->cb_namewidth - strlen(name) - depth), ""); - /* only toplevel vdevs have capacity stats */ - if (vs->vs_space == 0) { - if (scripted) - (void) printf("\t-\t-\t-\t-"); - else - (void) printf(" - - - -"); - } else { - print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, - scripted); - print_one_column(ZPOOL_PROP_CAPACITY, vs->vs_alloc, - scripted); - print_one_column(ZPOOL_PROP_FREE, - vs->vs_space - vs->vs_alloc, scripted); - print_one_column(ZPOOL_PROP_FRAGMENTATION, - vs->vs_fragmentation, scripted); - } - print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, - scripted); + /* + * Print the properties for the individual vdevs. Some + * properties are only applicable to toplevel vdevs. The + * 'toplevel' boolean value is passed to the print_one_column() + * to indicate that the value is valid. + */ + print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, scripted, + toplevel); + print_one_column(ZPOOL_PROP_ALLOCATED, vs->vs_alloc, scripted, + toplevel); + print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc, + scripted, toplevel); + print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, scripted, + B_TRUE); + print_one_column(ZPOOL_PROP_FRAGMENTATION, + vs->vs_fragmentation, scripted, + (vs->vs_fragmentation != ZFS_FRAG_INVALID && toplevel)); + 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"); } @@ -2878,7 +2896,8 @@ list_callback(zpool_handle_t *zhp, void * -H Scripted mode. Don't display headers, and separate properties * by a single tab. * -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. * -T Display a timestamp in date(1) or Unix format * @@ -2892,7 +2911,7 @@ zpool_do_list(int argc, char **argv) int ret; list_cbdata_t cb = { 0 }; static char default_props[] = - "name,size,allocated,free,fragmentation,expandsize,capacity," + "name,size,allocated,free,expandsize,fragmentation,capacity," "dedupratio,health,altroot"; char *props = default_props; unsigned long interval = 0, count = 0; Modified: vendor/illumos/dist/lib/libzfs/common/libzfs_pool.c ============================================================================== --- vendor/illumos/dist/lib/libzfs/common/libzfs_pool.c Sat Oct 4 06:01:30 2014 (r272492) +++ vendor/illumos/dist/lib/libzfs/common/libzfs_pool.c Sat Oct 4 07:24:35 2014 (r272493) @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. */ @@ -276,7 +276,6 @@ zpool_get_prop(zpool_handle_t *zhp, zpoo case ZPOOL_PROP_FREE: case ZPOOL_PROP_FREEING: case ZPOOL_PROP_LEAKED: - case ZPOOL_PROP_EXPANDSZ: if (literal) { (void) snprintf(buf, len, "%llu", (u_longlong_t)intval); @@ -284,7 +283,16 @@ zpool_get_prop(zpool_handle_t *zhp, zpoo (void) zfs_nicenum(intval, buf, len); } 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: if (literal) { (void) snprintf(buf, len, "%llu", @@ -302,13 +310,11 @@ zpool_get_prop(zpool_handle_t *zhp, zpoo (u_longlong_t)intval); } break; - case ZPOOL_PROP_DEDUPRATIO: (void) snprintf(buf, len, "%llu.%02llux", (u_longlong_t)(intval / 100), (u_longlong_t)(intval % 100)); break; - case ZPOOL_PROP_HEALTH: verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL), ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0);