>- In Windows is it possible to return RETRY or similar error code (NTSTATUS) from a disk filter driver
that will cause the upper layer driver basically NTFS to retry an operation like open/close/read/write?
There are no open/close requests between NTFS and the disk stack.
As about read/write - this is hardly possible, being possible only for cache flush IO. For such IO, any error which is NOT IoIsErrorUserInduced causes the FSD to retry up to some count, before triggering the “Lost Delayed Write Data” popup.
So, there is no generic and documented way of such retries.
Retries are supported at SCSI command layer between SCSI/STORPORT and the storage controller’s driver (miniport). If the SCSI operation raises the SCSI status of “retry needed” (can be a special sense info - forgot the details) - the SCSI/STORPORT will retry, up to some count.
- In Windows can we tell NTFS to forcibly flush and close all files on a given volume.
Just dismount the volume via FSCTL_DISMOUNT_VOLUME.
If you want to do gentle dismount and fail if there are open files, then issue FSCTL_LOCK_VOLUME before this. If you want to force dismount, rendering all open files inoperable - then do not do this.
This is what CHKDSK /F does: LOCK, the writes, DISMOUNT, UNLOCK, CloseHandle.
Note that in Windows, the volume will be automatically remounted in the next CreateFile attempt, so FSCTL_DISMOUNT_VOLUME is actually a remount.
The only way to avoid such remount is to put the volume offline, which is badly documented and I think will conflict with Failover Clustering which is the primary user of the feature.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com