diff mbox series

CIFS: Fix oplock handling for SMB 2.1+ protocols

Message ID 20190926193120.23769-1-pshilov@microsoft.com
State New
Headers show
Series CIFS: Fix oplock handling for SMB 2.1+ protocols | expand

Commit Message

Pavel Shilovsky Sept. 26, 2019, 7:31 p.m. UTC
There may be situations when a server negotiates SMB 2.1
protocol version or higher but responds to a CREATE request
with an oplock rather than a lease.

Currently the client doesn't handle such a case correctly:
when another CREATE comes in the server sends an oplock
break to the initial CREATE and the client doesn't send
an ack back due to a wrong caching level being set (READ
instead of RWH). Missing an oplock break ack makes the
server wait until the break times out which dramatically
increases the latency of the second CREATE.

Fix this by properly detecting oplocks when using SMB 2.1
protocol version and higher.

Cc: <stable@vger.kernel.org>
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
 fs/cifs/smb2ops.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series


diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 047066493832..00d2ac80cd6e 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -3314,6 +3314,11 @@  smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
+	/* Check if the server granted an oplock rather than a lease */
+		return smb2_set_oplock_level(cinode, oplock, epoch,
+					     purge_cache);
 	if (oplock & SMB2_LEASE_READ_CACHING_HE) {
 		new_oplock |= CIFS_CACHE_READ_FLG;
 		strcat(message, "R");