From: David Howells <dhowells@redhat.com>
To: Daniel Phillips <phillips@phunq.net>
Cc: Trond.Myklebust@netapp.com, nfsv4@linux-nfs.org,
linux-kernel@vger.kernel.org, dhowells@redhat.com,
linux-fsdevel@vger.kernel.org,
linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov,
casey@schaufler-ca.com
Subject: Re: [PATCH 00/37] Permit filesystem local caching
Date: Tue, 26 Feb 2008 14:33:38 +0000 [thread overview]
Message-ID: <27528.1204036418@redhat.com> (raw)
In-Reply-To: <200802260226.26984.phillips@phunq.net>
Daniel Phillips <phillips@phunq.net> wrote:
> I need to respond to this in pieces... first the bit that is bugging
> me:
>
> > > * two new page flags
> >
> > I need to keep track of two bits of per-cached-page information:
> >
> > (1) This page is known by the cache, and that the cache must be informed if
> > the page is going to go away.
>
> I still do not understand the life cycle of this bit. What does the
> cache do when it learns the page has gone away?
That's up to the cache. CacheFS, for example, unpins some resources when all
the pages managed by a pointer block are taken away from it. The cache may
also reserve a block on disk to back this page, and that reservation may then
be discarded by the netfs uncaching the page.
The cache may also speculatively take copies of the page if the machine is
idle.
Documentation/filesystems/caching/netfs-api.txt describes the caching API as a
process, including the presentation of netfs pages to the cache and their
uncaching.
> How is it informed?
[Documentation/filesystems/caching/netfs-api.txt]
==============
PAGE UNCACHING
==============
To uncache a page, this function should be called:
void fscache_uncache_page(struct fscache_cookie *cookie,
struct page *page);
This function permits the cache to release any in-memory representation it
might be holding for this netfs page. This function must be called once for
each page on which the read or write page functions above have been called to
make sure the cache's in-memory tracking information gets torn down.
Note that pages can't be explicitly deleted from the data file. The whole
data file must be retired (see the relinquish cookie function below).
Furthermore, note that this does not cancel the asynchronous read or write
operation started by the read/alloc and write functions.
[/]
> Who owns the page cache in which such a page lives, the nfs client?
> Filesystem that hosts the page? A third page cache owned by the
> cache itself? (See my basic confusion about how many page cache
> levels you have, below.)
[Documentation/filesystems/caching/fscache.txt]
(7) Data I/O is done direct to and from the netfs's pages. The netfs
indicates that page A is at index B of the data-file represented by cookie
C, and that it should be read or written. The cache backend may or may
not start I/O on that page, but if it does, a netfs callback will be
invoked to indicate completion. The I/O may be either synchronous or
asynchronous.
[/]
I should perhaps make the documentation more explicit: the pages passed to the
routines defined in include/linux/fscache.h are netfs pages, normally belonging
the pagecache of the appropriate netfs inode. This is, however, mentioned in
the function banner comments in fscache.h.
> Suppose one were to take a mundane approach to the persistent cache
> problem instead of layering filesystems. What you would do then is
> change NFS's ->write_page and variants to fiddle the persistent
> cache
It is a requirement laid down by the Linux NFS fs maintainers that the writes
to the cache be asynchronous, even if the writes to NFS aren't.
Note further that NFS's write_page() != writing to the cache. Writing to the
cache is typically done by NFS's readpages().
Besides, at the moment, caching is suppressed for any NFS file opened for
writing due to coherency issues. This is something to be revisited later.
> as well as the network, instead of just the network as now.
Not as now. See above.
> This fiddling could even consist of ->write calls to another
> filesystem, though working directly with the bio interface would
> yield the fastest, and therefore to my mind, best result.
You can't necessarily access the BIO interface, and even if you can, the cache
is still a filesystem.
Essentially, what cachefiles does is to do what you say: to perform ->write
calls on another filesystem.
FS-Cache also protects the netfs against (a) there being no cache, (b) the
cache suffering a fatal I/O error and (c) the cache being removed; and protects
the cache against (d) the netfs uncaching pages that the cache is using and (e)
conflicting operations from the netfs, some of which may be queued for
asynchronous processing.
FS-Cache also groups asynchronous netfs store requests together, which
hopefully, one day, I'll be able to pass on to the backing fs.
> In any case, you find out how to write the page to backing store by
> asking the filesystem, which in the naive approach would be nfs
> augmented with caching library calls.
NFS and AFS and CIFS and ISOFS, but yes, that's what fscache is, if you like, a
caching library.
> The filesystem keeps its own metadata around to know how to map the page to
> disk. So again naively, this metadata could tell the nfs client that the
> page is not mapped to disk at all.
The netfs should _not_ know about the metadata of a backing fs. Firstly, there
are many different potential backing filesystems, and secondly if the netfs
knows about the metadata of the backing fs, then the backing fs has to ask the
netfs's permission if it wants to change it (background defragmentation, for
instance).
The only bit of metadata Cachefiles asks for is whether a block is represented
on disk or not. This indicates whether the page held in that block is in the
cache or whether it has to be retrieved from the server. The answer to that
shouldn't change if the backing fs shuffles its (meta)data around on disk.
> So I do not see what your per-page bit is for, obviously because I do not
> fully understand your caching scheme.
It's an indication to the netfs that the cache has an interest in this page,
where an interest may be a pointer to it, resources allocated or reserverd for
it, or I/O in progress upon it.
> Which I could eventually find out by reading all the patches but asking you
> is so much more fun :-)
And a waste of my time. I've provided documentation in the main FS-Cache
patch, both as text files and in comments in header files that answer your
questions. Please read them first.
> By the way, how many levels of page caching for the same data are
> there, is it:
>
> 1) nfs client
> 2) cache layer's own page cache
> 3) filesystem hosting the cache
>
> or just:
>
> 1) nfs client page cache
> 2) filesystem hosting the cache
>
> I think it is the second, but that is already double caching, which
> has got to hurt.
Actually, it is ideally:
1) NFS client page cache.
But, because I can't do in-kernel O_DIRECT at the moment, with _CacheFiles_, it
is:
1) NFS client page cache.
2) Backing fs page cache.
With CacheFS it really is:
1) NFS client page cache.
and it really does BIOs directly to/from the pages in the netfs.
David
next prev parent reply other threads:[~2008-02-26 14:33 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-20 16:05 [PATCH 00/37] Permit filesystem local caching David Howells
2008-02-20 16:06 ` [PATCH 01/37] KEYS: Increase the payload size when instantiating a key David Howells
2008-02-20 16:06 ` [PATCH 02/37] KEYS: Check starting keyring as part of search David Howells
2008-02-20 16:06 ` [PATCH 03/37] KEYS: Allow the callout data to be passed as a blob rather than a string David Howells
2008-02-20 16:06 ` [PATCH 04/37] KEYS: Add keyctl function to get a security label David Howells
2008-02-20 16:06 ` [PATCH 05/37] Security: Change current->fs[ug]id to current_fs[ug]id() David Howells
2008-02-20 16:06 ` [PATCH 06/37] Security: Separate task security context from task_struct David Howells
2008-02-22 4:47 ` Casey Schaufler
2008-02-20 16:06 ` [PATCH 07/37] Security: De-embed task security record from task and use refcounting David Howells
2008-02-22 4:57 ` Casey Schaufler
2008-02-20 16:06 ` [PATCH 08/37] Security: Add a kernel_service object class to SELinux David Howells
2008-02-20 16:06 ` [PATCH 09/37] Security: Allow kernel services to override LSM settings for task actions David Howells
2008-02-22 5:06 ` Casey Schaufler
2008-02-22 13:06 ` David Howells
2008-02-20 16:06 ` [PATCH 10/37] Security: Make NFSD work with detached security David Howells
2008-02-20 16:06 ` [PATCH 11/37] FS-Cache: Release page->private after failed readahead David Howells
2008-02-20 16:07 ` [PATCH 12/37] FS-Cache: Recruit a couple of page flags for cache management David Howells
2008-02-20 16:07 ` [PATCH 13/37] FS-Cache: Provide an add_wait_queue_tail() function David Howells
2008-02-20 16:07 ` [PATCH 14/37] FS-Cache: Generic filesystem caching facility David Howells
2008-02-20 16:07 ` [PATCH 15/37] CacheFiles: Add missing copy_page export for ia64 David Howells
2008-02-20 16:07 ` [PATCH 16/37] CacheFiles: Be consistent about the use of mapping vs file->f_mapping in Ext3 David Howells
2008-02-20 16:07 ` [PATCH 17/37] CacheFiles: Add a hook to write a single page of data to an inode David Howells
2008-02-20 16:07 ` [PATCH 18/37] CacheFiles: Permit the page lock state to be monitored David Howells
2008-02-20 16:07 ` [PATCH 19/37] CacheFiles: Export things for CacheFiles David Howells
2008-02-20 16:07 ` [PATCH 20/37] CacheFiles: A cache that backs onto a mounted filesystem David Howells
2008-02-20 16:07 ` [PATCH 21/37] NFS: Add comment banners to some NFS functions David Howells
2008-02-20 16:07 ` [PATCH 22/37] NFS: Add FS-Cache option bit and debug bit David Howells
2008-02-20 16:08 ` [PATCH 23/37] NFS: Permit local filesystem caching to be enabled for NFS David Howells
2008-02-20 16:08 ` [PATCH 24/37] NFS: Register NFS for caching and retrieve the top-level index David Howells
2008-02-20 16:08 ` [PATCH 25/37] NFS: Define and create server-level objects David Howells
2008-02-20 16:08 ` [PATCH 26/37] NFS: Define and create superblock-level objects David Howells
2008-02-20 16:08 ` [PATCH 27/37] NFS: Define and create inode-level cache objects David Howells
2008-02-20 16:08 ` [PATCH 28/37] NFS: Use local disk inode cache David Howells
2008-02-20 16:08 ` [PATCH 29/37] NFS: Invalidate FsCache page flags when cache removed David Howells
2008-02-20 16:08 ` [PATCH 30/37] NFS: Add some new I/O event counters for FS-Cache events David Howells
2008-02-20 16:08 ` [PATCH 31/37] NFS: FS-Cache page management David Howells
2008-02-20 16:08 ` [PATCH 32/37] NFS: Add read context retention for FS-Cache to call back with David Howells
2008-02-20 16:08 ` [PATCH 33/37] NFS: nfs_readpage_async() needs to be accessible as a fallback for local caching David Howells
2008-02-20 16:09 ` [PATCH 34/37] NFS: Read pages from FS-Cache into an NFS inode David Howells
2008-02-20 16:09 ` [PATCH 35/37] NFS: Store pages from an NFS inode into a local cache David Howells
2008-02-20 16:09 ` [PATCH 36/37] NFS: Display local caching state David Howells
2008-02-20 16:09 ` [PATCH 37/37] NFS: Add mount options to enable local caching on NFS David Howells
2008-02-20 19:58 ` [PATCH 00/37] Permit filesystem local caching Serge E. Hallyn
2008-02-20 20:11 ` David Howells
2008-02-21 3:07 ` Daniel Phillips
2008-02-21 12:31 ` David Howells
2008-02-21 14:55 ` David Howells
2008-02-21 15:17 ` Kevin Coffman
2008-02-21 22:44 ` Daniel Phillips
2008-02-21 22:52 ` Muntz, Daniel
2008-02-22 0:07 ` David Howells
2008-02-22 0:57 ` Daniel Phillips
2008-02-22 12:48 ` David Howells
2008-02-22 22:25 ` Daniel Phillips
2008-02-23 1:22 ` David Howells
2008-02-21 23:33 ` David Howells
2008-02-22 13:52 ` Chris Mason
2008-02-22 16:12 ` David Howells
2008-02-22 16:47 ` David Howells
2008-02-25 23:19 ` David Howells
2008-02-26 0:43 ` Daniel Phillips
2008-02-26 2:00 ` David Howells
2008-02-26 10:26 ` Daniel Phillips
2008-02-26 14:33 ` David Howells [this message]
2008-02-26 19:43 ` Daniel Phillips
2008-02-26 21:09 ` David Howells
2008-02-22 16:14 ` David Howells
-- strict thread matches above, loose matches on Subject: below --
2008-02-22 16:01 Rick Macklem
2008-02-08 16:51 David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=27528.1204036418@redhat.com \
--to=dhowells@redhat.com \
--cc=Trond.Myklebust@netapp.com \
--cc=casey@schaufler-ca.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
--cc=phillips@phunq.net \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).