Documentation ¶
Index ¶
- type BlockQueueStats
- type DeviceMapperInfo
- type Diskstats
- type FS
- func (fs FS) ProcDiskstats() ([]Diskstats, error)
- func (fs FS) SysBlockDeviceMapperInfo(device string) (DeviceMapperInfo, error)
- func (fs FS) SysBlockDeviceQueueStats(device string) (BlockQueueStats, error)
- func (fs FS) SysBlockDeviceStat(device string) (IOStats, int, error)
- func (fs FS) SysBlockDeviceUnderlyingDevices(device string) (UnderlyingDeviceInfo, error)
- func (fs FS) SysBlockDevices() ([]string, error)
- type IOStats
- type Info
- type UnderlyingDeviceInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockQueueStats ¶ added in v0.1.0
type BlockQueueStats struct { // AddRandom is the status of a disk entropy (1 is on, 0 is off). AddRandom uint64 // Dax indicates whether the device supports Direct Access (DAX) (1 is on, 0 is off). DAX uint64 // DiscardGranularity is the size of internal allocation of the device in bytes, 0 means device // does not support the discard functionality. DiscardGranularity uint64 // DiscardMaxHWBytes is the hardware maximum number of bytes that can be discarded in a single operation, // 0 means device does not support the discard functionality. DiscardMaxHWBytes uint64 // DiscardMaxBytes is the software maximum number of bytes that can be discarded in a single operation. DiscardMaxBytes uint64 // HWSectorSize is the sector size of the device, in bytes. HWSectorSize uint64 // IOPoll indicates if polling is enabled (1 is on, 0 is off). IOPoll uint64 // IOPollDelay indicates how polling will be performed, -1 for classic polling, 0 for hybrid polling, // with greater than 0 the kernel will put process issuing IO to sleep for this amount of time in // microseconds before entering classic polling. IOPollDelay int64 // IOTimeout is the request timeout in milliseconds. IOTimeout uint64 // IOStats indicates if iostats accounting is used for the disk (1 is on, 0 is off). IOStats uint64 // LogicalBlockSize is the logical block size of the device, in bytes. LogicalBlockSize uint64 // MaxHWSectorsKB is the maximum number of kilobytes supported in a single data transfer. MaxHWSectorsKB uint64 // MaxIntegritySegments is the max limit of integrity segments as set by block layer which a hardware controller // can handle. MaxIntegritySegments uint64 // MaxSectorsKB is the maximum number of kilobytes that the block layer will allow for a filesystem request. MaxSectorsKB uint64 // MaxSegments is the number of segments on the device. MaxSegments uint64 // MaxSegmentsSize is the maximum segment size of the device. MaxSegmentSize uint64 // MinimumIOSize is the smallest preferred IO size reported by the device. MinimumIOSize uint64 // NoMerges shows the lookup logic involved with IO merging requests in the block layer. 0 all merges are // enabled, 1 only simple one hit merges are tried, 2 no merge algorithms will be tried. NoMerges uint64 // NRRequests is the number of how many requests may be allocated in the block layer for read or write requests. NRRequests uint64 // OptimalIOSize is the optimal IO size reported by the device. OptimalIOSize uint64 // PhysicalBlockSize is the physical block size of device, in bytes. PhysicalBlockSize uint64 // ReadAHeadKB is the maximum number of kilobytes to read-ahead for filesystems on this block device. ReadAHeadKB uint64 // Rotational indicates if the device is of rotational type or non-rotational type. Rotational uint64 // RQAffinity indicates affinity policy of device, if 1 the block layer will migrate request completions to the // cpu “group” that originally submitted the request, if 2 forces the completion to run on the requesting cpu. RQAffinity uint64 // SchedulerList contains list of available schedulers for this block device. SchedulerList []string // SchedulerCurrent is the current scheduler for this block device. SchedulerCurrent string // WriteCache shows the type of cache for block device, "write back" or "write through". WriteCache string // WriteSameMaxBytes is the number of bytes the device can write in a single write-same command. // A value of ‘0’ means write-same is not supported by this device. WriteSameMaxBytes uint64 // WBTLatUSec is the target minimum read latency, 0 means feature is disables. WBTLatUSec int64 // ThrottleSampleTime is the time window that blk-throttle samples data, in millisecond. Optional // exists only if CONFIG_BLK_DEV_THROTTLING_LOW is enabled. ThrottleSampleTime *uint64 // Zoned indicates if the device is a zoned block device and the zone model of the device if it is indeed zoned. // Possible values are: none, host-aware, host-managed for zoned block devices. Zoned string // NRZones indicates the total number of zones of the device, always zero for regular block devices. NRZones uint64 // ChunksSectors for RAID is the size in 512B sectors of the RAID volume stripe segment, // for zoned host device is the size in 512B sectors. ChunkSectors uint64 // FUA indicates whether the device supports Force Unit Access for write requests. FUA uint64 // MaxDiscardSegments is the maximum number of DMA entries in a discard request. MaxDiscardSegments uint64 // WriteZeroesMaxBytes the maximum number of bytes that can be zeroed at once. // The value 0 means that REQ_OP_WRITE_ZEROES is not supported. WriteZeroesMaxBytes uint64 }
BlockQueueStats models the queue files that are located in the sysfs tree for each block device and described in the kernel documentation: https://www.kernel.org/doc/Documentation/block/queue-sysfs.txt https://www.kernel.org/doc/html/latest/block/queue-sysfs.html
type DeviceMapperInfo ¶ added in v0.8.0
type DeviceMapperInfo struct { // Name is the string containing mapped device name. Name string // RqBasedSeqIOMergeDeadline determines how long (in microseconds) a request that is a reasonable merge // candidate can be queued on the request queue. RqBasedSeqIOMergeDeadline uint64 // Suspended indicates if the device is suspended (1 is on, 0 is off). Suspended uint64 // UseBlkMQ indicates if the device is using the request-based blk-mq I/O path mode (1 is on, 0 is off). UseBlkMQ uint64 // UUID is the DM-UUID string or empty string if DM-UUID is not set. UUID string }
DeviceMapperInfo models the devicemapper files that are located in the sysfs tree for each block device and described in the kernel documentation: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-block-dm
type Diskstats ¶
type Diskstats struct { Info IOStats // IoStatsCount contains the number of io stats read. For kernel versions 5.5+, // there should be 20 fields read. For kernel versions 4.18+, // there should be 18 fields read. For earlier kernel versions this // will be 14 because the discard values are not available. IoStatsCount int }
Diskstats combines the device Info and IOStats.
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS represents the pseudo-filesystems proc and sys, which provides an interface to kernel data structures.
func NewDefaultFS ¶ added in v0.0.2
NewDefaultFS returns a new blockdevice fs using the default mountPoints for proc and sys. It will error if either of these mount points can't be read.
func NewFS ¶
NewFS returns a new blockdevice fs using the given mountPoints for proc and sys. It will error if either of these mount points can't be read.
func (FS) ProcDiskstats ¶
ProcDiskstats reads the diskstats file and returns an array of Diskstats (one per line/device).
func (FS) SysBlockDeviceMapperInfo ¶ added in v0.8.0
func (fs FS) SysBlockDeviceMapperInfo(device string) (DeviceMapperInfo, error)
func (FS) SysBlockDeviceQueueStats ¶ added in v0.1.0
func (fs FS) SysBlockDeviceQueueStats(device string) (BlockQueueStats, error)
SysBlockDeviceQueueStats returns stats for /sys/block/xxx/queue where xxx is a device name.
func (FS) SysBlockDeviceStat ¶
SysBlockDeviceStat returns stats for the block device read from /sys/block/<device>/stat. The number of stats read will be 15 if the discard stats are available (kernel 4.18+) and 11 if they are not available.
func (FS) SysBlockDeviceUnderlyingDevices ¶ added in v0.8.0
func (fs FS) SysBlockDeviceUnderlyingDevices(device string) (UnderlyingDeviceInfo, error)
func (FS) SysBlockDevices ¶
SysBlockDevices lists the device names from /sys/block/<dev>.
type IOStats ¶
type IOStats struct { // ReadIOs is the number of reads completed successfully. ReadIOs uint64 // ReadMerges is the number of reads merged. Reads and writes // which are adjacent to each other may be merged for efficiency. ReadMerges uint64 // ReadSectors is the total number of sectors read successfully. ReadSectors uint64 // ReadTicks is the total number of milliseconds spent by all reads. ReadTicks uint64 // WriteIOs is the total number of writes completed successfully. WriteIOs uint64 // WriteMerges is the number of reads merged. WriteMerges uint64 // WriteSectors is the total number of sectors written successfully. WriteSectors uint64 // WriteTicks is the total number of milliseconds spent by all writes. WriteTicks uint64 // IOsInProgress is number of I/Os currently in progress. IOsInProgress uint64 // IOsTotalTicks is the number of milliseconds spent doing I/Os. // This field increases so long as IosInProgress is nonzero. IOsTotalTicks uint64 // WeightedIOTicks is the weighted number of milliseconds spent doing I/Os. // This can also be used to estimate average queue wait time for requests. WeightedIOTicks uint64 // DiscardIOs is the total number of discards completed successfully. DiscardIOs uint64 // DiscardMerges is the number of discards merged. DiscardMerges uint64 // DiscardSectors is the total number of sectors discarded successfully. DiscardSectors uint64 // DiscardTicks is the total number of milliseconds spent by all discards. DiscardTicks uint64 // FlushRequestsCompleted is the total number of flush request completed successfully. FlushRequestsCompleted uint64 // TimeSpentFlushing is the total number of milliseconds spent flushing. TimeSpentFlushing uint64 }
IOStats models the iostats data described in the kernel documentation. - https://www.kernel.org/doc/Documentation/iostats.txt, - https://www.kernel.org/doc/Documentation/block/stat.txt - https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
type UnderlyingDeviceInfo ¶ added in v0.8.0
type UnderlyingDeviceInfo struct { // DeviceNames is the list of devices names DeviceNames []string }
UnderlyingDevices models the list of devices that this device is built from.