From patchwork Tue Feb 23 22:22:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 12100985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83F5DC433E0 for ; Tue, 23 Feb 2021 22:23:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CFCE614A7 for ; Tue, 23 Feb 2021 22:23:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232029AbhBWWX0 (ORCPT ); Tue, 23 Feb 2021 17:23:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231978AbhBWWXZ (ORCPT ); Tue, 23 Feb 2021 17:23:25 -0500 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40ED5C061574 for ; Tue, 23 Feb 2021 14:22:45 -0800 (PST) Received: by mail-lj1-x231.google.com with SMTP id q14so74829ljp.4 for ; Tue, 23 Feb 2021 14:22:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=d1yC+WVgL2olp+V5fEP8Dv6k11wypUl9Ht9IO+Mjf7Y=; b=r+tSLTR1p5RmvWixlpdthyOKPRD25w69Ua3/ulqNnMgIuC6badmLwLZ2jah5IfwMiq W6FW3PuxDSEafeZIyJOgEmjj94LSAsHHnklVUk7EaQbm5EF+V1+ZLgBuIADu1GnysTBN XpwWe5pU9ncSJ/2d3K7TU/IK828JyEaNwZ4FiP/TXHP5jqwWeqUXJfAiUNQ1xDrw5YQl N/okF9HomfKruqmtLw5URcAJ3YHGgsGkE16ZnYuVHF78vqOOk7pZs6JYIG/4GfMods6g qBR5gbLxa/FnNpzGGTqqN+HH/y2yYKHUb0L9JAOij2GTHZQsq0tRoiMyl+eNuJXAvseK PmIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=d1yC+WVgL2olp+V5fEP8Dv6k11wypUl9Ht9IO+Mjf7Y=; b=a2Q3XgExb3TcVTHDL2ylQRm8n8Ao6uM82cyumF2SBZAtMaNQoFhBEbd50YT0y1JJdQ iO0++rLUogcw1btWnV93fZwMU4PQ+TrYOEKbs3659F2oPVuwiMtnuG1YLAOsXU5eNio3 +UM7vczkssdy/vVWVTMxCmwBcyzY3ABJDTvNFPgg/p7/1TioQgs5VFTUnO4W8TeV9G7C U8TGHqDCdOV7At7nfI5WVGKfMDiJ9BGvPKLf/mavenYFPNT7kGrQ09jjaE8F23xA/ylv swIvYSKHGZA+mbHENBmUcHEUxyu35xUA607iyvUmYI+YwAyD2VO4WuqNc19EMt4oZvwD N+dg== X-Gm-Message-State: AOAM531UrXBqwfe4FO2WIOE5JvNBOvR4C9oUayeXWsSFG/7Z3PQN7FZy Up65SrzDwIao/mHsfTAbqA11xGVvmtZ5OppgBmvu7j9D7GC/PA== X-Google-Smtp-Source: ABdhPJzN3O/k2NY5ppB4kEDMhRssL2AijU3fx7zN2ajkhP99AwpI9nA/J9c/YY4rbo4qnALfaDVNX/gL+6+1XcT1QKQ= X-Received: by 2002:a2e:7e11:: with SMTP id z17mr1624611ljc.477.1614118963429; Tue, 23 Feb 2021 14:22:43 -0800 (PST) MIME-Version: 1.0 From: Steve French Date: Tue, 23 Feb 2021 16:22:32 -0600 Message-ID: Subject: [PATCH] convert revalidate of directories to using directory metadata cache timeout To: CIFS Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org nfs and cifs on Linux currently have a mount parameter "actimeo" to control metadata (attribute) caching but cifs does not have additional mount parameters to allow distinguishing between caching directory metadata (e.g. needed to revalidate paths) and that for files. Add new mount parameter "acdirmax" to allow caching metadata for directories more loosely than file data. NFS adjusts metadata caching from acdirmin to acdirmax (and another two mount parms for files) but to reduce complexity, it is safer to just introduce the one mount parm to allow caching directories longer (30 seconds vs. the 1 second default for file metadata) which is still more conservative than other Linux filesystems (e.g. NFS sets acdirmax to 60 seconds) Signed-off-by: Steve French Reviewed-by: Ronnie Sahlberg Reviewed-By: Tom Talpey From 79f731e14559be57d48647d22283b93600caf192 Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 23 Feb 2021 16:16:09 -0600 Subject: [PATCH 2/2] cifs: convert revalidate of directories to using directory metadata cache timeout 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 (actimeo is checked for files) Signed-off-by: Steve French --- fs/cifs/inode.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index a83b3a8ffaac..cfd31cc4520f 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -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) && -- 2.27.0