nfsd: minor nfsd4_change_attribute cleanup

Minor cleanup, no change in behavior.

Also pull out a common helper that'll be useful elsewhere.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
J. Bruce Fields 2020-11-30 17:46:16 -05:00 committed by Chuck Lever
parent b2140338d8
commit 4b03d99794
2 changed files with 18 additions and 8 deletions

View File

@ -259,19 +259,16 @@ fh_clear_wcc(struct svc_fh *fhp)
static inline u64 nfsd4_change_attribute(struct kstat *stat, static inline u64 nfsd4_change_attribute(struct kstat *stat,
struct inode *inode) struct inode *inode)
{ {
u64 chattr;
if (IS_I_VERSION(inode)) { if (IS_I_VERSION(inode)) {
u64 chattr;
chattr = stat->ctime.tv_sec; chattr = stat->ctime.tv_sec;
chattr <<= 30; chattr <<= 30;
chattr += stat->ctime.tv_nsec; chattr += stat->ctime.tv_nsec;
chattr += inode_query_iversion(inode); chattr += inode_query_iversion(inode);
} else { return chattr;
chattr = stat->ctime.tv_sec; } else
chattr <<= 32; return time_to_chattr(&stat->ctime);
chattr += stat->ctime.tv_nsec;
}
return chattr;
} }
extern void fill_pre_wcc(struct svc_fh *fhp); extern void fill_pre_wcc(struct svc_fh *fhp);

View File

@ -328,6 +328,19 @@ inode_query_iversion(struct inode *inode)
return cur >> I_VERSION_QUERIED_SHIFT; return cur >> I_VERSION_QUERIED_SHIFT;
} }
/*
* For filesystems without any sort of change attribute, the best we can
* do is fake one up from the ctime:
*/
static inline u64 time_to_chattr(struct timespec64 *t)
{
u64 chattr = t->tv_sec;
chattr <<= 32;
chattr += t->tv_nsec;
return chattr;
}
/** /**
* inode_eq_iversion_raw - check whether the raw i_version counter has changed * inode_eq_iversion_raw - check whether the raw i_version counter has changed
* @inode: inode to check * @inode: inode to check