Skip to content

Commit 1bd201e

Browse files
Chris Sidenbehlendorf
authored andcommitted
Illumos #1948: zpool list should show more detailed pool info
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
1 parent 95fd8c9 commit 1bd201e

File tree

16 files changed

+383
-67
lines changed

16 files changed

+383
-67
lines changed

cmd/zpool/zpool_main.c

Lines changed: 207 additions & 35 deletions
Large diffs are not rendered by default.

include/libzfs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/*
2323
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
2424
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25-
* Copyright (c) 2011 by Delphix. All rights reserved.
25+
* Copyright (c) 2012 by Delphix. All rights reserved.
2626
*/
2727

2828
#ifndef _LIBZFS_H
@@ -252,6 +252,7 @@ typedef struct splitflags {
252252
extern int zpool_scan(zpool_handle_t *, pool_scan_func_t);
253253
extern int zpool_clear(zpool_handle_t *, const char *, nvlist_t *);
254254
extern int zpool_reguid(zpool_handle_t *);
255+
extern int zpool_reopen(zpool_handle_t *);
255256

256257
extern int zpool_vdev_online(zpool_handle_t *, const char *, int,
257258
vdev_state_t *);

include/sys/fs/zfs.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/*
2323
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24-
* Copyright (c) 2011 by Delphix. All rights reserved.
24+
* Copyright (c) 2012 by Delphix. All rights reserved.
2525
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
2626
*/
2727

@@ -168,6 +168,7 @@ typedef enum {
168168
ZPOOL_PROP_READONLY,
169169
ZPOOL_PROP_ASHIFT,
170170
ZPOOL_PROP_COMMENT,
171+
ZPOOL_PROP_EXPANDSZ,
171172
ZPOOL_NUM_PROPS
172173
} zpool_prop_t;
173174

@@ -678,6 +679,7 @@ typedef struct vdev_stat {
678679
uint64_t vs_space; /* total capacity */
679680
uint64_t vs_dspace; /* deflated capacity */
680681
uint64_t vs_rsize; /* replaceable dev size */
682+
uint64_t vs_esize; /* expandable dev size */
681683
uint64_t vs_ops[ZIO_TYPES]; /* operation count */
682684
uint64_t vs_bytes[ZIO_TYPES]; /* bytes read/written */
683685
uint64_t vs_read_errors; /* read errors */
@@ -800,6 +802,7 @@ typedef enum zfs_ioc {
800802
ZFS_IOC_POOL_REGUID,
801803
ZFS_IOC_SPACE_WRITTEN,
802804
ZFS_IOC_SPACE_SNAPS,
805+
ZFS_IOC_POOL_REOPEN,
803806
} zfs_ioc_t;
804807

805808
/*

include/sys/vdev_impl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121
/*
2222
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23+
* Copyright (c) 2012 by Delphix. All rights reserved.
2324
*/
2425

2526
#ifndef _SYS_VDEV_IMPL_H
@@ -56,7 +57,8 @@ typedef struct vdev_cache_entry vdev_cache_entry_t;
5657
/*
5758
* Virtual device operations
5859
*/
59-
typedef int vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *ashift);
60+
typedef int vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *max_size,
61+
uint64_t *ashift);
6062
typedef void vdev_close_func_t(vdev_t *vd);
6163
typedef uint64_t vdev_asize_func_t(vdev_t *vd, uint64_t psize);
6264
typedef int vdev_io_start_func_t(zio_t *zio);
@@ -125,6 +127,7 @@ struct vdev {
125127
uint64_t vdev_orig_guid; /* orig. guid prior to remove */
126128
uint64_t vdev_asize; /* allocatable device capacity */
127129
uint64_t vdev_min_asize; /* min acceptable asize */
130+
uint64_t vdev_max_asize; /* max acceptable asize */
128131
uint64_t vdev_ashift; /* block alignment shift */
129132
uint64_t vdev_state; /* see VDEV_STATE_* #defines */
130133
uint64_t vdev_prevstate; /* used when reopening a vdev */

lib/libzfs/libzfs_pool.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/*
2323
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
2424
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25-
* Copyright (c) 2011 by Delphix. All rights reserved.
25+
* Copyright (c) 2012 by Delphix. All rights reserved.
2626
*/
2727

2828
#include <ctype.h>
@@ -273,6 +273,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
273273
case ZPOOL_PROP_SIZE:
274274
case ZPOOL_PROP_ALLOCATED:
275275
case ZPOOL_PROP_FREE:
276+
case ZPOOL_PROP_EXPANDSZ:
276277
case ZPOOL_PROP_ASHIFT:
277278
(void) zfs_nicenum(intval, buf, len);
278279
break;
@@ -361,8 +362,8 @@ pool_uses_efi(nvlist_t *config)
361362
return (B_FALSE);
362363
}
363364

364-
static boolean_t
365-
pool_is_bootable(zpool_handle_t *zhp)
365+
boolean_t
366+
zpool_is_bootable(zpool_handle_t *zhp)
366367
{
367368
char bootfs[ZPOOL_MAXNAMELEN];
368369

@@ -1127,7 +1128,7 @@ zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot)
11271128
return (zfs_error(hdl, EZFS_BADVERSION, msg));
11281129
}
11291130

1130-
if (pool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot,
1131+
if (zpool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot,
11311132
ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0) {
11321133
uint64_t s;
11331134

@@ -2374,7 +2375,7 @@ zpool_vdev_attach(zpool_handle_t *zhp,
23742375
uint_t children;
23752376
nvlist_t *config_root;
23762377
libzfs_handle_t *hdl = zhp->zpool_hdl;
2377-
boolean_t rootpool = pool_is_bootable(zhp);
2378+
boolean_t rootpool = zpool_is_bootable(zhp);
23782379

23792380
if (replacing)
23802381
(void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN,
@@ -3005,6 +3006,26 @@ zpool_reguid(zpool_handle_t *zhp)
30053006
return (zpool_standard_error(hdl, errno, msg));
30063007
}
30073008

3009+
/*
3010+
* Reopen the pool.
3011+
*/
3012+
int
3013+
zpool_reopen(zpool_handle_t *zhp)
3014+
{
3015+
zfs_cmd_t zc = { "\0", "\0", "\0", "\0", 0 };
3016+
char msg[1024];
3017+
libzfs_handle_t *hdl = zhp->zpool_hdl;
3018+
3019+
(void) snprintf(msg, sizeof (msg),
3020+
dgettext(TEXT_DOMAIN, "cannot reopen '%s'"),
3021+
zhp->zpool_name);
3022+
3023+
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
3024+
if (zfs_ioctl(hdl, ZFS_IOC_POOL_REOPEN, &zc) == 0)
3025+
return (0);
3026+
return (zpool_standard_error(hdl, errno, msg));
3027+
}
3028+
30083029
/*
30093030
* Convert from a devid string to a path.
30103031
*/
@@ -3798,7 +3819,7 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, char *name)
37983819
if (zhp) {
37993820
nvlist_t *nvroot;
38003821

3801-
if (pool_is_bootable(zhp)) {
3822+
if (zpool_is_bootable(zhp)) {
38023823
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
38033824
"EFI labeled devices are not supported on root "
38043825
"pools."));

man/man8/zpool.8

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'\" te
22
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
33
.\" Copyright 2011 Nexenta Systems, Inc. All rights reserved.
4+
.\" Copyright (c) 2012 by Delphix. All Rights Reserved.
45
.\" 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.
56
.\" 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
67
.\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
@@ -83,7 +84,7 @@ zpool \- configures ZFS storage pools
8384

8485
.LP
8586
.nf
86-
\fBzpool list\fR [\fB-H\fR] [\fB-o\fR \fIproperty\fR[,...]] [\fIpool\fR] ...
87+
\fBzpool list\fR [\fB-Hv\fR] [\fB-o\fR \fIproperty\fR[,...]] [\fIpool\fR] ...
8788
.fi
8889

8990
.LP
@@ -476,6 +477,18 @@ A text string consisting of printable ASCII characters that will be stored such
476477
.ne 2
477478
.mk
478479
.na
480+
\fB\fBexpandsize\fR\fR
481+
.ad
482+
.RS 20n
483+
Amount of uninitialized space within the pool or device that can be used to
484+
increase the total capacity of the pool. Uninitialized space consists of
485+
any space on an EFI labeled vdev which has not been brought online
486+
(i.e. zpool online -e). This space occurs when a LUN is dynamically expanded.
487+
.RE
488+
489+
.sp
490+
.ne 2
491+
.na
479492
\fB\fBhealth\fR\fR
480493
.ad
481494
.RS 20n
@@ -1312,7 +1325,7 @@ Verbose statistics. Reports usage statistics for individual \fIvdevs\fR within t
13121325
.ne 2
13131326
.mk
13141327
.na
1315-
\fB\fBzpool list\fR [\fB-H\fR] [\fB-o\fR \fIprops\fR[,...]] [\fIpool\fR] ...\fR
1328+
\fB\fBzpool list\fR [\fB-Hv\fR] [\fB-o\fR \fIprops\fR[,...]] [\fIpool\fR] ...\fR
13161329
.ad
13171330
.sp .6
13181331
.RS 4n
@@ -1336,7 +1349,18 @@ Scripted mode. Do not display headers, and separate fields by a single tab inste
13361349
.ad
13371350
.RS 12n
13381351
.rt
1339-
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"
1352+
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"
1353+
.RE
1354+
1355+
.sp
1356+
.ne 2
1357+
.mk
1358+
.na
1359+
\fB\fB-v\fR\fR
1360+
.ad
1361+
.RS 12n
1362+
.rt
1363+
Verbose statistics. Reports usage statistics for individual \fIvdevs\fR within the pool, in addition to the pool-wise statistics.
13401364
.RE
13411365

13421366
.RE
@@ -1649,10 +1673,10 @@ The results from this command are similar to the following:
16491673
.in +2
16501674
.nf
16511675
# \fBzpool list\fR
1652-
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
1653-
pool 67.5G 2.92M 67.5G 0% ONLINE -
1654-
tank 67.5G 2.92M 67.5G 0% ONLINE -
1655-
zion - - - 0% FAULTED -
1676+
NAME SIZE ALLOC FREE EXPANDSZ CAP DEDUP HEALTH ALTROOT
1677+
rpool 19.9G 8.43G 11.4G - 42% 1.00x ONLINE -
1678+
tank 61.5G 20.0G 41.5G - 32% 1.00x ONLINE -
1679+
zion - - - - - - FAULTED -
16561680
.fi
16571681
.in -2
16581682
.sp
@@ -1855,6 +1879,29 @@ The command to remove the mirrored log \fBmirror-2\fR is:
18551879
.in -2
18561880
.sp
18571881

1882+
.LP
1883+
\fBExample 15 \fRDisplaying expanded space on a device
1884+
.sp
1885+
.LP
1886+
The following command dipslays the detailed information for the \fIdata\fR
1887+
pool. This pool is comprised of a single \fIraidz\fR vdev where one of its
1888+
devices increased its capacity by 1GB. In this example, the pool will not
1889+
be able to utilized this extra capacity until all the devices under the
1890+
\fIraidz\fR vdev have been expanded.
1891+
1892+
.sp
1893+
.in +2
1894+
.nf
1895+
# \fBzpool list -v data\fR
1896+
NAME SIZE ALLOC FREE EXPANDSZ CAP DEDUP HEALTH ALTROOT
1897+
data 17.9G 174K 17.9G - 0% 1.00x ONLINE -
1898+
raidz1 17.9G 174K 17.9G -
1899+
c4t2d0 - - - 1G
1900+
c4t3d0 - - - -
1901+
c4t4d0 - - - -
1902+
.fi
1903+
.in -2
1904+
18581905
.SH EXIT STATUS
18591906
.sp
18601907
.LP

module/zcommon/zpool_prop.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/*
2222
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
2323
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24-
* Copyright (c) 2011 by Delphix. All rights reserved.
24+
* Copyright (c) 2012 by Delphix. All rights reserved.
2525
*/
2626

2727
#include <sys/zio.h>
@@ -81,6 +81,8 @@ zpool_prop_init(void)
8181
ZFS_TYPE_POOL, "<size>", "FREE");
8282
zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0,
8383
PROP_READONLY, ZFS_TYPE_POOL, "<size>", "ALLOC");
84+
zprop_register_number(ZPOOL_PROP_EXPANDSZ, "expandsize", 0,
85+
PROP_READONLY, ZFS_TYPE_POOL, "<size>", "EXPANDSZ");
8486
zprop_register_number(ZPOOL_PROP_CAPACITY, "capacity", 0, PROP_READONLY,
8587
ZFS_TYPE_POOL, "<size>", "CAP");
8688
zprop_register_number(ZPOOL_PROP_GUID, "guid", 0, PROP_READONLY,

module/zfs/spa.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/*
2323
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
2424
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25-
* Copyright (c) 2011 by Delphix. All rights reserved.
25+
* Copyright (c) 2012 by Delphix. All rights reserved.
2626
*/
2727

2828
/*
@@ -168,22 +168,34 @@ spa_prop_add_list(nvlist_t *nvl, zpool_prop_t prop, char *strval,
168168
static void
169169
spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
170170
{
171+
vdev_t *rvd = spa->spa_root_vdev;
171172
uint64_t size;
172173
uint64_t alloc;
174+
uint64_t space;
173175
uint64_t cap, version;
174176
zprop_source_t src = ZPROP_SRC_NONE;
175177
spa_config_dirent_t *dp;
178+
int c;
176179

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

179-
if (spa->spa_root_vdev != NULL) {
182+
if (rvd != NULL) {
180183
alloc = metaslab_class_get_alloc(spa_normal_class(spa));
181184
size = metaslab_class_get_space(spa_normal_class(spa));
182185
spa_prop_add_list(*nvp, ZPOOL_PROP_NAME, spa_name(spa), 0, src);
183186
spa_prop_add_list(*nvp, ZPOOL_PROP_SIZE, NULL, size, src);
184187
spa_prop_add_list(*nvp, ZPOOL_PROP_ALLOCATED, NULL, alloc, src);
185188
spa_prop_add_list(*nvp, ZPOOL_PROP_FREE, NULL,
186189
size - alloc, src);
190+
191+
space = 0;
192+
for (c = 0; c < rvd->vdev_children; c++) {
193+
vdev_t *tvd = rvd->vdev_child[c];
194+
space += tvd->vdev_max_asize - tvd->vdev_asize;
195+
}
196+
spa_prop_add_list(*nvp, ZPOOL_PROP_EXPANDSZ, NULL, space,
197+
src);
198+
187199
spa_prop_add_list(*nvp, ZPOOL_PROP_READONLY, NULL,
188200
(spa_mode(spa) == FREAD), src);
189201

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

196208
spa_prop_add_list(*nvp, ZPOOL_PROP_HEALTH, NULL,
197-
spa->spa_root_vdev->vdev_state, src);
209+
rvd->vdev_state, src);
198210

199211
version = spa_version(spa);
200212
if (version == zpool_prop_default_numeric(ZPOOL_PROP_VERSION))

0 commit comments

Comments
 (0)