windows - 如何确定为磁盘设备分配了哪些 block ?

标签 windows winapi storage virtualization scsi

许多现代存储类型使用 Thin provisioning分配 block 。我需要得到 Block allocation map对于磁盘设备。有 FSCTL_GET_VOLUME_BITMAP 获取卷位图,但它是特定于文件系统的,我需要一种不是特定于 FS 的方法。 从 Windows 8 开始 Windows is sending "TRIM and Unmap" hints to storage media to track allocated blocks .

UNMAP is the SCSI command by which an application or the system can communicate to the storage stack and the disk that a certain sector or range of sectors are currently not in use, including sectors that were previously in use by files that were later deleted.

所以这应该是可能的。不幸的是,我找不到 Disk Management Control Code或磁盘管理功能来获取它。也许有人知道如何获得它?

最佳答案

就像 gubblebozer 所暗示的那样 - SBC-3 中引入的 GET LBA STATUS 命令是从设备本身检索低级映射的方法。来自 Thin Provisioning

The application can call the IOCTL DSM allocation routine to send the SCSI 
command and retrieve the mapped or unmapped state of each slab in a particular 
range. If the LBA provisioning status returned does not describe the entire 
allocation range, the application sends another SCSI command to retrieve the 
provisioning status of the remaining LBA range.

看起来这可以在 IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES 的帮助下完成 然后 DEVICE_DATA_SET_LB_PROVISIONING_STATE 结构将包含一个位图 平板分配。

关于windows - 如何确定为磁盘设备分配了哪些 block ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36531598/

相关文章:

winapi - 使用 GDIPlus (WIn32 C++) 显示存储为带 alpha 资源的图标

c - 如何包含必要的 kernel32.lib、 header - 或在自定义应用程序中使用标准 dll?

ios - FIRStorageErrorDomain 代码=-13010

windows - php composer.phar 更新不适用于 Symfony 安装

windows - getCPUTime 只返回两个值(0 或 15625000000)——这是正确的吗?

windows - 批量打码启动命令错误

winapi - 如何获得CreateWindowEx()在特定监视器上创建窗口?

ios - 在 iOS 上购买的大于 200MB 的超大文件应该存储在哪里?

amazon-ec2 - AWS ec2 - 从快照添加的卷的磁盘 uuid

windows - 如何在windows环境下安装运行(setup)reddit.com?