[Linux-cachefs] fscache_cookie

David Howells dhowells at redhat.com
Fri Jun 16 09:04:17 UTC 2006


Derek Siu <golf1123 at gmail.com> wrote:

> Would fscache_cookie still be needed if the filesystem that uses
> cachefs IS NOT a netfs?

Yes.  The cookie is a handle on stuff inside the cache.  It's just a number to
represent a cache object as far as the netfs is concerned.  As it happens, the
cache uses it as a pointer to its own internal structures, but the netfs
shouldn't need to know _what_ a cookie actually _is_.

> I am quite confused about that because it seems like every cache operation
> need the cookie.

Yes.  Consider the cookie a shortcut to avoid having to give each cache
operation a list of keys to the object.  Compare it to userspace I/O syscalls.
Many of them take an integer fd.  Userspace doesn't know what an fd actually
_is_, and it doesn't need to know - it's just an index to a look up table of
handles to kernel objects in the Linux kernel, but it doesn't have to be.

That, however, doesn't stop userspace reading and writing data using the fd as
a shortcut.  We could require that read() and write() take filenames instead,
but it would be slow and messy.

> Yet, the get cookie function (i.e. fscache_acquire_cookie) is only defined
> in the netfs API.

Yes.  Where else would it be appropriate?  It's not something that a cache
backend should be using.

I've not made the definition of fscache_cookie available to the netfs because
the netfs shouldn't be poking around in it, and shouldn't need to.  Of course,
there may be something I've missed.

David




More information about the Linux-cachefs mailing list