I'm looking to mmap
a region of a file, make changes, and then either msync(MS_INVALIDATE)
them so that my in memory changes are lost, or, should I like the changes, msync(MS_SYNC)
to write them back to the underlying storage.
The msync
manpage says the following on MS_INVALIDATE
:
When MS_INVALIDATE is specified, msync() shall invalidate all cached copies of mapped data that are inconsistent with the permanent storage locations such that subsequent references shall obtain data that was consistent with the permanent storage locations sometime between the call to msync() and the first subsequent memory reference to the data.
This gives the impression that an MS_INVALIDATE
should reset revert the memory back to the state in storage. However the changes seem to have already made their way to the device by the time I make the msync
call.
- Can I delay or prevent data from being written back to the device automatically?
- Is it possible to operate with manual write back only?
Notes
- The underlying storage can be several TB in size.