none
Does windows storage filter provide function get disk io sector address directly? RRS feed

  • Question

  • I could use storage upper filter driver get disk io sector number by following:

    Dispatch routine(Device_object, irp)

    {

    ....

    byteIndex= IOgetcurrentIrpstacklocation(Irp)->write.byteoffset.QuadPart;

    sect_number=byteIndex/512;

    ....

    }

    However I heared that there is Block IO in linux could get sector number directly, is there any method could do that in windows rather than my way of do that? or is there something wrong with my method, please let me know! Thanks!

    
    
    
    
    Tuesday, April 30, 2013 1:20 AM

Answers

  • No this is not Linux, what is the problem with doing the calculation?  If you want to know exactly what Windows is doing, look at the disk driver sample in the WDK which translates the disk requests to SRB's.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, April 30, 2013 2:09 PM

All replies

  • I don't think you should assume the disk sector size is always 512, some newer disks have a larger sector size (you can create and send a IOCTL_DISK_GET_DRIVE_GEOMETRY IRP down the stack and get the BytesPerSector field).

    I don't know of a method to get the sector directly from the IRP.

    Tsang Chan

    Tuesday, April 30, 2013 2:58 AM
  • yeal, I know 512 is according to hard disk drive, for ssd should be 4K.

    but what you told me could just get disk geometry, such as type, cylinders, and byte per sector. I want to know a disk IO address, which means where does this IO write or read on this disk. What you said is just get the disk information which is not exactlly what I want.

    Thanks anyway!

    
    
    Tuesday, April 30, 2013 3:23 AM
  • Can't you assume sector is (IOgetcurrentIrpstacklocation(Irp)->write.byteoffset.QuadPart / Geometry->BytesForSector) ?

    (also - there are new WD HDs that have 4K sectors, not just SSDs)

    • Proposed as answer by Tsang Chan Tuesday, April 30, 2013 2:30 PM
    Tuesday, April 30, 2013 5:36 AM
  • I know that, I want to know is there is other way to get sector number rather than using  write.byteoffset.QuadPart/BytesForSectors? Just like linux Block IO struct. That is what I really want to know.

    Tuesday, April 30, 2013 12:57 PM
  • No this is not Linux, what is the problem with doing the calculation?  If you want to know exactly what Windows is doing, look at the disk driver sample in the WDK which translates the disk requests to SRB's.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, April 30, 2013 2:09 PM
  • Thanks, you mean there is no problem with my method to do this, right?

    Thanks a lot.

    Tuesday, April 30, 2013 7:07 PM