]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Add physical device size to SIZE column in 'zpool list -v'
authorAkash B <akash-b@hpe.com>
Wed, 9 Mar 2022 00:20:41 +0000 (05:50 +0530)
committerGitHub <noreply@github.com>
Wed, 9 Mar 2022 00:20:41 +0000 (16:20 -0800)
Add physical device size/capacity only for physical devices in
'zpool list -v' instead of displaying "-" in the SIZE column.
This would make it easier to see the individual device capacity and
to determine which spares are large enough to replace which devices.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Dipak Ghosh <dipak.ghosh@hpe.com>
Signed-off-by: Akash B <akash-b@hpe.com>
Closes #12561
Closes #13106

cmd/zpool/zpool_main.c
include/sys/fs/zfs.h
module/zfs/vdev.c
tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh

index 717d8b806d79662af2641d0be110812acfe73aef..a445d10fcc82ab118857d56ca8127934f55c94b9 100644 (file)
@@ -6067,6 +6067,7 @@ print_one_column(zpool_prop_t prop, uint64_t value, const char *str,
        size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL);
 
        switch (prop) {
+       case ZPOOL_PROP_SIZE:
        case ZPOOL_PROP_EXPANDSZ:
        case ZPOOL_PROP_CHECKPOINT:
        case ZPOOL_PROP_DEDUPRATIO:
@@ -6162,8 +6163,12 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
                 * '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, NULL, scripted,
-                   toplevel, format);
+               if (vs->vs_pspace)
+                       print_one_column(ZPOOL_PROP_SIZE, vs->vs_pspace, NULL,
+                           scripted, B_TRUE, format);
+               else
+                       print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, NULL,
+                           scripted, toplevel, format);
                print_one_column(ZPOOL_PROP_ALLOCATED, vs->vs_alloc, NULL,
                    scripted, toplevel, format);
                print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc,
index ab29b4e2ef38ec93e89814780f56141d3fed9367..f9fd5cf676e2f70ba1208f58543077bab0d221b3 100644 (file)
@@ -1185,6 +1185,7 @@ typedef struct vdev_stat {
        uint64_t        vs_logical_ashift;      /* vdev_logical_ashift  */
        uint64_t        vs_physical_ashift;     /* vdev_physical_ashift */
        uint64_t        vs_noalloc;             /* allocations halted?  */
+       uint64_t        vs_pspace;              /* physical capacity */
 } vdev_stat_t;
 
 #define        VDEV_STAT_VALID(field, uint64_t_field_count) \
index a844ee2a73c5b2cb646917d9cb79fccf079e5704..7bc79a2259df40c83dc0367b933b03f98a97df84 100644 (file)
@@ -4424,6 +4424,7 @@ vdev_get_stats_ex(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx)
                vs->vs_rsize = vdev_get_min_asize(vd);
 
                if (vd->vdev_ops->vdev_op_leaf) {
+                       vs->vs_pspace = vd->vdev_psize;
                        vs->vs_rsize += VDEV_LABEL_START_SIZE +
                            VDEV_LABEL_END_SIZE;
                        /*
index 59f64081a977aae6340a0507b5515cfdfe164650..a18e634cefa7e99b716b6b3bc539c8e910bca1ba 100755 (executable)
@@ -48,14 +48,18 @@ log_must zpool checkpoint $NESTEDPOOL
 log_must truncate -s $EXPSZ $FILEDISK1
 log_must zpool online -e $NESTEDPOOL $FILEDISK1
 NEWSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}')
+DEXPSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $6}')
 nested_change_state_after_checkpoint
 log_mustnot [ "$INITSZ" = "$NEWSZ" ]
+log_must [ "$DEXPSZ" = "-" ]
 
 log_must zpool export $NESTEDPOOL
 log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL
 
 nested_verify_pre_checkpoint_state
 FINSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}')
-log_must [ "$INITSZ" = "$FINSZ" ]
+DEXPSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $6}')
+log_must [ "$EXPSZ" = "$FINSZ" ]
+log_must [ "$DEXPSZ" != "-" ]
 
 log_pass "LUN expansion rewinded correctly."