]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
fscache: Implement cookie registration
authorDavid Howells <dhowells@redhat.com>
Wed, 20 Oct 2021 14:53:34 +0000 (15:53 +0100)
committerDavid Howells <dhowells@redhat.com>
Fri, 26 Nov 2021 14:28:51 +0000 (14:28 +0000)
commit8305d638574bf1afe100f60166b71cda28f95dfb
tree9d6184db2b86941c83b009ff2bf4b58a48691c89
parent3189a86875f6d2cc5c6abe977e9427d3c9591761
fscache: Implement cookie registration

Add functions to the fscache API to allow data file cookies to be acquired
and relinquished by the network filesystem.  It is intended that the
filesystem will create such cookies per-inode under a volume.

To request a cookie, the filesystem should call:

struct fscache_cookie *
fscache_acquire_cookie(struct fscache_volume *volume,
       u8 advice,
       const void *index_key,
       size_t index_key_len,
       const void *aux_data,
       size_t aux_data_len,
       loff_t object_size)

The filesystem must first have created a volume cookie, which is passed in
here.  If it passes in NULL then the function will just return a NULL
cookie.

A binary key should be passed in index_key and is of size index_key_len.
This is saved in the cookie and is used to locate the associated data in
the cache.

A coherency data buffer of size aux_data_len will be allocated and
initialised from the buffer pointed to by aux_data.  This is used to
validate cache objects when they're opened and is stored on disk with them
when they're committed.  The data is stored in the cookie and will be
updateable by various functions in later patches.

The object_size must also be given.  This is also used to perform a
coherency check and to size the backing storage appropriately.

This function disallows a cookie from being acquired twice in parallel,
though it will cause the second user to wait if the first is busy
relinquishing its cookie.

When a network filesystem has finished with a cookie, it should call:

void
fscache_relinquish_cookie(struct fscache_volume *volume,
  bool retire)

If retire is true, any backing data will be discarded immediately.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-cachefs@redhat.com
fs/fscache/Makefile
fs/fscache/cookie.c [new file with mode: 0644]
fs/fscache/internal.h
fs/fscache/main.c
fs/fscache/proc.c
fs/fscache/stats.c
include/linux/fscache-cache.h
include/linux/fscache.h
include/trace/events/fscache.h