All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: linux-cachefs@redhat.com
Cc: Jeff Layton <jlayton@kernel.org>,
	dhowells@redhat.com, Trond Myklebust <trondmy@hammerspace.com>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	Steve French <smfrench@gmail.com>,
	Dominique Martinet <asmadeus@codewreck.org>,
	Jeff Layton <jlayton@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Omar Sandoval <osandov@osandov.com>,
	JeffleXu <jefflexu@linux.alibaba.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org,
	linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org,
	v9fs-developer@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 08/11] fscache: Add a comment explaining how page-release optimisation works
Date: Tue, 18 Jan 2022 13:54:44 +0000	[thread overview]
Message-ID: <164251408479.3435901.9540165422908194636.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <164251396932.3435901.344517748027321142.stgit@warthog.procyon.org.uk>

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]
---

 include/linux/fscache.h |    5 +++++
 1 file changed, 5 insertions(+)

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))



  parent reply	other threads:[~2022-01-18 13:55 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18 13:52 [PATCH 00/11] fscache, cachefiles: Rewrite fixes/updates David Howells
2022-01-18 13:53 ` [PATCH 01/11] fscache: Fix the volume collision wait condition David Howells
2022-01-18 13:53 ` [PATCH 02/11] cachefiles: Calculate the blockshift in terms of bytes, not pages David Howells
2022-01-21 17:47   ` Jeff Layton
2022-01-18 13:53 ` [PATCH 03/11] cachefiles: set default tag name if it's unspecified David Howells
2022-01-21 17:51   ` Jeff Layton
2022-01-18 13:53 ` [PATCH 04/11] cachefiles: Make some tracepoint adjustments David Howells
2022-01-21 17:52   ` Jeff Layton
2022-01-18 13:54 ` [PATCH 05/11] cachefiles: Trace active-mark failure David Howells
2022-01-21 17:53   ` Jeff Layton
2022-01-18 13:54 ` [PATCH 06/11] cachefiles: Explain checks in a comment David Howells
2022-01-18 13:54 ` [PATCH 07/11] cachefiles: Check that the backing filesystem supports tmpfiles David Howells
2022-01-18 13:54 ` David Howells [this message]
2022-01-18 13:54 ` [PATCH 09/11] vfs, fscache: Add an IS_KERNEL_FILE() macro for the S_KERNEL_FILE flag David Howells
2022-01-18 16:23   ` Christoph Hellwig
2022-01-18 17:40   ` David Howells
2022-01-19  5:20     ` Christoph Hellwig
2022-01-19  9:18     ` David Howells
2022-01-19 11:15       ` Christian Brauner
2022-01-20  9:08       ` Christoph Hellwig
2022-01-20  9:37       ` David Howells
2022-01-18 13:55 ` [PATCH 10/11] netfs: Make ops->init_rreq() optional David Howells
2022-01-18 13:55 ` [PATCH 11/11] cifs: Support fscache indexing rewrite David Howells
2022-01-19  5:31   ` Steve French
2022-01-19  5:44   ` Steve French
2022-01-19  8:32   ` David Howells
2022-01-19  9:48     ` Shyam Prasad N
2022-01-19 10:38     ` 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=164251408479.3435901.9540165422908194636.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=anna.schumaker@netapp.com \
    --cc=asmadeus@codewreck.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=jefflexu@linux.alibaba.com \
    --cc=jlayton@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=osandov@osandov.com \
    --cc=smfrench@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=trondmy@hammerspace.com \
    --cc=v9fs-developer@lists.sourceforge.net \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.