cifs: convert revalidate of directories to using directory metadata cache timeout
authorSteve French <stfrench@microsoft.com>
Tue, 23 Feb 2021 22:16:09 +0000 (16:16 -0600)
committerSteve French <stfrench@microsoft.com>
Thu, 25 Feb 2021 17:47:46 +0000 (11:47 -0600)
The new optional mount parm, "acdirmax" allows caching the metadata
for a directory longer than file metadata, which can be very helpful
for performance.  Convert cifs_inode_needs_reval to check acdirmax
for revalidating directory metadata.

Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed-By: Tom Talpey <tom@talpey.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/inode.c

index a83b3a8ffaacca690838f66fe4048efe89caf6db..cfd31cc4520f9161c36afb25cc2857510223af75 100644 (file)
@@ -2198,12 +2198,23 @@ cifs_inode_needs_reval(struct inode *inode)
        if (!lookupCacheEnabled)
                return true;
 
-       if (!cifs_sb->ctx->actimeo)
-               return true;
-
-       if (!time_in_range(jiffies, cifs_i->time,
-                               cifs_i->time + cifs_sb->ctx->actimeo))
-               return true;
+       /*
+        * depending on inode type, check if attribute caching disabled for
+        * files or directories
+        */
+       if (S_ISDIR(inode->i_mode)) {
+               if (!cifs_sb->ctx->acdirmax)
+                       return true;
+               if (!time_in_range(jiffies, cifs_i->time,
+                                  cifs_i->time + cifs_sb->ctx->acdirmax))
+                       return true;
+       } else { /* file */
+               if (!cifs_sb->ctx->actimeo)
+                       return true;
+               if (!time_in_range(jiffies, cifs_i->time,
+                                  cifs_i->time + cifs_sb->ctx->actimeo))
+                       return true;
+       }
 
        /* hardlinked files w/ noserverino get "special" treatment */
        if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&