summaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfsfh.h
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2020-11-30 17:46:14 -0500
committerChuck Lever <chuck.lever@oracle.com>2020-12-09 09:39:37 -0500
commit70b87f77294d16d3e567056ba4c9ee2b091a5b50 (patch)
tree557e788075d69a9eb9248a8cc6aeb3486dd5c348 /fs/nfsd/nfsfh.h
parent4a9d81caf841cd2c0ae36abec9c2963bf21d0284 (diff)
downloadlinux-70b87f77294d16d3e567056ba4c9ee2b091a5b50.tar.bz2
nfsd: only call inode_query_iversion in the I_VERSION case
inode_query_iversion() can modify i_version. Depending on the exported filesystem, that may not be safe. For example, if you're re-exporting NFS, NFS stores the server's change attribute in i_version and does not expect it to be modified locally. This has been observed causing unnecessary cache invalidations. The way a filesystem indicates that it's OK to call inode_query_iverson() is by setting SB_I_VERSION. So, move the I_VERSION check out of encode_change(), where it's used only in GETATTR responses, to nfsd4_change_attribute(), which is also called for pre- and post- operation attributes. (Note we could also pull the NFSEXP_V4ROOT case into nfsd4_change_attribute() as well. That would actually be a no-op, since pre/post attrs are only used for metadata-modifying operations, and V4ROOT exports are read-only. But we might make the change in the future just for simplicity.) Reported-by: Daire Byrne <daire@dneg.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/nfsd/nfsfh.h')
-rw-r--r--fs/nfsd/nfsfh.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h
index 56cfbc361561..39d764b129fa 100644
--- a/fs/nfsd/nfsfh.h
+++ b/fs/nfsd/nfsfh.h
@@ -261,10 +261,16 @@ static inline u64 nfsd4_change_attribute(struct kstat *stat,
{
u64 chattr;
- chattr = stat->ctime.tv_sec;
- chattr <<= 30;
- chattr += stat->ctime.tv_nsec;
- chattr += inode_query_iversion(inode);
+ if (IS_I_VERSION(inode)) {
+ chattr = stat->ctime.tv_sec;
+ chattr <<= 30;
+ chattr += stat->ctime.tv_nsec;
+ chattr += inode_query_iversion(inode);
+ } else {
+ chattr = stat->ctime.tv_sec;
+ chattr <<= 32;
+ chattr += stat->ctime.tv_nsec;
+ }
return chattr;
}