Skip to content

Commit 02bdb5b

Browse files
committed
storage/disk: avoid warning on SCSI devices
Avoid logging a warning when a device ID major number indicates its an SCSI device or a handful of other known, expect major device IDs. If a device ID's major number is unrecognized, we'll log a warning but otherwise will continue to operate normally. Epic: none Release note: none
1 parent 2b821ef commit 02bdb5b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pkg/storage/disk/platform_linux.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ func deviceIDFromFileInfo(finfo fs.FileInfo, path string) DeviceID {
7979
major := unix.Major(statInfo.Dev)
8080
minor := unix.Minor(statInfo.Dev)
8181

82-
// Per /usr/include/linux/major.h and Documentation/admin-guide/devices.rst:
82+
// See
83+
// - /usr/include/linux/major.h
84+
// - Documentation/admin-guide/devices.rst:
8385
switch major {
8486
case 0: // UNNAMED_MAJOR
85-
8687
// Perform additional lookups for unknown device types
8788
var statfs sysutil.StatfsT
8889
err := sysutil.Statfs(path, &statfs)
@@ -113,11 +114,21 @@ func deviceIDFromFileInfo(finfo fs.FileInfo, path string) DeviceID {
113114
maybeWarnf(ctx, "unsupported file system type %x for path (%d:%d) %q", statfs.Type, major, minor, path)
114115
}
115116

116-
case 259: // BLOCK_EXT_MAJOR=259
117+
case 43:
118+
// Network block devices (nb*)
119+
maybeInfof(ctx, "mapping %q to diskstats network block device %d:%d", path, major, minor)
120+
121+
case 8, 65, 66, 67, 68, 69, 70, 71, 128, 129, 130, 131, 132, 133, 134, 135:
122+
// SCSI disks (sdX)
123+
maybeInfof(ctx, "mapping %q to diskstats SCSI device %d:%d", path, major, minor)
117124

125+
case 202:
126+
// Xen virtual block devices (xvd*)
127+
maybeInfof(ctx, "mapping %q to diskstats xvd* device %d:%d", path, major, minor)
128+
129+
case 259: // BLOCK_EXT_MAJOR=259
118130
// NOTE: Major device 259 is the happy path for ext4 and xfs filesystems: no
119131
// additional handling is required.
120-
121132
maybeInfof(ctx, "mapping %q to diskstats device %d:%d", path, major, minor)
122133

123134
default:

0 commit comments

Comments
 (0)