From: trondmy@kernel.org
To: linux-nfs@vger.kernel.org
Subject: [PATCH v4 5/5] NFS: Don't ask for readdirplus if files are being written to
Date: Thu, 17 Feb 2022 17:33:23 -0500 [thread overview]
Message-ID: <20220217223323.696173-6-trondmy@kernel.org> (raw)
In-Reply-To: <20220217223323.696173-5-trondmy@kernel.org>
From: Trond Myklebust <trond.myklebust@hammerspace.com>
If a file is being written to, then readdirplus isn't going to help with
retrieving attributes, since we will have to flush out writes anyway in
order to sync the mtime/ctime.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/inode.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 1bef81f5373a..00500c369c5f 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -837,6 +837,7 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path,
int err = 0;
bool force_sync = query_flags & AT_STATX_FORCE_SYNC;
bool do_update = false;
+ bool record_cache = !nfs_have_writebacks(inode);
trace_nfs_getattr_enter(inode);
@@ -845,7 +846,8 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path,
STATX_INO | STATX_SIZE | STATX_BLOCKS;
if ((query_flags & AT_STATX_DONT_SYNC) && !force_sync) {
- nfs_readdirplus_parent_cache_hit(path->dentry);
+ if (record_cache)
+ nfs_readdirplus_parent_cache_hit(path->dentry);
goto out_no_revalidate;
}
@@ -894,17 +896,18 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path,
if (request_mask & STATX_BLOCKS)
do_update |= cache_validity & NFS_INO_INVALID_BLOCKS;
- if (do_update) {
+ if (record_cache) {
/* Update the attribute cache */
- if (!(server->flags & NFS_MOUNT_NOAC))
+ if (do_update && !(server->flags & NFS_MOUNT_NOAC))
nfs_readdirplus_parent_cache_miss(path->dentry);
else
nfs_readdirplus_parent_cache_hit(path->dentry);
+ }
+ if (do_update) {
err = __nfs_revalidate_inode(server, inode);
if (err)
goto out;
- } else
- nfs_readdirplus_parent_cache_hit(path->dentry);
+ }
out_no_revalidate:
/* Only return attributes that were revalidated. */
stat->result_mask = nfs_get_valid_attrmask(inode) | request_mask;
--
2.35.1
next prev parent reply other threads:[~2022-02-17 22:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 22:33 [PATCH v4 0/5] Readdir improvements trondmy
2022-02-17 22:33 ` [PATCH v4 1/5] NFS: Adjust the amount of readahead performed by NFS readdir trondmy
2022-02-17 22:33 ` [PATCH v4 2/5] NFS: Simplify nfs_readdir_xdr_to_array() trondmy
2022-02-17 22:33 ` [PATCH v4 3/5] NFS: Improve algorithm for falling back to uncached readdir trondmy
2022-02-17 22:33 ` [PATCH v4 4/5] NFS: Improve heuristic for readdirplus trondmy
2022-02-17 22:33 ` trondmy [this message]
2022-02-18 11:40 ` [PATCH v4 5/5] NFS: Don't ask for readdirplus if files are being written to Trond Myklebust
2022-02-18 11:37 ` [PATCH v4 4/5] NFS: Improve heuristic for readdirplus 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=20220217223323.696173-6-trondmy@kernel.org \
--to=trondmy@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox