From patchwork Sun Aug 27 05:12:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 13366846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16641C83F01 for ; Sun, 27 Aug 2023 05:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229379AbjH0FMo (ORCPT ); Sun, 27 Aug 2023 01:12:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjH0FMn (ORCPT ); Sun, 27 Aug 2023 01:12:43 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3201BF for ; Sat, 26 Aug 2023 22:12:39 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2bcd7a207f7so31800771fa.3 for ; Sat, 26 Aug 2023 22:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693113158; x=1693717958; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=te0tCmhyJvqllLKSsV9ph8rZEfpv5ZujuK8WkWy2Hkc=; b=lDL9jCDI69S82u9tcdDVm8CR1BZt+tWlNDtw7GtE5taJt7qQopuIbdEZfals7Faz9K AvLzjuRdqczS5fmUteezxKlj1q4LVReBWeNuPKB9l9bYAJR2h8NUvUv8IF38hZKI+3Er up4z2hkPxOZu/bmx1g5fkGi5G0iTFMLfeL2G/2O0n3spifOsGxzUhj42VqoG/UlJw5ly KrfvQKFL/OmXsIgcpcf6OThBv3IC/E1HatqicepcpLP/S3ZmuDK1cEtnJEBV5G6hlXUj 8V0aJKriL+XYdsk9OXX+JaFGPxeMaE8hInYFgu0RDg0zfYNC13rBuKp5BwxRn3wba20T j0GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693113158; x=1693717958; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=te0tCmhyJvqllLKSsV9ph8rZEfpv5ZujuK8WkWy2Hkc=; b=TKFdDHDNtMRP0sDgQ0UrdWJUDuyRMcfCHolKp7SP15GGO+iqaH8HpNildvS6WsXgGz GgNKnaAyKLiwqANM5gR34KajfgMtP08JWqE/b8JOv9mm/nekN2gJmkxICdkdPOWHkzpe wVDko+hnlpAgtwpEFnEci7uV8L811Mwk6var/4/ml0j0qrImtofCJyDQq66iFXiVsDXr vHpmz9drvn5B8O2Ps/S67EJwwOkfC0rOl49P5esF2UaU39lngVXS4hLGBb8lTKa0OW9Y GK6Jm5aqsZc4TvuvyCG7AUGp1Ewcx3eoxNcwkiG2RpY85svMukeB7IjWktVrBERhHmNw EMlw== X-Gm-Message-State: AOJu0YwIFX2IAO4g5PuidIDHLlG9bt+Myz1TJZZUaWEHdfbLE0hDVezS ABPwqPFEBtBlMzD70yBMbT9KxBd5h3ijpP92xMzYErCnzzxiKxf1 X-Google-Smtp-Source: AGHT+IHr8443w3l530CKAPvLY20946rraKFm00a7fPf3AmTFLwX2usx2e82PGITEytxd2xtNSabZeuJz0qpqxzeg6eI= X-Received: by 2002:a2e:88cb:0:b0:2bc:be3c:9080 with SMTP id a11-20020a2e88cb000000b002bcbe3c9080mr13915988ljk.27.1693113157495; Sat, 26 Aug 2023 22:12:37 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Sun, 27 Aug 2023 00:12:26 -0500 Message-ID: Subject: [PATCH][SMB3] allow controlling length of time directory entries are cached with dir leases To: CIFS Cc: ronnie sahlberg , Shyam Prasad N , Bharath S M Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Currently with directory leases we cache directory contents for a fixed period of time (default 30 seconds) but for many workloads this is too short. Allow configuring the maximum amount of time directory entries are cached when a directory lease is held on that directory (and set default timeout to 60 seconds). Add module load parm "max_dir_cache" For example to set the timeout to 10 minutes you would do: echo 600 > /sys/module/cifs/parameters/max_dir_cache Signed-off-by: Steve French --- fs/smb/client/cached_dir.c | 2 +- fs/smb/client/cifsfs.c | 12 ++++++++++++ fs/smb/client/cifsglob.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) extern atomic_t mid_count; From c5143ccd59b38821f5c208d835b8b7f8616ca631 Mon Sep 17 00:00:00 2001 From: Steve French Date: Sat, 26 Aug 2023 23:59:25 -0500 Subject: [PATCH] smb3: allow controlling length of time directory entries are cached with dir leases Currently with directory leases we cache directory contents for a fixed period of time (default 30 seconds) but for many workloads this is too short. Allow configuring the maximum amount of time directory entries are cached when a directory lease is held on that directory. Add module load parm "max_dir_cache" For example to set the timeout to 10 minutes you would do: echo 600 > /sys/module/cifs/parameters/max_dir_cache Signed-off-by: Steve French --- fs/smb/client/cached_dir.c | 2 +- fs/smb/client/cifsfs.c | 12 ++++++++++++ fs/smb/client/cifsglob.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index 2d5e9a9d5b8b..e48a902efd52 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -582,7 +582,7 @@ cifs_cfids_laundromat_thread(void *p) return 0; spin_lock(&cfids->cfid_list_lock); list_for_each_entry_safe(cfid, q, &cfids->entries, entry) { - if (time_after(jiffies, cfid->time + HZ * 30)) { + if (time_after(jiffies, cfid->time + HZ * max_dir_cache)) { list_del(&cfid->entry); list_add(&cfid->entry, &entry); cfids->num_entries--; diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index d49fd2bf71b0..7a89718d2a59 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -117,6 +117,10 @@ module_param(cifs_max_pending, uint, 0444); MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server for " "CIFS/SMB1 dialect (N/A for SMB3) " "Default: 32767 Range: 2 to 32767."); +unsigned int max_dir_cache = 60; +module_param(max_dir_cache, uint, 0644); +MODULE_PARM_DESC(max_dir_cache, "Number of seconds to cache directory contents for which we have a lease. Default: 60 " + "Range: 1 to 65000 seconds"); #ifdef CONFIG_CIFS_STATS2 unsigned int slow_rsp_threshold = 1; module_param(slow_rsp_threshold, uint, 0644); @@ -1679,6 +1683,14 @@ init_cifs(void) CIFS_MAX_REQ); } + if (max_dir_cache < 1) { + max_dir_cache = 1; + cifs_dbg(VFS, "max_dir_cache timeout set to min of 1 second\n"); + } else if (max_dir_cache > 65000) { + max_dir_cache = 65000; + cifs_dbg(VFS, "max_dir_cache timeout set to max of 65000 seconds\n"); + } + cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0); if (!cifsiod_wq) { rc = -ENOMEM; diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 259e231f8b4f..7aeeaa260cce 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -2016,6 +2016,7 @@ extern unsigned int CIFSMaxBufSize; /* max size not including hdr */ extern unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */ extern unsigned int cifs_min_small; /* min size of small buf pool */ extern unsigned int cifs_max_pending; /* MAX requests at once to server*/ +extern unsigned int max_dir_cache; /* max time for directory lease caching of dir */ extern bool disable_legacy_dialects; /* forbid vers=1.0 and vers=2.0 mounts */ extern atomic_t mid_count; -- 2.34.1