diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h index 2a630ec53212..dead20a38fe2 100644 --- a/include/sys/fs/zfs.h +++ b/include/sys/fs/zfs.h @@ -595,6 +595,9 @@ typedef struct zpool_rewind_policy { /* vdev enclosure sysfs path */ #define ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH "vdev_enc_sysfs_path" +/* Kind (ssd, file, mix, hdd) (part of vdev_stat_ex_t) */ +#define ZPOOL_CONFIG_VDEV_KIND "kind" + #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" #define ZPOOL_CONFIG_ERRCOUNT "error_count" #define ZPOOL_CONFIG_NOT_PRESENT "not_present" @@ -730,6 +733,14 @@ typedef enum vdev_aux { VDEV_AUX_SPLIT_POOL /* vdev was split off into another pool */ } vdev_aux_t; +typedef enum vdev_kind_info { + VDEV_KIND_UNKNOWN = 0, /* not set yet */ + VDEV_KIND_SSD, /* device is solid state */ + VDEV_KIND_FILE, /* device is file backed */ + VDEV_KIND_MIXED, /* device has both kinds */ + VDEV_KIND_HDD /* device is not solid state */ +} vdev_kind_info_t; + /* * pool state. The following states are written to disk as part of the normal * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining @@ -887,6 +898,8 @@ typedef struct vdev_stat_ex { uint64_t vsx_agg_histo[ZIO_PRIORITY_NUM_QUEUEABLE] [VDEV_RQ_HISTO_BUCKETS]; + /* Kind of vdev (ssd, file, mixed, hdd). Exported as one value. */ + uint64_t vsx_kind; } vdev_stat_ex_t; /* diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 6c6550862e07..74edfb8f01f9 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -2906,6 +2906,17 @@ vdev_get_stats_ex_impl(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx) &vd->vdev_queue.vq_class[t].vqc_queued_tree); } } + if (vsx) { + if (vd->vdev_nonrot) { + if (vd->vdev_ops == &vdev_file_ops) + vsx->vsx_kind = VDEV_KIND_FILE; + else + vsx->vsx_kind = VDEV_KIND_SSD; + } else if (vd->vdev_nonrot_mix) + vsx->vsx_kind = VDEV_KIND_MIXED; + else + vsx->vsx_kind = VDEV_KIND_HDD; + } } void diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 7a3a0e8a0644..737148bfbfda 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -344,6 +344,8 @@ vdev_config_generate_stats(vdev_t *vd, nvlist_t *nv) vsx->vsx_agg_histo[ZIO_PRIORITY_SCRUB], ARRAY_SIZE(vsx->vsx_agg_histo[ZIO_PRIORITY_SCRUB])); + fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_KIND, vsx->vsx_kind); + /* Add extended stats nvlist to main nvlist */ fnvlist_add_nvlist(nv, ZPOOL_CONFIG_VDEV_STATS_EX, nvx);