2021-03-30 00:20:19

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH 00/17] Attribute revalidation updates

From: Trond Myklebust <[email protected]>

The following updates try to simplify some of the attribute caching, and
further split out the attribute cache tracking. In particular, we want
to make use of the fact that NFSv4.x doesn't always need to retrieve all
the attributes to optimise the way we use the GETATTR call.

Before this patch set, when I run xfstests, I see

NFSv3:: getattr: 444656, lookup: 144117, access: 112148
NFSv4.1:: getattr: 898027, lookup: 68847, access: 14766, open: 111409
NFSv4.2:: getattr: 593422, lookup: 72488, access: 16647, open: 113056

after application of the patch set:

NFSv3:: getattr: 399324, lookup: 142331, access: 112444
NFSv4.1:: getattr: 134778, lookup: 70673, access: 15059, open: 112192
NFSv4.2:: getattr: 139080, lookup: 70722, access: 16563, open: 113601

Note that these numbers are against a knfsd server that does not support
the "change_attr_type" attribute. I'd expect further improvements once
we re-introduce that server support.

Trond Myklebust (17):
NFS: Deal correctly with attribute generation counter overflow
NFS: Fix up inode cache tracing
NFS: Mask out unsupported attributes in nfs_getattr()
NFS: NFS_INO_REVAL_PAGECACHE should mark the change attribute invalid
NFS: Fix up revalidation of space used
NFS: Don't revalidate attributes that are not being asked for
NFS: Fix up statx() results
NFS: Add a cache validity flag argument to nfs_revalidate_inode()
NFS: Replace use of NFS_INO_REVAL_PAGECACHE when checking cache
validity
NFS: Don't set NFS_INO_REVAL_PAGECACHE in the inode cache validity
NFS: Separate tracking of file nlinks cache validity from the
mode/uid/gid
NFS: Fix up handling of outstanding layoutcommit in nfs_update_inode()
NFS: Remove a line of code that has no effect in nfs_update_inode()
NFS: Simplify cache consistency in nfs_check_inode_attributes()
NFSv4: Fix value of decode_fsinfo_maxsz
NFSv4: Add support for the NFSv4.2 "change_attr_type" attribute
NFS: Use information about the change attribute to optimise updates

fs/nfs/client.c | 3 +
fs/nfs/dir.c | 4 +-
fs/nfs/export.c | 6 +-
fs/nfs/file.c | 2 +-
fs/nfs/inode.c | 246 +++++++++++++++++++++++++++-----------
fs/nfs/nfs3acl.c | 2 +-
fs/nfs/nfs3xdr.c | 1 +
fs/nfs/nfs4proc.c | 45 ++++---
fs/nfs/nfs4xdr.c | 43 ++++++-
fs/nfs/nfstrace.h | 9 +-
fs/nfs/proc.c | 1 +
fs/nfs/write.c | 2 +-
include/linux/nfs4.h | 9 ++
include/linux/nfs_fs.h | 4 +-
include/linux/nfs_fs_sb.h | 3 +
include/linux/nfs_xdr.h | 2 +
16 files changed, 283 insertions(+), 99 deletions(-)

--
2.30.2


2021-03-30 00:20:44

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH 01/17] NFS: Deal correctly with attribute generation counter overflow

From: Trond Myklebust <[email protected]>

We need to use unsigned long subtraction and then convert to signed in
order to deal correcly with C overflow rules.

Fixes: f5062003465c ("NFS: Set an attribute barrier on all updates")
Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/inode.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index ff737be559dc..8de5b3b9da91 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1662,10 +1662,10 @@ EXPORT_SYMBOL_GPL(_nfs_display_fhandle);
*/
static int nfs_inode_attrs_need_update(const struct inode *inode, const struct nfs_fattr *fattr)
{
- const struct nfs_inode *nfsi = NFS_I(inode);
+ unsigned long attr_gencount = NFS_I(inode)->attr_gencount;

- return ((long)fattr->gencount - (long)nfsi->attr_gencount) > 0 ||
- ((long)nfsi->attr_gencount - (long)nfs_read_attr_generation_counter() > 0);
+ return (long)(fattr->gencount - attr_gencount) > 0 ||
+ (long)(attr_gencount - nfs_read_attr_generation_counter()) > 0;
}

static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr)
@@ -2094,7 +2094,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
nfsi->attrtimeo_timestamp = now;
}
/* Set the barrier to be more recent than this fattr */
- if ((long)fattr->gencount - (long)nfsi->attr_gencount > 0)
+ if ((long)(fattr->gencount - nfsi->attr_gencount) > 0)
nfsi->attr_gencount = fattr->gencount;
}

--
2.30.2

2021-03-30 00:20:44

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH 02/17] NFS: Fix up inode cache tracing

From: Trond Myklebust <[email protected]>

Add missing enum definitions and missing entries for
nfs_show_cache_validity().

Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/nfstrace.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index 5a59dcdce0b2..cdba6eebe3cb 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -45,6 +45,9 @@ TRACE_DEFINE_ENUM(NFS_INO_INVALID_CTIME);
TRACE_DEFINE_ENUM(NFS_INO_INVALID_MTIME);
TRACE_DEFINE_ENUM(NFS_INO_INVALID_SIZE);
TRACE_DEFINE_ENUM(NFS_INO_INVALID_OTHER);
+TRACE_DEFINE_ENUM(NFS_INO_DATA_INVAL_DEFER);
+TRACE_DEFINE_ENUM(NFS_INO_INVALID_BLOCKS);
+TRACE_DEFINE_ENUM(NFS_INO_INVALID_XATTR);

#define nfs_show_cache_validity(v) \
__print_flags(v, "|", \
@@ -60,6 +63,8 @@ TRACE_DEFINE_ENUM(NFS_INO_INVALID_OTHER);
{ NFS_INO_INVALID_MTIME, "INVALID_MTIME" }, \
{ NFS_INO_INVALID_SIZE, "INVALID_SIZE" }, \
{ NFS_INO_INVALID_OTHER, "INVALID_OTHER" }, \
+ { NFS_INO_DATA_INVAL_DEFER, "DATA_INVAL_DEFER" }, \
+ { NFS_INO_INVALID_BLOCKS, "INVALID_BLOCKS" }, \
{ NFS_INO_INVALID_XATTR, "INVALID_XATTR" })

TRACE_DEFINE_ENUM(NFS_INO_ADVISE_RDPLUS);
--
2.30.2