Skip to content

Commit a016e27

Browse files
piastrysmfrench
authored andcommitted
CIFS: Fix oplock handling for SMB 2.1+ protocols
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: <[email protected]> Signed-off-by: Pavel Shilovsky <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Ronnie Sahlberg <[email protected]>
1 parent ff3ee62 commit a016e27

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/cifs/smb2ops.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,6 +3333,11 @@ smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
33333333
if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
33343334
return;
33353335

3336+
/* Check if the server granted an oplock rather than a lease */
3337+
if (oplock & SMB2_OPLOCK_LEVEL_EXCLUSIVE)
3338+
return smb2_set_oplock_level(cinode, oplock, epoch,
3339+
purge_cache);
3340+
33363341
if (oplock & SMB2_LEASE_READ_CACHING_HE) {
33373342
new_oplock |= CIFS_CACHE_READ_FLG;
33383343
strcat(message, "R");

0 commit comments

Comments
 (0)