From 6a0a87a1a8df0540f1f09346f45f8e94167af910 Mon Sep 17 00:00:00 2001
From: Henrique Carvalho <henrique.carvalho@suse.com>
Date: Jun 02 2025 17:55:06 +0000
Subject: smb3: fix Open files on server counter going negative

(git-fixes).

---

diff --git a/patches.suse/smb3-fix-Open-files-on-server-counter-going-negative.patch b/patches.suse/smb3-fix-Open-files-on-server-counter-going-negative.patch
new file mode 100644
index 0000000..3e87b3a
--- /dev/null
+++ b/patches.suse/smb3-fix-Open-files-on-server-counter-going-negative.patch
@@ -0,0 +1,38 @@
+From: Steve French <stfrench@microsoft.com>
+Date: Sat, 6 Apr 2024 23:16:08 -0500
+Subject: [PATCH] smb3: fix Open files on server counter going negative
+Git-commit: 28e0947651ce6a2200b9a7eceb93282e97d7e51a
+References: git-fixes
+Patch-mainline: v6.9-rc4
+
+We were decrementing the count of open files on server twice
+for the case where we were closing cached directories.
+
+Fixes: 8e843bf38f7b ("cifs: return a single-use cfid if we did not get a lease")
+Cc: stable@vger.kernel.org
+Acked-by: Bharath SM <bharathsm@microsoft.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
+Acked-by: Henrique Carvalho <henrique.carvalho@suse.com>
+---
+ fs/smb/client/cached_dir.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
+index 13a9d7acf8f8..0ff2491c311d 100644
+--- a/fs/smb/client/cached_dir.c
++++ b/fs/smb/client/cached_dir.c
+@@ -433,8 +433,8 @@ smb2_close_cached_fid(struct kref *ref)
+ 	if (cfid->is_open) {
+ 		rc = SMB2_close(0, cfid->tcon, cfid->fid.persistent_fid,
+ 			   cfid->fid.volatile_fid);
+-		if (rc != -EBUSY && rc != -EAGAIN)
+-			atomic_dec(&cfid->tcon->num_remote_opens);
++		if (rc) /* should we retry on -EBUSY or -EAGAIN? */
++			cifs_dbg(VFS, "close cached dir rc %d\n", rc);
+ 	}
+ 
+ 	free_cached_dir(cfid);
+-- 
+2.47.0
+
diff --git a/series.conf b/series.conf
index 6413fb0..39f2684 100644
--- a/series.conf
+++ b/series.conf
@@ -24191,6 +24191,7 @@
 	patches.suse/arm64-dts-imx8qm-ss-dma-fix-can-lpcg-indices.patch
 	patches.suse/firmware-arm_scmi-Make-raw-debugfs-entries-non-seeka.patch
 	patches.suse/arm64-tlb-Fix-TLBI-RANGE-operand.patch
+	patches.suse/smb3-fix-Open-files-on-server-counter-going-negative.patch
 	patches.suse/smb-client-instantiate-when-creating-SFU-files.patch
 	patches.suse/ata-ahci-Add-mask_port_map-module-parameter.patch
 	patches.suse/ata-libata-core-Allow-command-duration-limits-detect.patch