* [PATCH 1/3] NFS: Optimise away the close-to-open GETATTR when we have NFSv4 OPEN
@ 2018-05-10 19:28 Trond Myklebust
2018-05-10 19:28 ` [PATCH 2/3] NFS: If the VFS sets LOOKUP_REVAL then force a lookup of the dentry Trond Myklebust
0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2018-05-10 19:28 UTC (permalink / raw)
To: linux-nfs
NFSv4 should not need to perform an extra close-to-open GETATTR as part
of the process of looking up a regular file, since the OPEN call will
do that for us.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/dir.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 73f8b43d988c..4a73bd8b4517 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1012,13 +1012,25 @@ int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags)
if (IS_AUTOMOUNT(inode))
return 0;
+
+ if (flags & LOOKUP_OPEN) {
+ switch (inode->i_mode & S_IFMT) {
+ case S_IFREG:
+ /* A NFSv4 OPEN will revalidate later */
+ if (server->caps & NFS_CAP_ATOMIC_OPEN)
+ goto out;
+ /* Fallthrough */
+ case S_IFDIR:
+ if (server->flags & NFS_MOUNT_NOCTO)
+ break;
+ /* NFS close-to-open cache consistency validation */
+ goto out_force;
+ }
+ }
+
/* VFS wants an on-the-wire revalidation */
if (flags & LOOKUP_REVAL)
goto out_force;
- /* This is an open(2) */
- if ((flags & LOOKUP_OPEN) && !(server->flags & NFS_MOUNT_NOCTO) &&
- (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
- goto out_force;
out:
return (inode->i_nlink == 0) ? -ENOENT : 0;
out_force:
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] NFS: If the VFS sets LOOKUP_REVAL then force a lookup of the dentry
2018-05-10 19:28 [PATCH 1/3] NFS: Optimise away the close-to-open GETATTR when we have NFSv4 OPEN Trond Myklebust
@ 2018-05-10 19:28 ` Trond Myklebust
2018-05-10 19:28 ` [PATCH 3/3] NFS: Optimise away lookups for rename targets Trond Myklebust
0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2018-05-10 19:28 UTC (permalink / raw)
To: linux-nfs
If nfs_lookup_revalidate() is called with LOOKUP_REVAL because a
previous path lookup failed, then we ought to force a full lookup
of the component name.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 4a73bd8b4517..9dde88334c9c 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1118,7 +1118,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
goto out_set_verifier;
/* Force a full look up iff the parent directory has changed */
- if (!nfs_is_exclusive_create(dir, flags) &&
+ if (!(flags & (LOOKUP_EXCL | LOOKUP_REVAL)) &&
nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) {
error = nfs_lookup_verify_inode(inode, flags);
if (error) {
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] NFS: Optimise away lookups for rename targets
2018-05-10 19:28 ` [PATCH 2/3] NFS: If the VFS sets LOOKUP_REVAL then force a lookup of the dentry Trond Myklebust
@ 2018-05-10 19:28 ` Trond Myklebust
0 siblings, 0 replies; 3+ messages in thread
From: Trond Myklebust @ 2018-05-10 19:28 UTC (permalink / raw)
To: linux-nfs
We can optimise away any lookup for a rename target, unless we're
being asked to revalidate a dentry that might be in use.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/dir.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 9dde88334c9c..b315f53b3aec 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1051,13 +1051,15 @@ int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags)
*
* If LOOKUP_RCU prevents us from performing a full check, return 1
* suggesting a reval is needed.
+ *
+ * Note that when creating a new file, or looking up a rename target,
+ * then it shouldn't be necessary to revalidate a negative dentry.
*/
static inline
int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry,
unsigned int flags)
{
- /* Don't revalidate a negative dentry if we're creating a new file */
- if (flags & LOOKUP_CREATE)
+ if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
return 0;
if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG)
return 1;
@@ -1347,7 +1349,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
* If we're doing an exclusive create, optimize away the lookup
* but don't hash the dentry.
*/
- if (nfs_is_exclusive_create(dir, flags))
+ if (nfs_is_exclusive_create(dir, flags) || flags & LOOKUP_RENAME_TARGET)
return NULL;
res = ERR_PTR(-ENOMEM);
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-10 19:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10 19:28 [PATCH 1/3] NFS: Optimise away the close-to-open GETATTR when we have NFSv4 OPEN Trond Myklebust
2018-05-10 19:28 ` [PATCH 2/3] NFS: If the VFS sets LOOKUP_REVAL then force a lookup of the dentry Trond Myklebust
2018-05-10 19:28 ` [PATCH 3/3] NFS: Optimise away lookups for rename targets Trond Myklebust
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.