Turning off caching and switching to read-only
Posted Aug 11, 2013 1:43 UTC (Sun) by
giraffedata (subscriber, #1954)
In reply to:
Turning off caching by mathstuf
Parent article:
A survey of memory management patches
Switching a filesystem image read-only cleans the cache, but does not purge it. Thus, when you next read the file and see the correct data, that is no proof that the kernel correctly wrote to the device, which is what the OP wants. For that, you need to purge the cache and then read.
As for what happens when you switch to read-only while writing to a file is in progress: The mount() system call to switch to read-only fails. It fails if any file is open for writing.
And I'll tell you when else it fails, which causes no end of pain: when there's an unlinked file (a file not in any directory) in the filesystem. Because the kernel must update the filesystem when the file eventually closes (because it must delete the file at that time), the kernel cannot allow the switch to r/o.
(
Log in to post comments)