|
19 | 19 | ) |
20 | 20 |
|
21 | 21 | const ( |
22 | | - RedhatVendor = "0x1af4" |
23 | | - VirtioBlockDevice = "0x1042" |
| 22 | + // PCIClassBridgePCI Linux constant: https://github.com/torvalds/linux/blob/e43ffb69e0438cddd72aaa30898b4dc446f664f8/include/linux/pci_ids.h#L62 |
| 23 | + PCIClassBridgePCI = "0x0604" |
24 | 24 | ) |
25 | 25 |
|
26 | 26 | func newDeviceStats(statfs *unix.Statfs_t) *DeviceStats { |
@@ -63,7 +63,7 @@ func CountFreePCIeSlots() (int64, error) { |
63 | 63 | class := strings.TrimSpace(string(classBuf)) |
64 | 64 |
|
65 | 65 | // Class 0x060400 is a PCI-to-PCI bridge (standard for Root Ports) |
66 | | - if strings.HasPrefix(class, "0x0604") { |
| 66 | + if strings.HasPrefix(class, PCIClassBridgePCI) { |
67 | 67 | // 2. Check if the port has downstream devices |
68 | 68 | // If the bridge has children, they appear as subdirectories |
69 | 69 | // matching the PCI address format (e.g., 0000:01:00.0) |
@@ -114,20 +114,3 @@ func CountLocalCSIVolumes(driverName string) (int64, error) { |
114 | 114 |
|
115 | 115 | return int64(volumeCount), nil |
116 | 116 | } |
117 | | - |
118 | | -func IsNonBlockDevice(devPath string, file os.DirEntry) bool { |
119 | | - var isNonBlockDevice bool |
120 | | - pciDevicePath := filepath.Join(devPath, file.Name()) |
121 | | - vendorBuf, err := os.ReadFile(filepath.Join(pciDevicePath, "vendor")) |
122 | | - if err != nil { |
123 | | - klog.Errorf("failed to read PCI device vendor %s : %v", pciDevicePath, err) |
124 | | - } |
125 | | - deviceBuf, err := os.ReadFile(filepath.Join(pciDevicePath, "device")) |
126 | | - if err != nil { |
127 | | - klog.Errorf("failed to read PCI device file %s : %v", pciDevicePath, err) |
128 | | - } |
129 | | - if strings.TrimSpace(string(vendorBuf)) == RedhatVendor && strings.TrimSpace(string(deviceBuf)) != VirtioBlockDevice { |
130 | | - isNonBlockDevice = true |
131 | | - } |
132 | | - return isNonBlockDevice |
133 | | -} |
0 commit comments