Linux-CIFS Archive mirror
 help / color / mirror / Atom feed
From: Steve French <smfrench@gmail.com>
To: CIFS <linux-cifs@vger.kernel.org>
Cc: ronnie sahlberg <ronniesahlberg@gmail.com>,
	 Ritvik Budhiraja <budhirajaritviksmb@gmail.com>
Subject: [PATCH][SMB3 client] fix open files on server counter going negative
Date: Sat, 6 Apr 2024 23:29:46 -0500	[thread overview]
Message-ID: <CAH2r5mvF5JPaiT0S7DYRh-PiH+fKzsM4vij5Miffn-kxS3-zHg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 547 bytes --]

(resending with corrected email text)

The /proc/fs/cifs/Stats files open on the server counter
      Open files: 0 total (local), 0 open on server
was going negative because in smb2_close_cached_fid  we were
decrementing the count of remote (on server) open files twice (e.g.
for the case where we were closing cached directories so this was more
of an issue with mount to servers like Windows that support directory
leases).

    Fixes: 8e843bf38f7b ("cifs: return a single-use cfid if we did not
get a lease")

Fix attached

-- 
Thanks,

Steve

[-- Attachment #2: 0001-smb3-fix-Open-files-on-server-counter-going-negative.patch --]
[-- Type: text/x-patch, Size: 1177 bytes --]

From 4def7b92de293b9d3c5784bb9257490427833bce Mon Sep 17 00:00:00 2001
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

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
Signed-off-by: Steve French <stfrench@microsoft.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.40.1


                 reply	other threads:[~2024-04-07  4:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH2r5mvF5JPaiT0S7DYRh-PiH+fKzsM4vij5Miffn-kxS3-zHg@mail.gmail.com \
    --to=smfrench@gmail.com \
    --cc=budhirajaritviksmb@gmail.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=ronniesahlberg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).