Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

CIFS: Fix possible hang during async MTU reads and writes

When doing MTU i/o we need to leave some credits for
possible reopen requests and other operations happening
in parallel. Currently we leave 1 credit which is not
enough even for reopen only: we need at least 2 credits
if durable handle reconnect fails. Also there may be
other operations at the same time including compounding
ones which require 3 credits at a time each. Fix this
by leaving 8 credits which is big enough to cover most
scenarios.

Was able to reproduce this when server was configured
to give out fewer credits than usual.

The proper fix would be to reconnect a file handle first
and then obtain credits for an MTU request but this leads
to bigger code changes and should happen in other patches.

Cc: <stable@vger.kernel.org>
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Pavel Shilovsky and committed by
Steve French
acc58d0b 73aaf920

+3 -3
+3 -3
fs/cifs/smb2ops.c
··· 165 165 166 166 scredits = server->credits; 167 167 /* can deadlock with reopen */ 168 - if (scredits == 1) { 168 + if (scredits <= 8) { 169 169 *num = SMB2_MAX_BUFFER_SIZE; 170 170 *credits = 0; 171 171 break; 172 172 } 173 173 174 - /* leave one credit for a possible reopen */ 175 - scredits--; 174 + /* leave some credits for reopen and other ops */ 175 + scredits -= 8; 176 176 *num = min_t(unsigned int, size, 177 177 scredits * SMB2_MAX_BUFFER_SIZE); 178 178