diff options
author | David Howells <dhowells@redhat.com> | 2022-01-07 12:28:41 +0300 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2022-01-22 00:36:28 +0300 |
commit | c522e3ad296b7b692ed3960dfde467f2a34b434f (patch) | |
tree | 62d967b182c1daf2a36b3b396b9e0073ee535603 /include/linux/fscache.h | |
parent | 6633213139d827fb9abf9a9a280f3d9e89fc7091 (diff) | |
download | linux-c522e3ad296b7b692ed3960dfde467f2a34b434f.tar.xz |
fscache: Add a comment explaining how page-release optimisation works
Add a comment into fscache_note_page_release() to explain how the
page-release optimisation logic works[1]. It's not entirely obvious as it
has nothing to do with whether or not the netfs file contains data.
FSCACHE_COOKIE_NO_DATA_TO_READ is set if we have no data in the cache yet
(ie. the backing file lookup was negative, the file is 0 length or the
cookie got invalidated). It means that we have no data in the cache, not
that the file is necessarily empty on the server.
FSCACHE_COOKIE_HAVE_DATA is set once we've stored data in the backing file.
From that point on, we have data we *could* read - however, it's covered by
pages in the netfs pagecache until at such time one of those covering pages
is released.
So if we've written data to the cache (HAVE_DATA) and there wasn't any data
in the cache when we started (NO_DATA_TO_READ), it may no longer be true
that we can skip reading from the cache.
Read skipping is done by cachefiles_prepare_read().
Note that tracking is not done on a per-page basis, but only on a per-file
basis.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/043a206f03929c2667a465314144e518070a9b2d.camel@kernel.org/ [1]
Link: https://lore.kernel.org/r/164251408479.3435901.9540165422908194636.stgit@warthog.procyon.org.uk/ # v1
Diffstat (limited to 'include/linux/fscache.h')
-rw-r--r-- | include/linux/fscache.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/fscache.h b/include/linux/fscache.h index ede50406bcb0..296c5f1d9f35 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h @@ -665,6 +665,11 @@ static inline void fscache_clear_inode_writeback(struct fscache_cookie *cookie, static inline void fscache_note_page_release(struct fscache_cookie *cookie) { + /* If we've written data to the cache (HAVE_DATA) and there wasn't any + * data in the cache when we started (NO_DATA_TO_READ), it may no + * longer be true that we can skip reading from the cache - so clear + * the flag that causes reads to be skipped. + */ if (cookie && test_bit(FSCACHE_COOKIE_HAVE_DATA, &cookie->flags) && test_bit(FSCACHE_COOKIE_NO_DATA_TO_READ, &cookie->flags)) |