Skip to content

Commit

Permalink
Fix diskstats stats using sysfs (#394)
Browse files Browse the repository at this point in the history
/sys/block/<dev> is normally a symlink while code previously checked
for a directory.

Added flush request and time spend flushing diskstats for kernel 5.5+
to sysfs.

Signed-off-by: Luiz Angelo Daros de Luca <[email protected]>
  • Loading branch information
luizluca authored Jul 6, 2021
1 parent cf1df72 commit f73f4d0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions blockdevice/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const (
procDiskstatsPath = "diskstats"
procDiskstatsFormat = "%d %d %s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"
sysBlockPath = "block"
sysBlockStatFormat = "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"
sysBlockStatFormat = "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"
sysBlockQueue = "queue"
)

Expand Down Expand Up @@ -274,9 +274,7 @@ func (fs FS) SysBlockDevices() ([]string, error) {
}
devices := []string{}
for _, deviceDir := range deviceDirs {
if deviceDir.IsDir() {
devices = append(devices, deviceDir.Name())
}
devices = append(devices, deviceDir.Name())
}
return devices, nil
}
Expand Down Expand Up @@ -306,6 +304,8 @@ func (fs FS) SysBlockDeviceStat(device string) (IOStats, int, error) {
&stat.DiscardMerges,
&stat.DiscardSectors,
&stat.DiscardTicks,
&stat.FlushRequestsCompleted,
&stat.TimeSpentFlushing,
)
// An io.EOF error is ignored because it just means we read fewer than the full 15 fields.
if err == io.EOF {
Expand Down

0 comments on commit f73f4d0

Please sign in to comment.