Martin Visser <martinvisse...@gmail.com> writes:

> I don't get how sync will write anything to a "ro" filesystem.
> That seems to be to break a fundamental kernel and filesystem principle.

...ah.  Um, it doesn't write anything to the file system, as such.  It
triggers the dirty pages in the kernel cache to write out to their block
devices.

The "read only" switch in the file system, and to some degree the file system
itself, are at a higher level, so are not involved especially.

(...and once the file system is read only it *should* not generate any more
 dirty blocks, although occasionally bugs could trigger this.)

> I would have thought either the "remount" would either force a flush of
> dirty blocks before it switches to "ro", or alternatively those blocks still
> dirty at the time of the "remount" end up in the bit bucket.

Nope.  Not least because you *can't* make that assurance: the blocks written
may be in flight on the HBA, or even the network, between the file system and
the magnetic storage.

> Also I have seen this 3 sync incantation before.

It dates back a *long* time, well before Linux.  These days it is seldom, if
ever, necessary, but old habits die hard.

> It seems to me that all you are doing playing snap with processes that might
> have stuff to write but hasn't been flushed.

If there are active processes writing, sure.  It used to be, once upon a time,
that sync didn't (guarantee) to write every dirty block on the system.

(Theoretically, with enough block layers between the magnetic storage and the
 page cache you could perhaps still race to the same conclusion or so, but
 probably not.)

> After any sync and before the final shutdown I presume any running process
> is at liberty to create new dirty blocks that may or may not make it to disk
> in time.

Correct.  If you mount the file system read-only, though, you can be confident
that no *new* dirty blocks are being generated by that file system, absent
bugs.

        Daniel

-- 
✣ Daniel Pittman            ✉ dan...@rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to