Well, there are various issues here. You should really go the route that Maxim suggested and work with VSS.
First, there are certain things that your service doesn’t control that might require flushing (think about directory entries, the FS itself uses caching for those). So if you don’t flush the whole volume then you might miss some of the metadata so the volume won’t be in a consistent state (meaning your snapshot is corrupted from an NTFS perspective).
Second, even if the volume is NTFS consistent it is possible that some applications have not flushed their data and so their state is inconsistent. If you only do this to access certain files on the volume, files that YOUR PRODUCT owns then you might be safe since you can guarantee that the program state is saved to files (because presumably you’ve told your product to flush all its state) and that the data is written to disk (this is the only place where FILE_FLAG_WRITE_THROUGH helps). If you touch any other application’s files (and the OS is just another application from this perspective, so any system files fall under this) then you must use VSS to let the application know to flush its data. Moreover, not only is it possible that the state isn’t preserved across different files, but it is also possible that any file isn’t in a consistent state (if an application opens a file and does not share READ it doesn’t expect that there is anyone reading the file so it doesn’t have to try to keep it consistent). So this is the case for VSS integration, hope it makes sense…
Thanks,
Alex.
On Apr 2, 2013, at 9:55 AM, xxxxx@tastewar.com wrote:
Our application services remote clients by reading and writing files using NTFS. Our service accesses all files with the FILE_FLAG_WRITE_THROUGH set and no other flags set (in particular, FILE_FLAG_NOBUFFERING is not set, so NTFS manages the file cache). Our files reside on a non-boot partition.
Occasionally, our service suspends all file writes to the volume, and uses various SAN-based methods (e.g. fracture clone or snapcopy) to create a point-in-time copy of the LUN containing the volume. This copy of the LUN is used in our backup process.
Our question is, do we need to call FlushFileBuffers with a handle to the volume after we suspend writes and before we create the copy? FlushFileBuffers can take a long time to complete, and our application is quiesced during that time, so we would prefer to eliminate that call. Our research indicates that the call should not be necessary, although the language in the various Microsoft documentation is ambiguous.
Empirically, even in carefully controlled tests, ProcMon running during our call to FlushFileBuffers shows metadata ($MFT) being written to disk. We’re puzzled by this behavior and welcome any insights.
NTFSD is sponsored by OSR
OSR is hiring!! Info at http://www.osr.com/careers
For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer