@@ -195,6 +195,7 @@ void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
195195 if (!(flags & NFS_INO_REVAL_FORCED ))
196196 flags &= ~(NFS_INO_INVALID_MODE |
197197 NFS_INO_INVALID_OTHER |
198+ NFS_INO_INVALID_BTIME |
198199 NFS_INO_INVALID_XATTR );
199200 flags &= ~(NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_SIZE );
200201 }
@@ -519,6 +520,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
519520 memset (& inode -> i_atime , 0 , sizeof (inode -> i_atime ));
520521 memset (& inode -> i_mtime , 0 , sizeof (inode -> i_mtime ));
521522 inode_set_ctime (inode , 0 , 0 );
523+ memset (& nfsi -> btime , 0 , sizeof (nfsi -> btime ));
522524 inode_set_iversion_raw (inode , 0 );
523525 inode -> i_size = 0 ;
524526 clear_nlink (inode );
@@ -542,6 +544,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
542544 inode_set_ctime_to_ts (inode , fattr -> ctime );
543545 else if (fattr_supported & NFS_ATTR_FATTR_CTIME )
544546 nfs_set_cache_invalid (inode , NFS_INO_INVALID_CTIME );
547+ if (fattr -> valid & NFS_ATTR_FATTR_BTIME )
548+ nfsi -> btime = fattr -> btime ;
549+ else if (fattr_supported & NFS_ATTR_FATTR_BTIME )
550+ nfs_set_cache_invalid (inode , NFS_INO_INVALID_BTIME );
545551 if (fattr -> valid & NFS_ATTR_FATTR_CHANGE )
546552 inode_set_iversion_raw (inode , fattr -> change_attr );
547553 else
@@ -885,6 +891,7 @@ static void nfs_readdirplus_parent_cache_hit(struct dentry *dentry)
885891
886892static u32 nfs_get_valid_attrmask (struct inode * inode )
887893{
894+ u64 fattr_valid = NFS_SERVER (inode )-> fattr_valid ;
888895 unsigned long cache_validity = READ_ONCE (NFS_I (inode )-> cache_validity );
889896 u32 reply_mask = STATX_INO | STATX_TYPE ;
890897
@@ -904,6 +911,9 @@ static u32 nfs_get_valid_attrmask(struct inode *inode)
904911 reply_mask |= STATX_UID | STATX_GID ;
905912 if (!(cache_validity & NFS_INO_INVALID_BLOCKS ))
906913 reply_mask |= STATX_BLOCKS ;
914+ if (!(cache_validity & NFS_INO_INVALID_BTIME ) &&
915+ (fattr_valid & NFS_ATTR_FATTR_BTIME ))
916+ reply_mask |= STATX_BTIME ;
907917 if (!(cache_validity & NFS_INO_INVALID_CHANGE ))
908918 reply_mask |= STATX_CHANGE_COOKIE ;
909919 return reply_mask ;
@@ -914,6 +924,7 @@ int nfs_getattr(struct mnt_idmap *idmap, const struct path *path,
914924{
915925 struct inode * inode = d_inode (path -> dentry );
916926 struct nfs_server * server = NFS_SERVER (inode );
927+ u64 fattr_valid = server -> fattr_valid ;
917928 unsigned long cache_validity ;
918929 int err = 0 ;
919930 bool force_sync = query_flags & AT_STATX_FORCE_SYNC ;
@@ -924,9 +935,12 @@ int nfs_getattr(struct mnt_idmap *idmap, const struct path *path,
924935
925936 request_mask &= STATX_TYPE | STATX_MODE | STATX_NLINK | STATX_UID |
926937 STATX_GID | STATX_ATIME | STATX_MTIME | STATX_CTIME |
927- STATX_INO | STATX_SIZE | STATX_BLOCKS |
938+ STATX_INO | STATX_SIZE | STATX_BLOCKS | STATX_BTIME |
928939 STATX_CHANGE_COOKIE ;
929940
941+ if (!(fattr_valid & NFS_ATTR_FATTR_BTIME ))
942+ request_mask &= ~STATX_BTIME ;
943+
930944 if ((query_flags & AT_STATX_DONT_SYNC ) && !force_sync ) {
931945 if (readdirplus_enabled )
932946 nfs_readdirplus_parent_cache_hit (path -> dentry );
@@ -958,7 +972,7 @@ int nfs_getattr(struct mnt_idmap *idmap, const struct path *path,
958972 /* Is the user requesting attributes that might need revalidation? */
959973 if (!(request_mask & (STATX_MODE |STATX_NLINK |STATX_ATIME |STATX_CTIME |
960974 STATX_MTIME |STATX_UID |STATX_GID |
961- STATX_SIZE |STATX_BLOCKS |
975+ STATX_SIZE |STATX_BLOCKS |STATX_BTIME |
962976 STATX_CHANGE_COOKIE )))
963977 goto out_no_revalidate ;
964978
@@ -982,6 +996,8 @@ int nfs_getattr(struct mnt_idmap *idmap, const struct path *path,
982996 do_update |= cache_validity & NFS_INO_INVALID_OTHER ;
983997 if (request_mask & STATX_BLOCKS )
984998 do_update |= cache_validity & NFS_INO_INVALID_BLOCKS ;
999+ if (request_mask & STATX_BTIME )
1000+ do_update |= cache_validity & NFS_INO_INVALID_BTIME ;
9851001
9861002 if (do_update ) {
9871003 if (readdirplus_enabled )
@@ -1003,6 +1019,7 @@ int nfs_getattr(struct mnt_idmap *idmap, const struct path *path,
10031019 stat -> attributes |= STATX_ATTR_CHANGE_MONOTONIC ;
10041020 if (S_ISDIR (inode -> i_mode ))
10051021 stat -> blksize = NFS_SERVER (inode )-> dtsize ;
1022+ stat -> btime = NFS_I (inode )-> btime ;
10061023out :
10071024 trace_nfs_getattr_exit (inode , err );
10081025 return err ;
@@ -1894,7 +1911,7 @@ static int nfs_inode_finish_partial_attr_update(const struct nfs_fattr *fattr,
18941911 NFS_INO_INVALID_ATIME | NFS_INO_INVALID_CTIME |
18951912 NFS_INO_INVALID_MTIME | NFS_INO_INVALID_SIZE |
18961913 NFS_INO_INVALID_BLOCKS | NFS_INO_INVALID_OTHER |
1897- NFS_INO_INVALID_NLINK ;
1914+ NFS_INO_INVALID_NLINK | NFS_INO_INVALID_BTIME ;
18981915 unsigned long cache_validity = NFS_I (inode )-> cache_validity ;
18991916 enum nfs4_change_attr_type ctype = NFS_SERVER (inode )-> change_attr_type ;
19001917
@@ -2160,7 +2177,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
21602177 bool attr_changed = false;
21612178 bool have_delegation ;
21622179
2163- dfprintk (VFS , "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%x )\n" ,
2180+ dfprintk (VFS , "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%llx )\n" ,
21642181 __func__ , inode -> i_sb -> s_id , inode -> i_ino ,
21652182 nfs_display_fhandle_hash (NFS_FH (inode )),
21662183 atomic_read (& inode -> i_count ), fattr -> valid );
@@ -2255,7 +2272,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
22552272 | NFS_INO_INVALID_BLOCKS
22562273 | NFS_INO_INVALID_NLINK
22572274 | NFS_INO_INVALID_MODE
2258- | NFS_INO_INVALID_OTHER ;
2275+ | NFS_INO_INVALID_OTHER
2276+ | NFS_INO_INVALID_BTIME ;
22592277 if (S_ISDIR (inode -> i_mode ))
22602278 nfs_force_lookup_revalidate (inode );
22612279 attr_changed = true;
@@ -2289,6 +2307,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
22892307 nfsi -> cache_validity |=
22902308 save_cache_validity & NFS_INO_INVALID_CTIME ;
22912309
2310+ if (fattr -> valid & NFS_ATTR_FATTR_BTIME )
2311+ nfsi -> btime = fattr -> btime ;
2312+ else if (fattr_supported & NFS_ATTR_FATTR_BTIME )
2313+ nfsi -> cache_validity |=
2314+ save_cache_validity & NFS_INO_INVALID_BTIME ;
2315+
22922316 /* Check if our cached file size is stale */
22932317 if (fattr -> valid & NFS_ATTR_FATTR_SIZE ) {
22942318 new_isize = nfs_size_to_loff_t (fattr -> size );
0 commit comments