]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.15
authorSasha Levin <sashal@kernel.org>
Mon, 10 Apr 2023 12:34:53 +0000 (08:34 -0400)
committerSasha Levin <sashal@kernel.org>
Mon, 10 Apr 2023 12:34:53 +0000 (08:34 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.15/cifs-sanitize-paths-in-cifs_update_super_prepath.patch [new file with mode: 0644]
queue-5.15/iio-adc-ad7791-fix-irq-flags.patch [new file with mode: 0644]
queue-5.15/perf-core-fix-the-same-task-check-in-perf_event_set_.patch [new file with mode: 0644]
queue-5.15/scsi-iscsi_tcp-check-that-sock-is-valid-before-iscsi.patch [new file with mode: 0644]
queue-5.15/scsi-qla2xxx-fix-memory-leak-in-qla2x00_probe_one.patch [new file with mode: 0644]
queue-5.15/series
queue-5.15/smb3-allow-deferred-close-timeout-to-be-configurable.patch [new file with mode: 0644]
queue-5.15/smb3-lower-default-deferred-close-timeout-to-address.patch [new file with mode: 0644]

diff --git a/queue-5.15/cifs-sanitize-paths-in-cifs_update_super_prepath.patch b/queue-5.15/cifs-sanitize-paths-in-cifs_update_super_prepath.patch
new file mode 100644 (file)
index 0000000..d526b07
--- /dev/null
@@ -0,0 +1,98 @@
+From 3d9cd1556904fa928c22ec74071c34d594c127af Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 5 Apr 2023 10:16:48 -0300
+Subject: cifs: sanitize paths in cifs_update_super_prepath.
+
+From: Thiago Rafael Becker <tbecker@redhat.com>
+
+[ Upstream commit d19342c6609b67f2ba83b9eccca2777e3687f625 ]
+
+After a server reboot, clients are failing to move files with ENOENT.
+This is caused by DFS referrals containing multiple separators, which
+the server move call doesn't recognize.
+
+v1: Initial patch.
+v2: Move prototype to header.
+
+Link: https://bugzilla.redhat.com/show_bug.cgi?id=2182472
+Fixes: a31080899d5f ("cifs: sanitize multiple delimiters in prepath")
+Actually-Fixes: 24e0a1eff9e2 ("cifs: switch to new mount api")
+Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
+Signed-off-by: Thiago Rafael Becker <tbecker@redhat.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/fs_context.c | 13 +++++++------
+ fs/cifs/fs_context.h |  3 +++
+ fs/cifs/misc.c       |  2 +-
+ 3 files changed, 11 insertions(+), 7 deletions(-)
+
+diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
+index 85ad0c9e2f8b5..8455db6a26f5a 100644
+--- a/fs/cifs/fs_context.c
++++ b/fs/cifs/fs_context.c
+@@ -437,13 +437,14 @@ int smb3_parse_opt(const char *options, const char *key, char **val)
+  * but there are some bugs that prevent rename from working if there are
+  * multiple delimiters.
+  *
+- * Returns a sanitized duplicate of @path. The caller is responsible for
+- * cleaning up the original.
++ * Returns a sanitized duplicate of @path. @gfp indicates the GFP_* flags
++ * for kstrdup.
++ * The caller is responsible for freeing the original.
+  */
+ #define IS_DELIM(c) ((c) == '/' || (c) == '\\')
+-static char *sanitize_path(char *path)
++char *cifs_sanitize_prepath(char *prepath, gfp_t gfp)
+ {
+-      char *cursor1 = path, *cursor2 = path;
++      char *cursor1 = prepath, *cursor2 = prepath;
+       /* skip all prepended delimiters */
+       while (IS_DELIM(*cursor1))
+@@ -465,7 +466,7 @@ static char *sanitize_path(char *path)
+               cursor2--;
+       *(cursor2) = '\0';
+-      return kstrdup(path, GFP_KERNEL);
++      return kstrdup(prepath, gfp);
+ }
+ /*
+@@ -527,7 +528,7 @@ smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)
+       if (!*pos)
+               return 0;
+-      ctx->prepath = sanitize_path(pos);
++      ctx->prepath = cifs_sanitize_prepath(pos, GFP_KERNEL);
+       if (!ctx->prepath)
+               return -ENOMEM;
+diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
+index ad45256cf68e2..3cf8d6235162d 100644
+--- a/fs/cifs/fs_context.h
++++ b/fs/cifs/fs_context.h
+@@ -283,4 +283,7 @@ extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
+  */
+ #define SMB3_MAX_DCLOSETIMEO (1 << 30)
+ #define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
++
++extern char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
++
+ #endif
+diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
+index 3a90ee314ed73..300f5f382e43f 100644
+--- a/fs/cifs/misc.c
++++ b/fs/cifs/misc.c
+@@ -1301,7 +1301,7 @@ int cifs_update_super_prepath(struct cifs_sb_info *cifs_sb, char *prefix)
+       kfree(cifs_sb->prepath);
+       if (prefix && *prefix) {
+-              cifs_sb->prepath = kstrdup(prefix, GFP_ATOMIC);
++              cifs_sb->prepath = cifs_sanitize_prepath(prefix, GFP_ATOMIC);
+               if (!cifs_sb->prepath)
+                       return -ENOMEM;
+-- 
+2.39.2
+
diff --git a/queue-5.15/iio-adc-ad7791-fix-irq-flags.patch b/queue-5.15/iio-adc-ad7791-fix-irq-flags.patch
new file mode 100644 (file)
index 0000000..34a532e
--- /dev/null
@@ -0,0 +1,40 @@
+From 936dd8816e8bc43662f263715327983eff95bc29 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 20 Jan 2023 13:46:45 +0100
+Subject: iio: adc: ad7791: fix IRQ flags
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Nuno Sá <nuno.sa@analog.com>
+
+[ Upstream commit 0c6ef985a1fd8a74dcb5cad941ddcadd55cb8697 ]
+
+The interrupt is triggered on the falling edge rather than being a level
+low interrupt.
+
+Fixes: da4d3d6bb9f6 ("iio: adc: ad-sigma-delta: Allow custom IRQ flags")
+Signed-off-by: Nuno Sá <nuno.sa@analog.com>
+Link: https://lore.kernel.org/r/20230120124645.819910-1-nuno.sa@analog.com
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iio/adc/ad7791.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
+index cb579aa89f39c..f7d7bc1e44455 100644
+--- a/drivers/iio/adc/ad7791.c
++++ b/drivers/iio/adc/ad7791.c
+@@ -253,7 +253,7 @@ static const struct ad_sigma_delta_info ad7791_sigma_delta_info = {
+       .has_registers = true,
+       .addr_shift = 4,
+       .read_mask = BIT(3),
+-      .irq_flags = IRQF_TRIGGER_LOW,
++      .irq_flags = IRQF_TRIGGER_FALLING,
+ };
+ static int ad7791_read_raw(struct iio_dev *indio_dev,
+-- 
+2.39.2
+
diff --git a/queue-5.15/perf-core-fix-the-same-task-check-in-perf_event_set_.patch b/queue-5.15/perf-core-fix-the-same-task-check-in-perf_event_set_.patch
new file mode 100644 (file)
index 0000000..3705fe1
--- /dev/null
@@ -0,0 +1,73 @@
+From a6d7746502fbf97f7bf387fb9bd86b30542331c4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 22 Mar 2023 13:24:49 -0700
+Subject: perf/core: Fix the same task check in perf_event_set_output
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Kan Liang <kan.liang@linux.intel.com>
+
+[ Upstream commit 24d3ae2f37d8bc3c14b31d353c5d27baf582b6a6 ]
+
+The same task check in perf_event_set_output has some potential issues
+for some usages.
+
+For the current perf code, there is a problem if using of
+perf_event_open() to have multiple samples getting into the same mmap’d
+memory when they are both attached to the same process.
+https://lore.kernel.org/all/92645262-D319-4068-9C44-2409EF44888E@gmail.com/
+Because the event->ctx is not ready when the perf_event_set_output() is
+invoked in the perf_event_open().
+
+Besides the above issue, before the commit bd2756811766 ("perf: Rewrite
+core context handling"), perf record can errors out when sampling with
+a hardware event and a software event as below.
+ $ perf record -e cycles,dummy --per-thread ls
+ failed to mmap with 22 (Invalid argument)
+That's because that prior to the commit a hardware event and a software
+event are from different task context.
+
+The problem should be a long time issue since commit c3f00c70276d
+("perk: Separate find_get_context() from event initialization").
+
+The task struct is stored in the event->hw.target for each per-thread
+event. It is a more reliable way to determine whether two events are
+attached to the same task.
+
+The event->hw.target was also introduced several years ago by the
+commit 50f16a8bf9d7 ("perf: Remove type specific target pointers"). It
+can not only be used to fix the issue with the current code, but also
+back port to fix the issues with an older kernel.
+
+Note: The event->hw.target was introduced later than commit
+c3f00c70276d. The patch may cannot be applied between the commit
+c3f00c70276d and commit 50f16a8bf9d7. Anybody that wants to back-port
+this at that period may have to find other solutions.
+
+Fixes: c3f00c70276d ("perf: Separate find_get_context() from event initialization")
+Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Reviewed-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
+Link: https://lkml.kernel.org/r/20230322202449.512091-1-kan.liang@linux.intel.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/events/core.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kernel/events/core.c b/kernel/events/core.c
+index 2cdee62c3de73..dc57835e70966 100644
+--- a/kernel/events/core.c
++++ b/kernel/events/core.c
+@@ -12024,7 +12024,7 @@ perf_event_set_output(struct perf_event *event, struct perf_event *output_event)
+       /*
+        * If its not a per-cpu rb, it must be the same task.
+        */
+-      if (output_event->cpu == -1 && output_event->ctx != event->ctx)
++      if (output_event->cpu == -1 && output_event->hw.target != event->hw.target)
+               goto out;
+       /*
+-- 
+2.39.2
+
diff --git a/queue-5.15/scsi-iscsi_tcp-check-that-sock-is-valid-before-iscsi.patch b/queue-5.15/scsi-iscsi_tcp-check-that-sock-is-valid-before-iscsi.patch
new file mode 100644 (file)
index 0000000..09a9fbc
--- /dev/null
@@ -0,0 +1,48 @@
+From a0cee310c846df2888cf48c34943f44fb27fbde2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 29 Mar 2023 15:17:39 +0800
+Subject: scsi: iscsi_tcp: Check that sock is valid before iscsi_set_param()
+
+From: Zhong Jinghua <zhongjinghua@huawei.com>
+
+[ Upstream commit 48b19b79cfa37b1e50da3b5a8af529f994c08901 ]
+
+The validity of sock should be checked before assignment to avoid incorrect
+values. Commit 57569c37f0ad ("scsi: iscsi: iscsi_tcp: Fix null-ptr-deref
+while calling getpeername()") introduced this change which may lead to
+inconsistent values of tcp_sw_conn->sendpage and conn->datadgst_en.
+
+Fix the issue by moving the position of the assignment.
+
+Fixes: 57569c37f0ad ("scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()")
+Signed-off-by: Zhong Jinghua <zhongjinghua@huawei.com>
+Link: https://lore.kernel.org/r/20230329071739.2175268-1-zhongjinghua@huaweicloud.com
+Reviewed-by: Mike Christie <michael.christie@oracle.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/scsi/iscsi_tcp.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
+index 5943360041907..fe705b8bf4643 100644
+--- a/drivers/scsi/iscsi_tcp.c
++++ b/drivers/scsi/iscsi_tcp.c
+@@ -767,13 +767,12 @@ static int iscsi_sw_tcp_conn_set_param(struct iscsi_cls_conn *cls_conn,
+               iscsi_set_param(cls_conn, param, buf, buflen);
+               break;
+       case ISCSI_PARAM_DATADGST_EN:
+-              iscsi_set_param(cls_conn, param, buf, buflen);
+-
+               mutex_lock(&tcp_sw_conn->sock_lock);
+               if (!tcp_sw_conn->sock) {
+                       mutex_unlock(&tcp_sw_conn->sock_lock);
+                       return -ENOTCONN;
+               }
++              iscsi_set_param(cls_conn, param, buf, buflen);
+               tcp_sw_conn->sendpage = conn->datadgst_en ?
+                       sock_no_sendpage : tcp_sw_conn->sock->ops->sendpage;
+               mutex_unlock(&tcp_sw_conn->sock_lock);
+-- 
+2.39.2
+
diff --git a/queue-5.15/scsi-qla2xxx-fix-memory-leak-in-qla2x00_probe_one.patch b/queue-5.15/scsi-qla2xxx-fix-memory-leak-in-qla2x00_probe_one.patch
new file mode 100644 (file)
index 0000000..a96c4d6
--- /dev/null
@@ -0,0 +1,58 @@
+From 78be8b8671249f5553c832b0ccc950864fbbe38f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 25 Mar 2023 11:00:04 +0000
+Subject: scsi: qla2xxx: Fix memory leak in qla2x00_probe_one()
+
+From: Li Zetao <lizetao1@huawei.com>
+
+[ Upstream commit 85ade4010e13ef152ea925c74d94253db92e5428 ]
+
+There is a memory leak reported by kmemleak:
+
+  unreferenced object 0xffffc900003f0000 (size 12288):
+    comm "modprobe", pid 19117, jiffies 4299751452 (age 42490.264s)
+    hex dump (first 32 bytes):
+      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
+      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
+    backtrace:
+      [<00000000629261a8>] __vmalloc_node_range+0xe56/0x1110
+      [<0000000001906886>] __vmalloc_node+0xbd/0x150
+      [<000000005bb4dc34>] vmalloc+0x25/0x30
+      [<00000000a2dc1194>] qla2x00_create_host+0x7a0/0xe30 [qla2xxx]
+      [<0000000062b14b47>] qla2x00_probe_one+0x2eb8/0xd160 [qla2xxx]
+      [<00000000641ccc04>] local_pci_probe+0xeb/0x1a0
+
+The root cause is traced to an error-handling path in qla2x00_probe_one()
+when the adapter "base_vha" initialize failed. The fab_scan_rp "scan.l" is
+used to record the port information and it is allocated in
+qla2x00_create_host(). However, it is not released in the error handling
+path "probe_failed".
+
+Fix this by freeing the memory of "scan.l" when an error occurs in the
+adapter initialization process.
+
+Fixes: a4239945b8ad ("scsi: qla2xxx: Add switch command to simplify fabric discovery")
+Signed-off-by: Li Zetao <lizetao1@huawei.com>
+Link: https://lore.kernel.org/r/20230325110004.363898-1-lizetao1@huawei.com
+Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/scsi/qla2xxx/qla_os.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
+index 6063f48558081..2efe31327ed1e 100644
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -3573,6 +3573,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
+ probe_failed:
+       qla_enode_stop(base_vha);
+       qla_edb_stop(base_vha);
++      vfree(base_vha->scan.l);
+       if (base_vha->gnl.l) {
+               dma_free_coherent(&ha->pdev->dev, base_vha->gnl.size,
+                               base_vha->gnl.l, base_vha->gnl.ldma);
+-- 
+2.39.2
+
index ad887d3aee5a097342409467679da9cace5dd5b0..070a2888759f167dc60d6c2d0963943a6dae8d95 100644 (file)
@@ -52,3 +52,10 @@ kbuild-refactor-single-builds-of-.ko.patch
 clk-imx-imx8mp-add-shared-clk-gate-for-usb-suspend-c.patch
 usb-xhci-tegra-fix-sleep-in-atomic-call.patch
 xhci-also-avoid-the-xhci_zero_64b_regs-quirk-with-a-passthrough-iommu.patch
+iio-adc-ad7791-fix-irq-flags.patch
+scsi-qla2xxx-fix-memory-leak-in-qla2x00_probe_one.patch
+scsi-iscsi_tcp-check-that-sock-is-valid-before-iscsi.patch
+smb3-allow-deferred-close-timeout-to-be-configurable.patch
+smb3-lower-default-deferred-close-timeout-to-address.patch
+cifs-sanitize-paths-in-cifs_update_super_prepath.patch
+perf-core-fix-the-same-task-check-in-perf_event_set_.patch
diff --git a/queue-5.15/smb3-allow-deferred-close-timeout-to-be-configurable.patch b/queue-5.15/smb3-allow-deferred-close-timeout-to-be-configurable.patch
new file mode 100644 (file)
index 0000000..12f9449
--- /dev/null
@@ -0,0 +1,153 @@
+From 284d135258d33430c1fe3be17a20ba53cc5f65f1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 11 Aug 2022 00:53:00 -0500
+Subject: smb3: allow deferred close timeout to be configurable
+
+From: Steve French <stfrench@microsoft.com>
+
+[ Upstream commit 5efdd9122eff772eae2feae9f0fc0ec02d4846a3 ]
+
+Deferred close can be a very useful feature for allowing
+caching data for read, and for minimizing the number of
+reopens needed for a file that is repeatedly opened and
+close but there are workloads where its default (1 second,
+similar to actimeo/acregmax) is much too small.
+
+Allow the user to configure the amount of time we can
+defer sending the final smb3 close when we have a
+handle lease on the file (rather than forcing it to depend
+on value of actimeo which is often unrelated, and less safe).
+
+Adds new mount parameter "closetimeo=" which is the maximum
+number of seconds we can wait before sending an SMB3
+close when we have a handle lease for it.  Default value
+also is set to slightly larger at 5 seconds (although some
+other clients use larger default this should still help).
+
+Suggested-by: Bharath SM <bharathsm@microsoft.com>
+Reviewed-by: Bharath SM <bharathsm@microsoft.com>
+Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
+Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Stable-dep-of: d19342c6609b ("cifs: sanitize paths in cifs_update_super_prepath.")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/cifsfs.c     | 1 +
+ fs/cifs/connect.c    | 2 ++
+ fs/cifs/file.c       | 4 ++--
+ fs/cifs/fs_context.c | 9 +++++++++
+ fs/cifs/fs_context.h | 8 ++++++++
+ 5 files changed, 22 insertions(+), 2 deletions(-)
+
+diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
+index fc736ced6f4a3..26f87437b2dd7 100644
+--- a/fs/cifs/cifsfs.c
++++ b/fs/cifs/cifsfs.c
+@@ -682,6 +682,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
+               seq_printf(s, ",acdirmax=%lu", cifs_sb->ctx->acdirmax / HZ);
+               seq_printf(s, ",acregmax=%lu", cifs_sb->ctx->acregmax / HZ);
+       }
++      seq_printf(s, ",closetimeo=%lu", cifs_sb->ctx->closetimeo / HZ);
+       if (tcon->ses->chan_max > 1)
+               seq_printf(s, ",multichannel,max_channels=%zu",
+diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
+index 555bd386a24df..f6c41265fdfd9 100644
+--- a/fs/cifs/connect.c
++++ b/fs/cifs/connect.c
+@@ -2436,6 +2436,8 @@ compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data)
+               return 0;
+       if (old->ctx->acdirmax != new->ctx->acdirmax)
+               return 0;
++      if (old->ctx->closetimeo != new->ctx->closetimeo)
++              return 0;
+       return 1;
+ }
+diff --git a/fs/cifs/file.c b/fs/cifs/file.c
+index cca9ff01b30c2..b3cf9ab50139d 100644
+--- a/fs/cifs/file.c
++++ b/fs/cifs/file.c
+@@ -897,12 +897,12 @@ int cifs_close(struct inode *inode, struct file *file)
+                                * So, Increase the ref count to avoid use-after-free.
+                                */
+                               if (!mod_delayed_work(deferredclose_wq,
+-                                              &cfile->deferred, cifs_sb->ctx->acregmax))
++                                              &cfile->deferred, cifs_sb->ctx->closetimeo))
+                                       cifsFileInfo_get(cfile);
+                       } else {
+                               /* Deferred close for files */
+                               queue_delayed_work(deferredclose_wq,
+-                                              &cfile->deferred, cifs_sb->ctx->acregmax);
++                                              &cfile->deferred, cifs_sb->ctx->closetimeo);
+                               cfile->deferred_close_scheduled = true;
+                               spin_unlock(&cinode->deferred_lock);
+                               return 0;
+diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
+index 3b8ed36b37113..85ad0c9e2f8b5 100644
+--- a/fs/cifs/fs_context.c
++++ b/fs/cifs/fs_context.c
+@@ -143,6 +143,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
+       fsparam_u32("actimeo", Opt_actimeo),
+       fsparam_u32("acdirmax", Opt_acdirmax),
+       fsparam_u32("acregmax", Opt_acregmax),
++      fsparam_u32("closetimeo", Opt_closetimeo),
+       fsparam_u32("echo_interval", Opt_echo_interval),
+       fsparam_u32("max_credits", Opt_max_credits),
+       fsparam_u32("handletimeout", Opt_handletimeout),
+@@ -1058,6 +1059,13 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
+               }
+               ctx->acdirmax = ctx->acregmax = HZ * result.uint_32;
+               break;
++      case Opt_closetimeo:
++              ctx->closetimeo = HZ * result.uint_32;
++              if (ctx->closetimeo > SMB3_MAX_DCLOSETIMEO) {
++                      cifs_errorf(fc, "closetimeo too large\n");
++                      goto cifs_parse_mount_err;
++              }
++              break;
+       case Opt_echo_interval:
+               ctx->echo_interval = result.uint_32;
+               break;
+@@ -1496,6 +1504,7 @@ int smb3_init_fs_context(struct fs_context *fc)
+       ctx->acregmax = CIFS_DEF_ACTIMEO;
+       ctx->acdirmax = CIFS_DEF_ACTIMEO;
++      ctx->closetimeo = SMB3_DEF_DCLOSETIMEO;
+       /* Most clients set timeout to 0, allows server to use its default */
+       ctx->handle_timeout = 0; /* See MS-SMB2 spec section 2.2.14.2.12 */
+diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
+index 29601a4eb4116..b5ae210bafe04 100644
+--- a/fs/cifs/fs_context.h
++++ b/fs/cifs/fs_context.h
+@@ -123,6 +123,7 @@ enum cifs_param {
+       Opt_actimeo,
+       Opt_acdirmax,
+       Opt_acregmax,
++      Opt_closetimeo,
+       Opt_echo_interval,
+       Opt_max_credits,
+       Opt_snapshot,
+@@ -243,6 +244,8 @@ struct smb3_fs_context {
+       /* attribute cache timemout for files and directories in jiffies */
+       unsigned long acregmax;
+       unsigned long acdirmax;
++      /* timeout for deferred close of files in jiffies */
++      unsigned long closetimeo;
+       struct smb_version_operations *ops;
+       struct smb_version_values *vals;
+       char *prepath;
+@@ -275,4 +278,9 @@ static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *f
+ extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);
+ extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
++/*
++ * max deferred close timeout (jiffies) - 2^30
++ */
++#define SMB3_MAX_DCLOSETIMEO (1 << 30)
++#define SMB3_DEF_DCLOSETIMEO (5 * HZ) /* Can increase later, other clients use larger */
+ #endif
+-- 
+2.39.2
+
diff --git a/queue-5.15/smb3-lower-default-deferred-close-timeout-to-address.patch b/queue-5.15/smb3-lower-default-deferred-close-timeout-to-address.patch
new file mode 100644 (file)
index 0000000..1fa371c
--- /dev/null
@@ -0,0 +1,48 @@
+From 51a9713180712fe92b9b0bbd465068ee0ae59747 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 23 Mar 2023 15:10:26 -0500
+Subject: smb3: lower default deferred close timeout to address perf regression
+
+From: Steve French <stfrench@microsoft.com>
+
+[ Upstream commit 7e0e76d99079be13c9961dde7c93b2d1ee665af4 ]
+
+Performance tests with large number of threads noted that the change
+of the default closetimeo (deferred close timeout between when
+close is done by application and when client has to send the close
+to the server), to 5 seconds from 1 second, significantly degraded
+perf in some cases like this (in the filebench example reported,
+the stats show close requests on the wire taking twice as long,
+and 50% regression in filebench perf). This is stil configurable
+via mount parm closetimeo, but to be safe, decrease default back
+to its previous value of 1 second.
+
+Reported-by: Yin Fengwei <fengwei.yin@intel.com>
+Reported-by: kernel test robot <yujie.liu@intel.com>
+Link: https://lore.kernel.org/lkml/997614df-10d4-af53-9571-edec36b0e2f3@intel.com/
+Fixes: 5efdd9122eff ("smb3: allow deferred close timeout to be configurable")
+Cc: stable@vger.kernel.org # 6.0+
+Tested-by: Yin Fengwei <fengwei.yin@intel.com>
+Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
+Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Stable-dep-of: d19342c6609b ("cifs: sanitize paths in cifs_update_super_prepath.")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/fs_context.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
+index b5ae210bafe04..ad45256cf68e2 100644
+--- a/fs/cifs/fs_context.h
++++ b/fs/cifs/fs_context.h
+@@ -282,5 +282,5 @@ extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
+  * max deferred close timeout (jiffies) - 2^30
+  */
+ #define SMB3_MAX_DCLOSETIMEO (1 << 30)
+-#define SMB3_DEF_DCLOSETIMEO (5 * HZ) /* Can increase later, other clients use larger */
++#define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
+ #endif
+-- 
+2.39.2
+