mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
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
This commit is contained in:
committed by
Brian Behlendorf
parent
95fd8c9a7f
commit
1bd201e70d
@@ -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>
|
||||
@@ -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,
|
||||
|
||||
+15
-3
@@ -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.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -168,15 +168,18 @@ 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);
|
||||
@@ -184,6 +187,15 @@ spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
|
||||
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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
+13
-4
@@ -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 <sys/zfs_context.h>
|
||||
@@ -109,7 +109,7 @@ vdev_get_min_asize(vdev_t *vd)
|
||||
vdev_t *pvd = vd->vdev_parent;
|
||||
|
||||
/*
|
||||
* The our parent is NULL (inactive spare or cache) or is the root,
|
||||
* If our parent is NULL (inactive spare or cache) or is the root,
|
||||
* just return our own asize.
|
||||
*/
|
||||
if (pvd == NULL)
|
||||
@@ -747,6 +747,7 @@ vdev_add_parent(vdev_t *cvd, vdev_ops_t *ops)
|
||||
|
||||
mvd->vdev_asize = cvd->vdev_asize;
|
||||
mvd->vdev_min_asize = cvd->vdev_min_asize;
|
||||
mvd->vdev_max_asize = cvd->vdev_max_asize;
|
||||
mvd->vdev_ashift = cvd->vdev_ashift;
|
||||
mvd->vdev_state = cvd->vdev_state;
|
||||
mvd->vdev_crtxg = cvd->vdev_crtxg;
|
||||
@@ -1132,7 +1133,8 @@ vdev_open(vdev_t *vd)
|
||||
spa_t *spa = vd->vdev_spa;
|
||||
int error;
|
||||
uint64_t osize = 0;
|
||||
uint64_t asize, psize;
|
||||
uint64_t max_osize = 0;
|
||||
uint64_t asize, max_asize, psize;
|
||||
uint64_t ashift = 0;
|
||||
int c;
|
||||
|
||||
@@ -1164,7 +1166,7 @@ vdev_open(vdev_t *vd)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
error = vd->vdev_ops->vdev_op_open(vd, &osize, &ashift);
|
||||
error = vd->vdev_ops->vdev_op_open(vd, &osize, &max_osize, &ashift);
|
||||
|
||||
/*
|
||||
* Reset the vdev_reopening flag so that we actually close
|
||||
@@ -1222,6 +1224,7 @@ vdev_open(vdev_t *vd)
|
||||
}
|
||||
|
||||
osize = P2ALIGN(osize, (uint64_t)sizeof (vdev_label_t));
|
||||
max_osize = P2ALIGN(max_osize, (uint64_t)sizeof (vdev_label_t));
|
||||
|
||||
if (vd->vdev_children == 0) {
|
||||
if (osize < SPA_MINDEVSIZE) {
|
||||
@@ -1231,6 +1234,8 @@ vdev_open(vdev_t *vd)
|
||||
}
|
||||
psize = osize;
|
||||
asize = osize - (VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE);
|
||||
max_asize = max_osize - (VDEV_LABEL_START_SIZE +
|
||||
VDEV_LABEL_END_SIZE);
|
||||
} else {
|
||||
if (vd->vdev_parent != NULL && osize < SPA_MINDEVSIZE -
|
||||
(VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE)) {
|
||||
@@ -1240,6 +1245,7 @@ vdev_open(vdev_t *vd)
|
||||
}
|
||||
psize = 0;
|
||||
asize = osize;
|
||||
max_asize = max_osize;
|
||||
}
|
||||
|
||||
vd->vdev_psize = psize;
|
||||
@@ -1259,6 +1265,7 @@ vdev_open(vdev_t *vd)
|
||||
* For testing purposes, a higher ashift can be requested.
|
||||
*/
|
||||
vd->vdev_asize = asize;
|
||||
vd->vdev_max_asize = max_asize;
|
||||
vd->vdev_ashift = MAX(ashift, vd->vdev_ashift);
|
||||
} else {
|
||||
/*
|
||||
@@ -1269,6 +1276,7 @@ vdev_open(vdev_t *vd)
|
||||
VDEV_AUX_BAD_LABEL);
|
||||
return (EINVAL);
|
||||
}
|
||||
vd->vdev_max_asize = max_asize;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2499,6 +2507,7 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t *vs)
|
||||
vs->vs_rsize = vdev_get_min_asize(vd);
|
||||
if (vd->vdev_ops->vdev_op_leaf)
|
||||
vs->vs_rsize += VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE;
|
||||
vs->vs_esize = vd->vdev_max_asize - vd->vdev_asize;
|
||||
mutex_exit(&vd->vdev_stat_lock);
|
||||
|
||||
/*
|
||||
|
||||
@@ -224,7 +224,8 @@ vdev_disk_rrpart(const char *path, int mode, vdev_disk_t *vd)
|
||||
}
|
||||
|
||||
static int
|
||||
vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *ashift)
|
||||
vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
|
||||
uint64_t *ashift)
|
||||
{
|
||||
struct block_device *bdev = ERR_PTR(-ENXIO);
|
||||
vdev_disk_t *vd;
|
||||
@@ -288,6 +289,9 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *ashift)
|
||||
/* Physical volume size in bytes */
|
||||
*psize = bdev_capacity(bdev);
|
||||
|
||||
/* TODO: report possible expansion size */
|
||||
*max_psize = *psize;
|
||||
|
||||
/* Based on the minimum sector size set the block size */
|
||||
*ashift = highbit(MAX(block_size, SPA_MINBLOCKSIZE)) - 1;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012 by Delphix. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <sys/zfs_context.h>
|
||||
@@ -47,7 +48,8 @@ vdev_file_rele(vdev_t *vd)
|
||||
}
|
||||
|
||||
static int
|
||||
vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift)
|
||||
vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
|
||||
uint64_t *ashift)
|
||||
{
|
||||
vdev_file_t *vf;
|
||||
vnode_t *vp;
|
||||
@@ -112,7 +114,7 @@ skip_open:
|
||||
return (error);
|
||||
}
|
||||
|
||||
*psize = vattr.va_size;
|
||||
*max_psize = *psize = vattr.va_size;
|
||||
*ashift = SPA_MINBLOCKSHIFT;
|
||||
|
||||
return (0);
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012 by Delphix. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <sys/zfs_context.h>
|
||||
#include <sys/spa.h>
|
||||
#include <sys/vdev_impl.h>
|
||||
@@ -127,7 +131,8 @@ vdev_mirror_map_alloc(zio_t *zio)
|
||||
}
|
||||
|
||||
static int
|
||||
vdev_mirror_open(vdev_t *vd, uint64_t *asize, uint64_t *ashift)
|
||||
vdev_mirror_open(vdev_t *vd, uint64_t *asize, uint64_t *max_asize,
|
||||
uint64_t *ashift)
|
||||
{
|
||||
int numerrors = 0;
|
||||
int lasterror = 0;
|
||||
@@ -150,6 +155,7 @@ vdev_mirror_open(vdev_t *vd, uint64_t *asize, uint64_t *ashift)
|
||||
}
|
||||
|
||||
*asize = MIN(*asize - 1, cvd->vdev_asize - 1) + 1;
|
||||
*max_asize = MIN(*max_asize - 1, cvd->vdev_max_asize - 1) + 1;
|
||||
*ashift = MAX(*ashift, cvd->vdev_ashift);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012 by Delphix. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The 'missing' vdev is a special vdev type used only during import. It
|
||||
* signifies a placeholder in the root vdev for some vdev that we know is
|
||||
@@ -40,7 +44,8 @@
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
vdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift)
|
||||
vdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
|
||||
uint64_t *ashift)
|
||||
{
|
||||
/*
|
||||
* Really this should just fail. But then the root vdev will be in the
|
||||
@@ -49,6 +54,7 @@ vdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift)
|
||||
* will fail the GUID sum check before ever trying to open the pool.
|
||||
*/
|
||||
*psize = 0;
|
||||
*max_psize = 0;
|
||||
*ashift = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012 by Delphix. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <sys/zfs_context.h>
|
||||
@@ -1441,7 +1442,8 @@ vdev_raidz_reconstruct(raidz_map_t *rm, int *t, int nt)
|
||||
}
|
||||
|
||||
static int
|
||||
vdev_raidz_open(vdev_t *vd, uint64_t *asize, uint64_t *ashift)
|
||||
vdev_raidz_open(vdev_t *vd, uint64_t *asize, uint64_t *max_asize,
|
||||
uint64_t *ashift)
|
||||
{
|
||||
vdev_t *cvd;
|
||||
uint64_t nparity = vd->vdev_nparity;
|
||||
@@ -1469,10 +1471,12 @@ vdev_raidz_open(vdev_t *vd, uint64_t *asize, uint64_t *ashift)
|
||||
}
|
||||
|
||||
*asize = MIN(*asize - 1, cvd->vdev_asize - 1) + 1;
|
||||
*max_asize = MIN(*max_asize - 1, cvd->vdev_max_asize - 1) + 1;
|
||||
*ashift = MAX(*ashift, cvd->vdev_ashift);
|
||||
}
|
||||
|
||||
*asize *= vd->vdev_children;
|
||||
*max_asize *= vd->vdev_children;
|
||||
|
||||
if (numerrors > nparity) {
|
||||
vd->vdev_stat.vs_aux = VDEV_AUX_NO_REPLICAS;
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012 by Delphix. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <sys/zfs_context.h>
|
||||
#include <sys/spa.h>
|
||||
#include <sys/vdev_impl.h>
|
||||
@@ -50,7 +54,8 @@ too_many_errors(vdev_t *vd, int numerrors)
|
||||
}
|
||||
|
||||
static int
|
||||
vdev_root_open(vdev_t *vd, uint64_t *asize, uint64_t *ashift)
|
||||
vdev_root_open(vdev_t *vd, uint64_t *asize, uint64_t *max_asize,
|
||||
uint64_t *ashift)
|
||||
{
|
||||
int lasterror = 0;
|
||||
int numerrors = 0;
|
||||
@@ -78,6 +83,7 @@ vdev_root_open(vdev_t *vd, uint64_t *asize, uint64_t *ashift)
|
||||
}
|
||||
|
||||
*asize = 0;
|
||||
*max_asize = 0;
|
||||
*ashift = 0;
|
||||
|
||||
return (0);
|
||||
|
||||
+19
-1
@@ -24,7 +24,7 @@
|
||||
* Portions Copyright 2012 Pawel Jakub Dawidek <pawel@dawidek.net>
|
||||
* Copyright (c) 2012, Joyent, Inc. 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/types.h>
|
||||
@@ -4037,6 +4037,22 @@ zfs_ioc_clear(zfs_cmd_t *zc)
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
zfs_ioc_pool_reopen(zfs_cmd_t *zc)
|
||||
{
|
||||
spa_t *spa;
|
||||
int error;
|
||||
|
||||
error = spa_open(zc->zc_name, &spa, FTAG);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
spa_vdev_state_enter(spa, SCL_NONE);
|
||||
vdev_reopen(spa->spa_root_vdev);
|
||||
(void) spa_vdev_state_exit(spa, NULL, 0);
|
||||
spa_close(spa, FTAG);
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* inputs:
|
||||
* zc_name name of filesystem
|
||||
@@ -4831,6 +4847,8 @@ static zfs_ioc_vec_t zfs_ioc_vec[] = {
|
||||
POOL_CHECK_SUSPENDED },
|
||||
{ zfs_ioc_space_snaps, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
|
||||
POOL_CHECK_SUSPENDED },
|
||||
{ zfs_ioc_pool_reopen, zfs_secpolicy_config, POOL_NAME, B_TRUE,
|
||||
POOL_CHECK_SUSPENDED },
|
||||
};
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user