Add interface NVME to devstat

This allows to list only NVMe devices in systat, iostat, vmstat, etc.
Previously those were counted as OTHER.
This commit is contained in:
Alexander Motin 2023-11-15 23:03:40 -05:00
parent 7b21c447fb
commit d282baddb0
9 changed files with 18 additions and 0 deletions

View File

@ -194,6 +194,8 @@ inline int DEVSTAT_TYPE_IF_IDE = 0x020;
#pragma D binding "1.13" DEVSTAT_TYPE_IF_IDE
inline int DEVSTAT_TYPE_IF_OTHER = 0x030;
#pragma D binding "1.13" DEVSTAT_TYPE_IF_OTHER
inline int DEVSTAT_TYPE_IF_NVM = 0x040;
#pragma D binding "1.13" DEVSTAT_TYPE_IF_NVME
inline int DEVSTAT_TYPE_IF_MASK = 0x0f0;
#pragma D binding "1.13" DEVSTAT_TYPE_IF_MASK
inline int DEVSTAT_TYPE_PASS = 0x100;
@ -228,6 +230,7 @@ inline string device_if_string[int type] =
type == DEVSTAT_TYPE_IF_SCSI ? "SCSI" :
type == DEVSTAT_TYPE_IF_IDE ? "IDE" :
type == DEVSTAT_TYPE_IF_OTHER ? "OTHER" :
type == DEVSTAT_TYPE_IF_NVME ? "NVME" :
strjoin("UNKNOWN(", strjoin(lltostr(type), ")"));
#pragma D binding "1.13" device_if

View File

@ -428,6 +428,8 @@ Floppy devices
Integrated Drive Electronics devices
.It Li SCSI
Small Computer System Interface devices
.It Li NVME
NVM Express Interface devices
.It Li other
Any other device interface
.El

View File

@ -75,6 +75,7 @@ struct devstat_match_table match_table[] = {
{"scsi", DEVSTAT_TYPE_IF_SCSI, DEVSTAT_MATCH_IF},
{"ide", DEVSTAT_TYPE_IF_IDE, DEVSTAT_MATCH_IF},
{"other", DEVSTAT_TYPE_IF_OTHER, DEVSTAT_MATCH_IF},
{"nvme", DEVSTAT_TYPE_IF_NVME, DEVSTAT_MATCH_IF},
{"worm", DEVSTAT_TYPE_WORM, DEVSTAT_MATCH_TYPE},
{"sa", DEVSTAT_TYPE_SEQUENTIAL,DEVSTAT_MATCH_TYPE},
{"pass", DEVSTAT_TYPE_PASS, DEVSTAT_MATCH_PASS},

View File

@ -414,6 +414,7 @@ typedef enum {
DEVSTAT_TYPE_IF_SCSI = 0x010,
DEVSTAT_TYPE_IF_IDE = 0x020,
DEVSTAT_TYPE_IF_OTHER = 0x030,
DEVSTAT_TYPE_IF_NVME = 0x040,
DEVSTAT_TYPE_IF_MASK = 0x0f0,
DEVSTAT_TYPE_PASS = 0x100
} devstat_type_flags;

View File

@ -306,6 +306,7 @@ typedef enum {
!XPORT_IS_ATA(t) && !XPORT_IS_NVME(t))
#define XPORT_DEVSTAT_TYPE(t) (XPORT_IS_ATA(t) ? DEVSTAT_TYPE_IF_IDE : \
XPORT_IS_SCSI(t) ? DEVSTAT_TYPE_IF_SCSI : \
XPORT_IS_NVME(t) ? DEVSTAT_TYPE_IF_NVME : \
DEVSTAT_TYPE_IF_OTHER)
#define PROTO_VERSION_UNKNOWN (UINT_MAX - 1)

View File

@ -30,6 +30,7 @@
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/bio.h>
#include <sys/devicestat.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
@ -471,6 +472,10 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg)
disk->d_flags |= DISKFLAG_CANDELETE;
if (nvme_ns_get_flags(ns) & NVME_NS_FLUSH_SUPPORTED)
disk->d_flags |= DISKFLAG_CANFLUSHCACHE;
disk->d_devstat = devstat_new_entry(disk->d_name, disk->d_unit,
disk->d_sectorsize, DEVSTAT_ALL_SUPPORTED,
DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_NVME,
DEVSTAT_PRIORITY_DISK);
/*
* d_ident and d_descr are both far bigger than the length of either

View File

@ -125,6 +125,7 @@ typedef enum {
DEVSTAT_TYPE_IF_SCSI = 0x010,
DEVSTAT_TYPE_IF_IDE = 0x020,
DEVSTAT_TYPE_IF_OTHER = 0x030,
DEVSTAT_TYPE_IF_NVME = 0x040,
DEVSTAT_TYPE_IF_MASK = 0x0f0,
DEVSTAT_TYPE_PASS = 0x100
} devstat_type_flags;

View File

@ -173,6 +173,8 @@ Floppy devices
Integrated Drive Electronics devices
.It SCSI
Small Computer System Interface devices
.It NVME
NVM Express Interface devices
.It other
Any other device interface
.El

View File

@ -206,6 +206,8 @@ Floppy devices
Integrated Drive Electronics devices
.It SCSI
Small Computer System Interface devices
.It NVME
NVM Express Interface devices
.It other
Any other device interface
.El