Skip to content

Fix disk io counters windows#347

Merged
sni merged 6 commits intomainfrom
fix-disk-io-counters-windows
Mar 2, 2026
Merged

Fix disk io counters windows#347
sni merged 6 commits intomainfrom
fix-disk-io-counters-windows

Conversation

@inqrphl
Copy link
Contributor

@inqrphl inqrphl commented Mar 2, 2026

the code was previously checking for associations between drive letters
and collected STORAGE_DEVICE_NUMBER struct, and then relying on the
generated handle \.\PhysicalDrive[DeviceNumber] throwing an error for
the drive

now check STORAGE_DEVICE_NUMBER structs in three ways.

  • temporary devices seem to have DeviceNumber set to 0, but have
    PartitionNumber set above 32768, remove these devices.

  • DeviceType is also in the returned struct. Check if it matches the
    FILE_DEVICE_DISK value.

  • the code was iterating from 0 to 32 for deviceNumber and checking if it
    had a driveLetter. this was causing some drive letters to be skipped,
    since multiple drive letters might belong to the same physical drive

collect valid storageDeviceNumber structs into another map from drive
letter to the struct. then iterate over this map from scratch

this valid storageDeviceNumbers are initialized initialized and cached in init() function

logs print out filtered out / taken STORAGE_DEVICE_NUMBER structs. easier to debug
if a disk is not watched now.

Ahmet Oeztuerk added 6 commits March 2, 2026 12:57
the code was previously checking for associations between drive letters
and collected STORAGE_DEVICE_NUMBER struct, and then relying on the
generated handle \\.\PhysicalDrive[DeviceNumber] throwing an error for
the drive

now check STORAGE_DEVICE_NUMBER structs in three two ways.

temporary devices seem to have DeviceNumber set to 0, but have
PartitionNumber set above 32768, remove these devices.

DeviceType is also in the returned struct. Check if it matches the
FILE_DEVICE_DISK value.

the code was iterating from 0 to 32 for deviceNumber and checking if it
had a driveLetter. this was causing some drive letters to be skipped,
since ultiple drive letters might belong to the same physical drive

collect valid storageDeviceNumber structs into another map from drive
letter to the struct. then iterate over this map from scratch
 every invocation ioCountersWindows function.
@sni sni merged commit a98b7d6 into main Mar 2, 2026
133 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants