All of lore.kernel.org
 help / color / mirror / Atom feed
From: nspmangalore@gmail.com
To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.org,
	bharathsm@microsoft.com, dhowells@redhat.com,
	henrique.carvalho@suse.com, ematsumiya@suse.de
Cc: Shyam Prasad N <sprasad@microsoft.com>, stable@vger.kernel.org
Subject: [PATCH v2 2/7] cifs: abort open_cached_dir if we don't request leases
Date: Tue, 21 Apr 2026 12:09:50 +0530	[thread overview]
Message-ID: <20260421063955.99164-2-sprasad@microsoft.com> (raw)
In-Reply-To: <20260421063955.99164-1-sprasad@microsoft.com>

From: Shyam Prasad N <sprasad@microsoft.com>

It is possible that SMB2_open_init may not set lease context based
on the requested oplock level. This can happen when leases have been
temporarily or permanently disabled. When this happens, we will have
open_cached_dir making an open without lease context and the response
will anyway be rejected by open_cached_dir (thereby forcing a close to
discard this open). That's unnecessary two round-trips to the server.

This change adds a check before making the open request to the server
to make sure that SMB2_open_init did add the expected lease context
to the open in open_cached_dir.

Cc: <stable@vger.kernel.org>
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
---
 fs/smb/client/cached_dir.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index 04bb95091f498..e9917e5204b00 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -286,6 +286,13 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
 			    &rqst[0], &oplock, &oparms, utf16_path);
 	if (rc)
 		goto oshr_free;
+
+	if (oplock != SMB2_OPLOCK_LEVEL_II) {
+		rc = -EINVAL;
+		cifs_dbg(FYI, "unexpected oplock level %d for cached directory\n", oplock);
+		goto oshr_free;
+	}
+
 	smb2_set_next_command(tcon, &rqst[0]);
 
 	memset(&qi_iov, 0, sizeof(qi_iov));
-- 
2.43.0


  reply	other threads:[~2026-04-21  6:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21  6:39 [PATCH v2 1/7] cifs: change_conf needs to be called for session setup nspmangalore
2026-04-21  6:39 ` nspmangalore [this message]
2026-04-21 15:26   ` [PATCH v2 2/7] cifs: abort open_cached_dir if we don't request leases Bharath SM
2026-04-24  4:06     ` Shyam Prasad N
2026-04-21  6:39 ` [PATCH v2 3/7] cifs: invalidate cfid on unlink/rename/rmdir nspmangalore
2026-04-21  6:39 ` [PATCH v2 4/7] cifs: define variable sized buffer for querydir responses nspmangalore
2026-04-21  6:39 ` [PATCH v2 5/7] cifs: optimize readdir for small directories nspmangalore
2026-04-21  6:39 ` [PATCH v2 6/7] cifs: optimize readdir for larger directories nspmangalore
2026-04-21  6:39 ` [PATCH v2 7/7] cifs: reorganize cached dir helpers nspmangalore
2026-04-21 13:58 ` [PATCH v2 1/7] cifs: change_conf needs to be called for session setup Bharath SM
2026-04-24  4:07   ` Shyam Prasad N

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=20260421063955.99164-2-sprasad@microsoft.com \
    --to=nspmangalore@gmail.com \
    --cc=bharathsm@microsoft.com \
    --cc=dhowells@redhat.com \
    --cc=ematsumiya@suse.de \
    --cc=henrique.carvalho@suse.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.