@@ -115,6 +115,9 @@ static int nfs4_do_check_delegation(struct inode *inode, fmode_t type,
115115 if (mark )
116116 nfs_mark_delegation_referenced (delegation );
117117 ret = 1 ;
118+ if ((flags & NFS_DELEGATION_FLAG_TIME ) &&
119+ !test_bit (NFS_DELEGATION_DELEGTIME , & delegation -> flags ))
120+ ret = 0 ;
118121 }
119122 rcu_read_unlock ();
120123 return ret ;
@@ -221,11 +224,12 @@ static int nfs_delegation_claim_opens(struct inode *inode,
221224 * @type: delegation type
222225 * @stateid: delegation stateid
223226 * @pagemod_limit: write delegation "space_limit"
227+ * @deleg_type: raw delegation type
224228 *
225229 */
226230void nfs_inode_reclaim_delegation (struct inode * inode , const struct cred * cred ,
227231 fmode_t type , const nfs4_stateid * stateid ,
228- unsigned long pagemod_limit )
232+ unsigned long pagemod_limit , u32 deleg_type )
229233{
230234 struct nfs_delegation * delegation ;
231235 const struct cred * oldcred = NULL ;
@@ -239,6 +243,14 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred,
239243 delegation -> pagemod_limit = pagemod_limit ;
240244 oldcred = delegation -> cred ;
241245 delegation -> cred = get_cred (cred );
246+ switch (deleg_type ) {
247+ case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG :
248+ case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG :
249+ set_bit (NFS_DELEGATION_DELEGTIME , & delegation -> flags );
250+ break ;
251+ default :
252+ clear_bit (NFS_DELEGATION_DELEGTIME , & delegation -> flags );
253+ }
242254 clear_bit (NFS_DELEGATION_NEED_RECLAIM , & delegation -> flags );
243255 if (test_and_clear_bit (NFS_DELEGATION_REVOKED ,
244256 & delegation -> flags ))
@@ -250,7 +262,7 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred,
250262 } else {
251263 rcu_read_unlock ();
252264 nfs_inode_set_delegation (inode , cred , type , stateid ,
253- pagemod_limit );
265+ pagemod_limit , deleg_type );
254266 }
255267}
256268
@@ -418,13 +430,13 @@ nfs_update_inplace_delegation(struct nfs_delegation *delegation,
418430 * @type: delegation type
419431 * @stateid: delegation stateid
420432 * @pagemod_limit: write delegation "space_limit"
433+ * @deleg_type: raw delegation type
421434 *
422435 * Returns zero on success, or a negative errno value.
423436 */
424437int nfs_inode_set_delegation (struct inode * inode , const struct cred * cred ,
425- fmode_t type ,
426- const nfs4_stateid * stateid ,
427- unsigned long pagemod_limit )
438+ fmode_t type , const nfs4_stateid * stateid ,
439+ unsigned long pagemod_limit , u32 deleg_type )
428440{
429441 struct nfs_server * server = NFS_SERVER (inode );
430442 struct nfs_client * clp = server -> nfs_client ;
@@ -444,6 +456,11 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,
444456 delegation -> cred = get_cred (cred );
445457 delegation -> inode = inode ;
446458 delegation -> flags = 1 <<NFS_DELEGATION_REFERENCED ;
459+ switch (deleg_type ) {
460+ case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG :
461+ case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG :
462+ delegation -> flags |= BIT (NFS_DELEGATION_DELEGTIME );
463+ }
447464 delegation -> test_gen = 0 ;
448465 spin_lock_init (& delegation -> lock );
449466
@@ -508,6 +525,11 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,
508525 atomic_long_inc (& nfs_active_delegations );
509526
510527 trace_nfs4_set_delegation (inode , type );
528+
529+ /* If we hold writebacks and have delegated mtime then update */
530+ if (deleg_type == NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG &&
531+ nfs_have_writebacks (inode ))
532+ nfs_update_delegated_mtime (inode );
511533out :
512534 spin_unlock (& clp -> cl_lock );
513535 if (delegation != NULL )
0 commit comments