DEVICE_OBJECT showing SectorSize on 4k sector devices as 512. RRS feed

  • Question

  • Not sure if this is the right place to ask this question, sorry in advanced if this is not the right place. 

    I was poking around a bit of software I work with that involves filter drivers and found a potential issue with 4k sector devices. The issue is the PhysicalDeviceObject passed into our AddDevice function always reports SectorSize as 512 on a system that only supports native 4k sector sizes. This caused a math error and resulted in data loss in the application. User space tools and APIs all report the sector size properly. 

    My question is at this layer is it expected that the sector size is going to be 512 for legacy issues, or is this actually a bug leftover from before sectors were supported. From my understanding the PnP manager handles passing us the device pointer and we have little control over what is really populated in the DEVICE_OBJECT structure. The devices up and down the stack also report 512 for the sector size. 

    Any info if this expected behaviour or if there is a better way to get the real sector size at this level would be nice. 

    FSUTIL report this for the device in question on the command line. 

    C:\Users\Administrator>fsutil.exe fsinfo sectorInfo C:
    LogicalBytesPerSector :                                 4096
    PhysicalBytesPerSectorForAtomicity :                    4096
    PhysicalBytesPerSectorForPerformance :                  4096
    FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096
    Device Alignment :                                      Aligned (0x000)
    Partition alignment on device :                         Aligned (0x000)
    Performs Normal Seeks
    Trim Not Supported

    Thursday, March 1, 2018 6:26 PM