Skip to content

Commit

Permalink
Illumos #1948: zpool list should show more detailed pool info
Browse files Browse the repository at this point in the history
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Albert Lee <trisk@nexenta.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Eric Schrock <eric.schrock@delphix.com>

References:
  https://www.illumos.org/issues/1948

Ported by:	Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #685
  • Loading branch information
Chris Siden authored and behlendorf committed Sep 19, 2012
1 parent 95fd8c9 commit 1bd201e
Show file tree
Hide file tree
Showing 16 changed files with 383 additions and 67 deletions.
242 changes: 207 additions & 35 deletions cmd/zpool/zpool_main.c

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
*/

#ifndef _LIBZFS_H
Expand Down Expand Up @@ -252,6 +252,7 @@ typedef struct splitflags {
extern int zpool_scan(zpool_handle_t *, pool_scan_func_t);
extern int zpool_clear(zpool_handle_t *, const char *, nvlist_t *);
extern int zpool_reguid(zpool_handle_t *);
extern int zpool_reopen(zpool_handle_t *);

extern int zpool_vdev_online(zpool_handle_t *, const char *, int,
vdev_state_t *);
Expand Down
5 changes: 4 additions & 1 deletion include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/

Expand Down Expand Up @@ -168,6 +168,7 @@ typedef enum {
ZPOOL_PROP_READONLY,
ZPOOL_PROP_ASHIFT,
ZPOOL_PROP_COMMENT,
ZPOOL_PROP_EXPANDSZ,
ZPOOL_NUM_PROPS
} zpool_prop_t;

Expand Down Expand Up @@ -678,6 +679,7 @@ typedef struct vdev_stat {
uint64_t vs_space; /* total capacity */
uint64_t vs_dspace; /* deflated capacity */
uint64_t vs_rsize; /* replaceable dev size */
uint64_t vs_esize; /* expandable dev size */
uint64_t vs_ops[ZIO_TYPES]; /* operation count */
uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */
uint64_t vs_read_errors; /* read errors */
Expand Down Expand Up @@ -800,6 +802,7 @@ typedef enum zfs_ioc {
ZFS_IOC_POOL_REGUID,
ZFS_IOC_SPACE_WRITTEN,
ZFS_IOC_SPACE_SNAPS,
ZFS_IOC_POOL_REOPEN,
} zfs_ioc_t;

/*
Expand Down
5 changes: 4 additions & 1 deletion include/sys/vdev_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
*/

#ifndef _SYS_VDEV_IMPL_H
Expand Down Expand Up @@ -56,7 +57,8 @@ typedef struct vdev_cache_entry vdev_cache_entry_t;
/*
* Virtual device operations
*/
typedef int vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *ashift);
typedef int vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *max_size,
uint64_t *ashift);
typedef void vdev_close_func_t(vdev_t *vd);
typedef uint64_t vdev_asize_func_t(vdev_t *vd, uint64_t psize);
typedef int vdev_io_start_func_t(zio_t *zio);
Expand Down Expand Up @@ -125,6 +127,7 @@ struct vdev {
uint64_t vdev_orig_guid; /* orig. guid prior to remove */
uint64_t vdev_asize; /* allocatable device capacity */
uint64_t vdev_min_asize; /* min acceptable asize */
uint64_t vdev_max_asize; /* max acceptable asize */
uint64_t vdev_ashift; /* block alignment shift */
uint64_t vdev_state; /* see VDEV_STATE_* #defines */
uint64_t vdev_prevstate; /* used when reopening a vdev */
Expand Down
33 changes: 27 additions & 6 deletions lib/libzfs/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
*/

#include <ctype.h>
Expand Down Expand Up @@ -273,6 +273,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
case ZPOOL_PROP_SIZE:
case ZPOOL_PROP_ALLOCATED:
case ZPOOL_PROP_FREE:
case ZPOOL_PROP_EXPANDSZ:
case ZPOOL_PROP_ASHIFT:
(void) zfs_nicenum(intval, buf, len);
break;
Expand Down Expand Up @@ -361,8 +362,8 @@ pool_uses_efi(nvlist_t *config)
return (B_FALSE);
}

static boolean_t
pool_is_bootable(zpool_handle_t *zhp)
boolean_t
zpool_is_bootable(zpool_handle_t *zhp)
{
char bootfs[ZPOOL_MAXNAMELEN];

Expand Down Expand Up @@ -1127,7 +1128,7 @@ zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot)
return (zfs_error(hdl, EZFS_BADVERSION, msg));
}

if (pool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot,
if (zpool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot,
ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0) {
uint64_t s;

Expand Down Expand Up @@ -2374,7 +2375,7 @@ zpool_vdev_attach(zpool_handle_t *zhp,
uint_t children;
nvlist_t *config_root;
libzfs_handle_t *hdl = zhp->zpool_hdl;
boolean_t rootpool = pool_is_bootable(zhp);
boolean_t rootpool = zpool_is_bootable(zhp);

if (replacing)
(void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN,
Expand Down Expand Up @@ -3005,6 +3006,26 @@ zpool_reguid(zpool_handle_t *zhp)
return (zpool_standard_error(hdl, errno, msg));
}

/*
* Reopen the pool.
*/
int
zpool_reopen(zpool_handle_t *zhp)
{
zfs_cmd_t zc = { "\0", "\0", "\0", "\0", 0 };
char msg[1024];
libzfs_handle_t *hdl = zhp->zpool_hdl;

(void) snprintf(msg, sizeof (msg),
dgettext(TEXT_DOMAIN, "cannot reopen '%s'"),
zhp->zpool_name);

(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
if (zfs_ioctl(hdl, ZFS_IOC_POOL_REOPEN, &zc) == 0)
return (0);
return (zpool_standard_error(hdl, errno, msg));
}

/*
* Convert from a devid string to a path.
*/
Expand Down Expand Up @@ -3798,7 +3819,7 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, char *name)
if (zhp) {
nvlist_t *nvroot;

if (pool_is_bootable(zhp)) {
if (zpool_is_bootable(zhp)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"EFI labeled devices are not supported on root "
"pools."));
Expand Down
61 changes: 54 additions & 7 deletions man/man8/zpool.8
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'\" te
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 2011 Nexenta Systems, Inc. All rights reserved.
.\" Copyright (c) 2012 by Delphix. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
Expand Down Expand Up @@ -83,7 +84,7 @@ zpool \- configures ZFS storage pools

.LP
.nf
\fBzpool list\fR [\fB-H\fR] [\fB-o\fR \fIproperty\fR[,...]] [\fIpool\fR] ...
\fBzpool list\fR [\fB-Hv\fR] [\fB-o\fR \fIproperty\fR[,...]] [\fIpool\fR] ...
.fi

.LP
Expand Down Expand Up @@ -476,6 +477,18 @@ A text string consisting of printable ASCII characters that will be stored such
.ne 2
.mk
.na
\fB\fBexpandsize\fR\fR
.ad
.RS 20n
Amount of uninitialized space within the pool or device that can be used to
increase the total capacity of the pool. Uninitialized space consists of
any space on an EFI labeled vdev which has not been brought online
(i.e. zpool online -e). This space occurs when a LUN is dynamically expanded.
.RE

.sp
.ne 2
.na
\fB\fBhealth\fR\fR
.ad
.RS 20n
Expand Down Expand Up @@ -1312,7 +1325,7 @@ Verbose statistics. Reports usage statistics for individual \fIvdevs\fR within t
.ne 2
.mk
.na
\fB\fBzpool list\fR [\fB-H\fR] [\fB-o\fR \fIprops\fR[,...]] [\fIpool\fR] ...\fR
\fB\fBzpool list\fR [\fB-Hv\fR] [\fB-o\fR \fIprops\fR[,...]] [\fIpool\fR] ...\fR
.ad
.sp .6
.RS 4n
Expand All @@ -1336,7 +1349,18 @@ Scripted mode. Do not display headers, and separate fields by a single tab inste
.ad
.RS 12n
.rt
Comma-separated list of properties to display. See the "Properties" section for a list of valid properties. The default list is "name, size, used, available, capacity, health, altroot"
Comma-separated list of properties to display. See the "Properties" section for a list of valid properties. The default list is "name, size, used, available, expandsize, capacity, dedupratio, health, altroot"
.RE

.sp
.ne 2
.mk
.na
\fB\fB-v\fR\fR
.ad
.RS 12n
.rt
Verbose statistics. Reports usage statistics for individual \fIvdevs\fR within the pool, in addition to the pool-wise statistics.
.RE

.RE
Expand Down Expand Up @@ -1649,10 +1673,10 @@ The results from this command are similar to the following:
.in +2
.nf
# \fBzpool list\fR
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
pool 67.5G 2.92M 67.5G 0% ONLINE -
tank 67.5G 2.92M 67.5G 0% ONLINE -
zion - - - 0% FAULTED -
NAME SIZE ALLOC FREE EXPANDSZ CAP DEDUP HEALTH ALTROOT
rpool 19.9G 8.43G 11.4G - 42% 1.00x ONLINE -
tank 61.5G 20.0G 41.5G - 32% 1.00x ONLINE -
zion - - - - - - FAULTED -
.fi
.in -2
.sp
Expand Down Expand Up @@ -1855,6 +1879,29 @@ The command to remove the mirrored log \fBmirror-2\fR is:
.in -2
.sp

.LP
\fBExample 15 \fRDisplaying expanded space on a device
.sp
.LP
The following command dipslays the detailed information for the \fIdata\fR
pool. This pool is comprised of a single \fIraidz\fR vdev where one of its
devices increased its capacity by 1GB. In this example, the pool will not
be able to utilized this extra capacity until all the devices under the
\fIraidz\fR vdev have been expanded.

.sp
.in +2
.nf
# \fBzpool list -v data\fR
NAME SIZE ALLOC FREE EXPANDSZ CAP DEDUP HEALTH ALTROOT
data 17.9G 174K 17.9G - 0% 1.00x ONLINE -
raidz1 17.9G 174K 17.9G -
c4t2d0 - - - 1G
c4t3d0 - - - -
c4t4d0 - - - -
.fi
.in -2

.SH EXIT STATUS
.sp
.LP
Expand Down
4 changes: 3 additions & 1 deletion module/zcommon/zpool_prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
*/

#include <sys/zio.h>
Expand Down Expand Up @@ -81,6 +81,8 @@ zpool_prop_init(void)
ZFS_TYPE_POOL, "<size>", "FREE");
zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0,
PROP_READONLY, ZFS_TYPE_POOL, "<size>", "ALLOC");
zprop_register_number(ZPOOL_PROP_EXPANDSZ, "expandsize", 0,
PROP_READONLY, ZFS_TYPE_POOL, "<size>", "EXPANDSZ");
zprop_register_number(ZPOOL_PROP_CAPACITY, "capacity", 0, PROP_READONLY,
ZFS_TYPE_POOL, "<size>", "CAP");
zprop_register_number(ZPOOL_PROP_GUID, "guid", 0, PROP_READONLY,
Expand Down
18 changes: 15 additions & 3 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
*/

/*
Expand Down Expand Up @@ -168,22 +168,34 @@ spa_prop_add_list(nvlist_t *nvl, zpool_prop_t prop, char *strval,
static void
spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
{
vdev_t *rvd = spa->spa_root_vdev;
uint64_t size;
uint64_t alloc;
uint64_t space;
uint64_t cap, version;
zprop_source_t src = ZPROP_SRC_NONE;
spa_config_dirent_t *dp;
int c;

ASSERT(MUTEX_HELD(&spa->spa_props_lock));

if (spa->spa_root_vdev != NULL) {
if (rvd != NULL) {
alloc = metaslab_class_get_alloc(spa_normal_class(spa));
size = metaslab_class_get_space(spa_normal_class(spa));
spa_prop_add_list(*nvp, ZPOOL_PROP_NAME, spa_name(spa), 0, src);
spa_prop_add_list(*nvp, ZPOOL_PROP_SIZE, NULL, size, src);
spa_prop_add_list(*nvp, ZPOOL_PROP_ALLOCATED, NULL, alloc, src);
spa_prop_add_list(*nvp, ZPOOL_PROP_FREE, NULL,
size - alloc, src);

space = 0;
for (c = 0; c < rvd->vdev_children; c++) {
vdev_t *tvd = rvd->vdev_child[c];
space += tvd->vdev_max_asize - tvd->vdev_asize;
}
spa_prop_add_list(*nvp, ZPOOL_PROP_EXPANDSZ, NULL, space,
src);

spa_prop_add_list(*nvp, ZPOOL_PROP_READONLY, NULL,
(spa_mode(spa) == FREAD), src);

Expand All @@ -194,7 +206,7 @@ spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
ddt_get_pool_dedup_ratio(spa), src);

spa_prop_add_list(*nvp, ZPOOL_PROP_HEALTH, NULL,
spa->spa_root_vdev->vdev_state, src);
rvd->vdev_state, src);

version = spa_version(spa);
if (version == zpool_prop_default_numeric(ZPOOL_PROP_VERSION))
Expand Down
Loading

0 comments on commit 1bd201e

Please sign in to comment.