From fb6d8cf229c308ef63424bf81221966438327bb0 Mon Sep 17 00:00:00 2001 From: Don Brady Date: Tue, 23 Jul 2024 17:34:09 -0600 Subject: [PATCH] Add some missing vdev properties (#16346) Sponsored-by: Klara, Inc. Sponsored-By: Wasabi Technology, Inc. Signed-off-by: Don Brady Co-authored-by: Don Brady Reviewed-by: Alexander Motin Reviewed-by: Tony Hutter --- include/sys/fs/zfs.h | 3 +++ lib/libzfs/libzfs.abi | 5 ++++- lib/libzfs/libzfs_pool.c | 7 +++++++ man/man7/vdevprops.7 | 10 +++++++++- module/zcommon/zpool_prop.c | 9 +++++++++ module/zfs/vdev.c | 18 ++++++++++++++++++ .../functional/cli_root/zpool_get/vdev_get.cfg | 3 +++ 7 files changed, 53 insertions(+), 2 deletions(-) diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h index e191420f2..b572c22a2 100644 --- a/include/sys/fs/zfs.h +++ b/include/sys/fs/zfs.h @@ -368,6 +368,9 @@ typedef enum { VDEV_PROP_RAIDZ_EXPANDING, VDEV_PROP_SLOW_IO_N, VDEV_PROP_SLOW_IO_T, + VDEV_PROP_TRIM_SUPPORT, + VDEV_PROP_TRIM_ERRORS, + VDEV_PROP_SLOW_IOS, VDEV_NUM_PROPS } vdev_prop_t; diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 80f4b7439..a75f5bbb4 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -5702,7 +5702,10 @@ - + + + + diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 979bbdd38..d5e934045 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -5225,6 +5225,8 @@ zpool_get_vdev_prop_value(nvlist_t *nvprop, vdev_prop_t prop, char *prop_name, case VDEV_PROP_WRITE_ERRORS: case VDEV_PROP_CHECKSUM_ERRORS: case VDEV_PROP_INITIALIZE_ERRORS: + case VDEV_PROP_TRIM_ERRORS: + case VDEV_PROP_SLOW_IOS: case VDEV_PROP_OPS_NULL: case VDEV_PROP_OPS_READ: case VDEV_PROP_OPS_WRITE: @@ -5304,6 +5306,11 @@ zpool_get_vdev_prop_value(nvlist_t *nvprop, vdev_prop_t prop, char *prop_name, src = fnvlist_lookup_uint64(nv, ZPROP_SOURCE); intval = fnvlist_lookup_uint64(nv, ZPROP_VALUE); } else { + /* 'trim_support' only valid for leaf vdevs */ + if (prop == VDEV_PROP_TRIM_SUPPORT) { + (void) strlcpy(buf, "-", len); + break; + } src = ZPROP_SRC_DEFAULT; intval = vdev_prop_default_numeric(prop); /* Only use if provided by the RAIDZ VDEV above */ diff --git a/man/man7/vdevprops.7 b/man/man7/vdevprops.7 index 5ec37df17..34d4026b1 100644 --- a/man/man7/vdevprops.7 +++ b/man/man7/vdevprops.7 @@ -102,8 +102,14 @@ Parent of this vdev Comma separated list of children of this vdev .It Sy numchildren The number of children belonging to this vdev -.It Sy read_errors , write_errors , checksum_errors , initialize_errors +.It Sy read_errors , write_errors , checksum_errors , initialize_errors , trim_errors The number of errors of each type encountered by this vdev +.It Sy slow_ios +The number of slow I/Os encountered by this vdev, +These represent I/O operations that didn't complete in +.Sy zio_slow_io_ms +milliseconds +.Pq Sy 30000 No by default . .It Sy null_ops , read_ops , write_ops , free_ops , claim_ops , trim_ops The number of I/O operations of each type performed by this vdev .It Xo @@ -113,6 +119,8 @@ The number of I/O operations of each type performed by this vdev The cumulative size of all operations of each type performed by this vdev .It Sy removing If this device is currently being removed from the pool +.It Sy trim_support +Indicates if a leaf device supports trim operations. .El .Pp The following native properties can be used to change the behavior of a vdev. diff --git a/module/zcommon/zpool_prop.c b/module/zcommon/zpool_prop.c index e2e3bf5be..b367c95b8 100644 --- a/module/zcommon/zpool_prop.c +++ b/module/zcommon/zpool_prop.c @@ -381,6 +381,12 @@ vdev_prop_init(void) zprop_register_number(VDEV_PROP_INITIALIZE_ERRORS, "initialize_errors", 0, PROP_READONLY, ZFS_TYPE_VDEV, "", "INITERR", B_FALSE, sfeatures); + zprop_register_number(VDEV_PROP_TRIM_ERRORS, "trim_errors", 0, + PROP_READONLY, ZFS_TYPE_VDEV, "", "TRIMERR", B_FALSE, + sfeatures); + zprop_register_number(VDEV_PROP_SLOW_IOS, "slow_ios", 0, + PROP_READONLY, ZFS_TYPE_VDEV, "", "SLOW", B_FALSE, + sfeatures); zprop_register_number(VDEV_PROP_OPS_NULL, "null_ops", 0, PROP_READONLY, ZFS_TYPE_VDEV, "", "NULLOP", B_FALSE, sfeatures); @@ -448,6 +454,9 @@ vdev_prop_init(void) zprop_register_index(VDEV_PROP_RAIDZ_EXPANDING, "raidz_expanding", 0, PROP_READONLY, ZFS_TYPE_VDEV, "on | off", "RAIDZ_EXPANDING", boolean_table, sfeatures); + zprop_register_index(VDEV_PROP_TRIM_SUPPORT, "trim_support", 0, + PROP_READONLY, ZFS_TYPE_VDEV, "on | off", "TRIMSUP", + boolean_table, sfeatures); /* default index properties */ zprop_register_index(VDEV_PROP_FAILFAST, "failfast", B_TRUE, diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 11cc39ba3..6ae0a1412 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -6222,6 +6222,16 @@ vdev_prop_get(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl) vd->vdev_stat.vs_initialize_errors, ZPROP_SRC_NONE); continue; + case VDEV_PROP_TRIM_ERRORS: + vdev_prop_add_list(outnvl, propname, NULL, + vd->vdev_stat.vs_trim_errors, + ZPROP_SRC_NONE); + continue; + case VDEV_PROP_SLOW_IOS: + vdev_prop_add_list(outnvl, propname, NULL, + vd->vdev_stat.vs_slow_ios, + ZPROP_SRC_NONE); + continue; case VDEV_PROP_OPS_NULL: vdev_prop_add_list(outnvl, propname, NULL, vd->vdev_stat.vs_ops[ZIO_TYPE_NULL], @@ -6306,6 +6316,14 @@ vdev_prop_get(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl) ZPROP_SRC_NONE); } continue; + case VDEV_PROP_TRIM_SUPPORT: + /* only valid for leaf vdevs */ + if (vd->vdev_ops->vdev_op_leaf) { + vdev_prop_add_list(outnvl, propname, + NULL, vd->vdev_has_trim, + ZPROP_SRC_NONE); + } + continue; /* Numeric Properites */ case VDEV_PROP_ALLOCATING: /* Leaf vdevs cannot have this property */ diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_get/vdev_get.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_get/vdev_get.cfg index c3b9efd64..6cfa7eaf7 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_get/vdev_get.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_get/vdev_get.cfg @@ -72,4 +72,7 @@ typeset -a properties=( io_t slow_io_n slow_io_t + trim_support + trim_errors + slow_ios )