Martin Frey wrote:
> What I don't understand is what happens if somebody
> writes to a mmaped area. The page will certainly be
> modifed. Reads will see the modification since the
> page is in page cache. What about a write that
> modifies a part of the same page? The contents in
> the page cache is newer than that what is in buffer
> cache or on disk, so a write that modifies only
> a part of a block should fetch out of page cache
> for a read-modify-write instead of buffer cache
> or from disk.
> What am I missing here?

You are missing the fact that the buffer heads on a page in the page
cache aren't referenced from the buffer cache hash table, and there is
no communication or consistency enforement at all between the two types
of cache.  There is nothing to stop you from using a buffer cache
operation, e.g., getblk, to access a block that is referenced by the
page cache, but doing so creates an inconsistent state: the buffer that
getblk hands you will not be the same as the one in the page cache.

The generic file access routines in the VFS take care of mapping file
data into page cache pages.  The various filesystems are called upon by
the VFS to map disk blocks into cache page buffers, and to do this they
access metadata blocks using buffer cache operations.  This works nicely
as long as metadata blocks and data blocks are strictly separated.

Is this confusing?  Yes it is.  The cache system is in a confused state
at the moment.  It works, it works efficiently, and a handful of people
on this planet understand it and can track down and fix bugs in it. 
Welcome to the party :-)

--
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]

Reply via email to