Hi,
I encountered a mild “inconvenience” while working with FAT32 formatted storage devices:
In one of the projects I’m involved in, I implemented a file system inside a file whom I’m creating on the storage device (not that uncommon). The file itself occupies most of the usable space of the storage device and the user “sees” only my mounted file system.
When the user tries to safely remove the device, it triggers FAT’s lazy writer(s) and the remove operation takes forever (well, not forever, but much longer than I’d want it to take). In other case, if the user surprise removes the device, she sees the “delayed write failed” pop-up, indicating that the file wasn’t properly flushed.
I want to emphasize that I’m obligated to the “original” underlying file system of the storage device, hence if it comes formatted as FAT32, I can’t change it to something more “comfortable” like NTFS and correct my file’s valid size.
Due to the fact that I’m entirely controlling the used and unused sectors of this device (at least on systems having my drivers installed, etc.), can I somehow “disable” FAT’s LW, for this specific case (I’d happily have them working in the background when my file is already initialized, as I don’t want the user to entirely lose her information on surprise removal cases).
I tried zero-ing the file myself and it still takes too much time (and why wouldn’t it?), I don’t want to mimic surprise removal on safe removal (according to fastfat’s sample, the actual flush and cache purge are triggered on IRP_MN_QUERY_REMOVE_DEVICE), at least not in PnP terms and I’d rather prefer preserving its semantics (for example, according to fastfat’s sample, marking it as write protected will prevent the flush), but I really can’t think of something better.
If I could, somehow, “mark” this file so that it could avoid the flush, only in the scope of its initialization, it could be awesome.
I’d greatly appreciate any suggestions, workarounds and ideas.
Thanks in advance,
Leonid.
P.S.,
If I’m not mistaken, exFAT also employs LW, so although I can keep the “FAT”-ness of the device, re-formatting it to exFAT won’t help, right?