All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Coddington <bcodding@redhat.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH v3 1/8] NFS: save the directory's change attribute on pagecache pages
Date: Wed, 23 Feb 2022 08:40:28 -0500	[thread overview]
Message-ID: <d759b6df8acd82b8d44e2afcf11a7a94dcf85ba6.1645623510.git.bcodding@redhat.com> (raw)
In-Reply-To: <20220221160851.15508-14-trondmy@kernel.org>

After a pagecache page has been filled with entries, set PagePrivate and
the directory's change attribute on the page.  This will help us perform
per-page invalidations in a later patch.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/dir.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 9f48c75dbf4c..79bdcedc0cad 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -54,6 +54,9 @@ static int nfs_closedir(struct inode *, struct file *);
 static int nfs_readdir(struct file *, struct dir_context *);
 static int nfs_fsync_dir(struct file *, loff_t, loff_t, int);
 static loff_t nfs_llseek_dir(struct file *, loff_t, int);
+static void nfs_readdir_invalidatepage(struct page *,
+			unsigned int, unsigned int);
+static int nfs_readdir_clear_page(struct page*, gfp_t);
 static void nfs_readdir_clear_array(struct page*);
 
 const struct file_operations nfs_dir_operations = {
@@ -66,6 +69,8 @@ const struct file_operations nfs_dir_operations = {
 };
 
 const struct address_space_operations nfs_dir_aops = {
+	.invalidatepage = nfs_readdir_invalidatepage,
+	.releasepage = nfs_readdir_clear_page,
 	.freepage = nfs_readdir_clear_array,
 };
 
@@ -212,6 +217,27 @@ static void nfs_readdir_page_init_array(struct page *page, u64 last_cookie)
 	array->last_cookie = last_cookie;
 	array->cookies_are_ordered = 1;
 	kunmap_atomic(array);
+	set_page_private(page, 0);
+}
+
+static int
+nfs_readdir_clear_page(struct page *page, gfp_t gfp_mask)
+{
+	detach_page_private(page);
+	return 1;
+}
+
+static void
+nfs_readdir_invalidatepage(struct page *page, unsigned int offset,
+							unsigned int length)
+{
+	nfs_readdir_clear_page(page, GFP_KERNEL);
+}
+
+static void
+nfs_readdir_set_page_verifier(struct page *page, unsigned long verf)
+{
+	attach_page_private(page, (void *)verf);
 }
 
 /*
@@ -794,6 +820,8 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc,
 		if (status != -ENOSPC)
 			continue;
 
+		nfs_readdir_set_page_verifier(page, desc->dir_verifier);
+
 		if (page->mapping != mapping) {
 			if (!--narrays)
 				break;
@@ -822,10 +850,13 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc,
 	case -EBADCOOKIE:
 		if (entry->eof) {
 			nfs_readdir_page_set_eof(page);
+			nfs_readdir_set_page_verifier(page, desc->dir_verifier);
 			status = 0;
 		}
 		break;
 	case -ENOSPC:
+		nfs_readdir_set_page_verifier(page, desc->dir_verifier);
+		fallthrough;
 	case -EAGAIN:
 		status = 0;
 		break;
-- 
2.31.1


  reply	other threads:[~2022-02-23 13:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 16:08 [PATCH v6 00/13] Readdir improvements trondmy
2022-02-21 16:08 ` [PATCH v6 01/13] NFS: constify nfs_server_capable() and nfs_have_writebacks() trondmy
2022-02-21 16:08   ` [PATCH v6 02/13] NFS: Trace lookup revalidation failure trondmy
2022-02-21 16:08     ` [PATCH v6 03/13] NFS: Adjust the amount of readahead performed by NFS readdir trondmy
2022-02-21 16:08       ` [PATCH v6 04/13] NFS: Simplify nfs_readdir_xdr_to_array() trondmy
2022-02-21 16:08         ` [PATCH v6 05/13] NFS: Improve algorithm for falling back to uncached readdir trondmy
2022-02-21 16:08           ` [PATCH v6 06/13] NFS: Improve heuristic for readdirplus trondmy
2022-02-21 16:08             ` [PATCH v6 07/13] NFS: Don't ask for readdirplus unless it can help nfs_getattr() trondmy
2022-02-21 16:08               ` [PATCH v6 08/13] NFSv4: Ask for a full XDR buffer of readdir goodness trondmy
2022-02-21 16:08                 ` [PATCH v6 09/13] NFS: Readdirplus can't help lookup for case insensitive filesystems trondmy
2022-02-21 16:08                   ` [PATCH v6 10/13] NFS: Don't request readdirplus when revaldation was forced trondmy
2022-02-21 16:08                     ` [PATCH v6 11/13] NFS: Add basic readdir tracing trondmy
2022-02-21 16:08                       ` [PATCH v6 12/13] NFS: Trace effects of readdirplus on the dcache trondmy
2022-02-21 16:08                         ` [PATCH v6 13/13] NFS: Trace effects of the readdirplus heuristic trondmy
2022-02-23 13:40                           ` Benjamin Coddington [this message]
2022-02-23 13:40                             ` [PATCH v3 2/8] NFSv4: Send GETATTR with READDIR Benjamin Coddington
2022-02-23 13:40                               ` [PATCH v3 3/8] NFS: Add a struct to track readdir pagecache location Benjamin Coddington
2022-02-23 13:40                                 ` [PATCH v3 4/8] NFS: Keep the readdir pagecache cursor updated Benjamin Coddington
2022-02-23 13:40                                   ` [PATCH v3 5/8] NFS: readdir per-page cache validation Benjamin Coddington
2022-02-23 13:40                                     ` [PATCH v3 6/8] NFS: stash the readdir pagecache cursor on the open directory context Benjamin Coddington
2022-02-23 13:40                                       ` [PATCH v3 7/8] NFS: Support headless readdir pagecache pages Benjamin Coddington
2022-02-23 13:40                                         ` [PATCH v3 8/8] NFS: Revalidate the directory pagecache on every nfs_readdir() Benjamin Coddington
2022-02-21 16:45           ` [PATCH v6 05/13] NFS: Improve algorithm for falling back to uncached readdir Benjamin Coddington
2022-02-21 19:58             ` Trond Myklebust
2022-02-21 20:22               ` Benjamin Coddington
2022-02-21 20:55                 ` Trond Myklebust
2022-02-21 21:10                   ` Benjamin Coddington
2022-02-21 23:20                     ` Trond Myklebust
2022-02-22 12:50                       ` Benjamin Coddington
2022-02-22 20:11                         ` Trond Myklebust
2022-02-22 20:21                           ` Benjamin Coddington
2022-02-23 12:17                             ` Trond Myklebust
2022-02-23 13:34                               ` Benjamin Coddington
2022-02-23 21:31                                 ` Trond Myklebust

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=d759b6df8acd82b8d44e2afcf11a7a94dcf85ba6.1645623510.git.bcodding@redhat.com \
    --to=bcodding@redhat.com \
    --cc=linux-nfs@vger.kernel.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.