What I mean by a 'netfs' when dealing with FS-Cache

From: David Howells
Date: Thu Apr 02 2009 - 12:50:25 EST



I think I see the problem. I think you're misunderstanding what I mean by
netfs.

Note that when I say 'netfs' I don't necessarily _mean_ it has to be a network
fs. It could be NFS, AFS, CIFS, but it might also be ISO9660. Look at these
two diagrams (taken from the docs added by patch 07):

+---------+
| | +--------------+
| NFS |--+ | |
| | | +-->| CacheFS |
+---------+ | +----------+ | | /dev/hda5 |
| | | | +--------------+
+---------+ +-->| | |
| | | |--+
| AFS |----->| FS-Cache |
| | | |--+
+---------+ +-->| | |
| | | | +--------------+
+---------+ | +----------+ | | |
| | | +-->| CacheFiles |
| ISOFS |--+ | /var/cache |
| | +--------------+
+---------+

NFS, AFS and ISOFS in this diagram all fill the roll of 'netfs'. CacheFS
(cache on blockdev) and CacheFiles (cache on filesystem) fill the roll of
'backingfs'.

And:

+---------+
| |
| Server |
| |
+---------+
| NETWORK
~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +----------+
V | |
+---------+ | |
| | | |
| NFS |----->| FS-Cache |
| | | |--+
+---------+ | | | +--------------+ +--------------+
| | | | | | | |
V +----------+ +-->| CacheFiles |-->| Ext3 |
+---------+ | /var/cache | | /dev/sda6 |
| | +--------------+ +--------------+
| VFS | ^ ^
| | | |
+---------+ +--------------+ |
| KERNEL SPACE | |
~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~|~~~~
| USER SPACE | |
V | |
+---------+ +--------------+
| | | |
| Process | | cachefilesd |
| | | |
+---------+ +--------------+


FS-Cache tracks pages from the 'netfs' because it may want to keep metadata on
them (such as where in the backingfs the pages are to be stored). In many
ways, PG_fscache is equivalent of PG_mappedtodisk. You could think of it as
PG_mappedtocache if you like.

The procedure for the netfs to use the cache on a page is that it calls one
of:

fscache_read_or_alloc_page()
fscache_read_or_alloc_pages()
fscache_alloc_page()

to either read pages from the cache or reserve space in the cache into which
the page can be written.

Then, the netfs calls:

fscache_write_page()

to write pages back to the cache as often as it likes. This may only be
called if read/alloc has been called first, and is permitted, inside the
caching backend (eg CacheFiles), to cache metadata about the read/alloc.

Finally, to polish off, the netfs calls:

fscache_uncache_page()

to tell FS-Cache to release any metadata it might hold on that page.

As I've been saying, I want to be able to make iso9660 be a client of FS-Cache
- ie: fill the roll of a netfs.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/