2021-01-19 19:42:25

by J. Bruce Fields

[permalink] [raw]
Subject: [PATCH 0/3] NFS change attribute patches

From: "J. Bruce Fields" <[email protected]>

These patches move a little more of the change attribute logic into the
filesystems. They should let us skip a few unnecessary stats, and use
the source filesystem's change attribute in the NFS reexport case.

Do this look reasonable to everyone else?

J. Bruce Fields (3):
nfs: use change attribute for NFS re-exports
nfsd: move change attribute generation to filesystem
nfsd: skip some unnecessary stats in the v4 case

fs/btrfs/export.c | 2 ++
fs/ext4/super.c | 9 +++++++++
fs/nfs/export.c | 18 ++++++++++++++++++
fs/nfsd/nfs3xdr.c | 37 ++++++++++++++++++++-----------------
fs/nfsd/nfsfh.h | 28 ++++++----------------------
fs/xfs/xfs_export.c | 10 ++++++++++
include/linux/exportfs.h | 1 +
include/linux/iversion.h | 26 ++++++++++++++++++++++++++
8 files changed, 92 insertions(+), 39 deletions(-)

--
2.29.2


2021-01-19 19:43:13

by J. Bruce Fields

[permalink] [raw]
Subject: [PATCH 3/3] nfsd: skip some unnecessary stats in the v4 case

From: "J. Bruce Fields" <[email protected]>

In the typical case of v4 and an i_version-supporting filesystem, we can
skip a stat which is only required to fake up a change attribute from
ctime.

Signed-off-by: J. Bruce Fields <[email protected]>
---
fs/nfsd/nfs3xdr.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 821db21ba072..e22d5d209d08 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -260,24 +260,25 @@ void fill_pre_wcc(struct svc_fh *fhp)
struct inode *inode;
struct kstat stat;
bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE);
- __be32 err;

if (fhp->fh_no_wcc || fhp->fh_pre_saved)
return;
inode = d_inode(fhp->fh_dentry);
- err = fh_getattr(fhp, &stat);
- if (err) {
- /* Grab the times from inode anyway */
- stat.mtime = inode->i_mtime;
- stat.ctime = inode->i_ctime;
- stat.size = inode->i_size;
+ if (!v4 || !inode->i_sb->s_export_op->fetch_iversion) {
+ __be32 err = fh_getattr(fhp, &stat);
+ if (err) {
+ /* Grab the times from inode anyway */
+ stat.mtime = inode->i_mtime;
+ stat.ctime = inode->i_ctime;
+ stat.size = inode->i_size;
+ }
+ fhp->fh_pre_mtime = stat.mtime;
+ fhp->fh_pre_ctime = stat.ctime;
+ fhp->fh_pre_size = stat.size;
}
if (v4)
fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode);

- fhp->fh_pre_mtime = stat.mtime;
- fhp->fh_pre_ctime = stat.ctime;
- fhp->fh_pre_size = stat.size;
fhp->fh_pre_saved = true;
}

@@ -288,7 +289,6 @@ void fill_post_wcc(struct svc_fh *fhp)
{
bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE);
struct inode *inode = d_inode(fhp->fh_dentry);
- __be32 err;

if (fhp->fh_no_wcc)
return;
@@ -296,12 +296,15 @@ void fill_post_wcc(struct svc_fh *fhp)
if (fhp->fh_post_saved)
printk("nfsd: inode locked twice during operation.\n");

- err = fh_getattr(fhp, &fhp->fh_post_attr);
- if (err) {
- fhp->fh_post_saved = false;
- fhp->fh_post_attr.ctime = inode->i_ctime;
- } else
- fhp->fh_post_saved = true;
+ fhp->fh_post_saved = true;
+
+ if (!v4 || !inode->i_sb->s_export_op->fetch_iversion) {
+ __be32 err = fh_getattr(fhp, &fhp->fh_post_attr);
+ if (err) {
+ fhp->fh_post_saved = false;
+ fhp->fh_post_attr.ctime = inode->i_ctime;
+ }
+ }
if (v4)
fhp->fh_post_change =
nfsd4_change_attribute(&fhp->fh_post_attr, inode);
--
2.29.2

2021-01-22 17:42:17

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 0/3] NFS change attribute patches

So I'm fine with 1 and 3, but I'd rather skip patch 2.