From patchwork Tue Oct 24 04:32:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 13433903 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 49E53C25B47 for ; Tue, 24 Oct 2023 04:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbjJXEck (ORCPT ); Tue, 24 Oct 2023 00:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbjJXEcj (ORCPT ); Tue, 24 Oct 2023 00:32:39 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 421CB128; Mon, 23 Oct 2023 21:32:35 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-507a3b8b113so6060449e87.0; Mon, 23 Oct 2023 21:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698121953; x=1698726753; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=wJ/+y2X3I+YhjHcxxUlCPRXGEsfyDra299a0h7CvvOk=; b=lOQN71gmbRsV7moo4WeJrAEsuGwcke5oQfGgyS33WcxzJwV6NUraSxV0aEv1EnPDtH FvdqDQsZKeI2kxpty1jbYjXQUGCQB8w7jn/P3TDV0/aI4LdJx5Jolpo2gFo6UeENbaI4 kdiHm8QfBaajN3bkilfxv9tfKyVl3DPoNqUl8Xm3Ul1EPfRCC5xuMR2yjcLxlsFS3Je9 Ti6A8QTysD6AsFBeZgRemkxV5DsFoeeqsWsUn+wZJx/jxD6zCt342aNWFPX90tnsfj7e km763VBQOT9tePhpzl42Psgd1zJPOWSR4G2kYQVv500W13vX4Q4cV9z/D/TzEKTtg8yp n8lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698121953; x=1698726753; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wJ/+y2X3I+YhjHcxxUlCPRXGEsfyDra299a0h7CvvOk=; b=MBq8QSMVgGE/5uqTAMbCmdK70Gwr0ot+92x2dWQyyEktYF+JwHjnkeEn06cfjCy69u MBOp0wK+hxOum6xOkqGStPx+ZPMUBffmN5/y3XliriHNyHgNToNsPp0XMtDGxVu9RB1N XL9zQcocK3iYgo1yMypTbgAIqW5nLU8EClcMOdnkilFglgR0LKuiS3zXYmgCkaYxm1+/ PV6J0j69YLS2ZWS/s63DPq0MC7teoH9v8kq7nsIA+0I6eW4sbAG3E3kZo9R5cVuapLTw OY9TbewUdqHprTJEw3w0HsF4S8TVGqCJ7VanQ6h6CXCWhCkydvYQWUgn+U6wtnGkuXB2 sqTQ== X-Gm-Message-State: AOJu0YyPDPMGvoRdbnPeMnoTMlcXnJrymO50/lxHUkDC/PVbtAi0PSBY nKeqYtRopx3a9oJOPXewfSW12fdQlF472GvZk3kJazzljp64AA== X-Google-Smtp-Source: AGHT+IFwgPcK/8xhshATNpES8UIG2iUhvvVpaG2q+BkWi50nmDSjS+zy+LZYRhQKIfvTPsY9QMr4vl5Pe1dJRwVZVtQ= X-Received: by 2002:a19:5211:0:b0:501:c406:c296 with SMTP id m17-20020a195211000000b00501c406c296mr7249112lfb.31.1698121952801; Mon, 23 Oct 2023 21:32:32 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Mon, 23 Oct 2023 23:32:21 -0500 Message-ID: Subject: Some additional cifs patches for 6.5 stable to address issue brought up by kernel regression tracker To: Stable Cc: Paulo Alcantara , ronnie sahlberg , Linux Regressions , "Dr. Bernd Feige" , CIFS Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org There were a set of issues brought up in 6.5 by the introduction of the "laundromat" (which cleans up directory leases). After discussion and testing with Paulo, Bernd Feige and others, we request that the following set also be included to address these problems. They are all in mainline (added in 6.6) and the patches (from mainline since they apply cleanly) are also attached. 238b351d0935 ("smb3: allow controlling length of time directory entries are cached with dir leases") 6a50d71d0fff ("smb3: allow controlling maximum number of cached directories") 2da338ff752a ("smb3: do not start laundromat thread when dir leases disabled") 3b8bb3171571 ("smb: client: do not start laundromat thread on nohandlecache") e95f3f744650 ("smb: client: make laundromat a delayed worker") 81ba10959970 ("smb: client: prevent new fids from being removed by laundromat") From 238b351d0935df568ecb3dc5aef25971778f0f7c Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 30 Aug 2023 22:48:41 -0500 Subject: [PATCH 29/50] 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/dir_cache_timeout or to disable caching directory contents: echo 0 > /sys/module/cifs/parameters/dir_cache_timeout Reviewed-by: Bharath SM Signed-off-by: Steve French --- fs/smb/client/cached_dir.c | 4 ++-- fs/smb/client/cifsfs.c | 10 ++++++++++ fs/smb/client/cifsglob.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index 2d5e9a9d5b8b..9d84c4a7bd0c 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -145,7 +145,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, const char *npath; if (tcon == NULL || tcon->cfids == NULL || tcon->nohandlecache || - is_smb1_server(tcon->ses->server)) + is_smb1_server(tcon->ses->server) || (dir_cache_timeout == 0)) return -EOPNOTSUPP; ses = tcon->ses; @@ -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 * dir_cache_timeout)) { 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 73c44e097a69..52612bb52bd7 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 dir_cache_timeout = 30; +module_param(dir_cache_timeout, uint, 0644); +MODULE_PARM_DESC(dir_cache_timeout, "Number of seconds to cache directory contents for which we have a lease. Default: 30 " + "Range: 1 to 65000 seconds, 0 to disable caching dir contents"); #ifdef CONFIG_CIFS_STATS2 unsigned int slow_rsp_threshold = 1; module_param(slow_rsp_threshold, uint, 0644); @@ -1679,6 +1683,12 @@ init_cifs(void) CIFS_MAX_REQ); } + /* Limit max to about 18 hours, and setting to zero disables directory entry caching */ + if (dir_cache_timeout > 65000) { + dir_cache_timeout = 65000; + cifs_dbg(VFS, "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..501426ee39e7 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 dir_cache_timeout; /* 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.39.2