SysBlockDeviceQueueStats returns stats for /sys/block/xxx/queue where xxx is a device name.
(device string)
| 359 | |
| 360 | // SysBlockDeviceQueueStats returns stats for /sys/block/xxx/queue where xxx is a device name. |
| 361 | func (fs FS) SysBlockDeviceQueueStats(device string) (BlockQueueStats, error) { |
| 362 | stat := BlockQueueStats{} |
| 363 | // Files with uint64 fields |
| 364 | for file, p := range map[string]*uint64{ |
| 365 | "add_random": &stat.AddRandom, |
| 366 | "dax": &stat.DAX, |
| 367 | "discard_granularity": &stat.DiscardGranularity, |
| 368 | "discard_max_hw_bytes": &stat.DiscardMaxHWBytes, |
| 369 | "discard_max_bytes": &stat.DiscardMaxBytes, |
| 370 | "hw_sector_size": &stat.HWSectorSize, |
| 371 | "io_poll": &stat.IOPoll, |
| 372 | "io_timeout": &stat.IOTimeout, |
| 373 | "iostats": &stat.IOStats, |
| 374 | "logical_block_size": &stat.LogicalBlockSize, |
| 375 | "max_hw_sectors_kb": &stat.MaxHWSectorsKB, |
| 376 | "max_integrity_segments": &stat.MaxIntegritySegments, |
| 377 | "max_sectors_kb": &stat.MaxSectorsKB, |
| 378 | "max_segments": &stat.MaxSegments, |
| 379 | "max_segment_size": &stat.MaxSegmentSize, |
| 380 | "minimum_io_size": &stat.MinimumIOSize, |
| 381 | "nomerges": &stat.NoMerges, |
| 382 | "nr_requests": &stat.NRRequests, |
| 383 | "optimal_io_size": &stat.OptimalIOSize, |
| 384 | "physical_block_size": &stat.PhysicalBlockSize, |
| 385 | "read_ahead_kb": &stat.ReadAHeadKB, |
| 386 | "rotational": &stat.Rotational, |
| 387 | "rq_affinity": &stat.RQAffinity, |
| 388 | "write_same_max_bytes": &stat.WriteSameMaxBytes, |
| 389 | "nr_zones": &stat.NRZones, |
| 390 | "chunk_sectors": &stat.ChunkSectors, |
| 391 | "fua": &stat.FUA, |
| 392 | "max_discard_segments": &stat.MaxDiscardSegments, |
| 393 | "write_zeroes_max_bytes": &stat.WriteZeroesMaxBytes, |
| 394 | } { |
| 395 | val, err := util.ReadUintFromFile(fs.sys.Path(sysBlockPath, device, sysBlockQueue, file)) |
| 396 | if err != nil { |
| 397 | return BlockQueueStats{}, err |
| 398 | } |
| 399 | *p = val |
| 400 | } |
| 401 | // Files with int64 fields |
| 402 | for file, p := range map[string]*int64{ |
| 403 | "io_poll_delay": &stat.IOPollDelay, |
| 404 | "wbt_lat_usec": &stat.WBTLatUSec, |
| 405 | } { |
| 406 | val, err := util.ReadIntFromFile(fs.sys.Path(sysBlockPath, device, sysBlockQueue, file)) |
| 407 | if err != nil { |
| 408 | return BlockQueueStats{}, err |
| 409 | } |
| 410 | *p = val |
| 411 | } |
| 412 | // Files with string fields |
| 413 | for file, p := range map[string]*string{ |
| 414 | "write_cache": &stat.WriteCache, |
| 415 | "zoned": &stat.Zoned, |
| 416 | } { |
| 417 | val, err := util.SysReadFile(fs.sys.Path(sysBlockPath, device, sysBlockQueue, file)) |
| 418 | if err != nil { |