diff options
author | Pavel Shilovsky <pshilov@microsoft.com> | 2019-01-23 18:15:52 -0800 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2019-03-05 18:10:01 -0600 |
commit | 9a1c67e8d5dad143d5166dac1ee6776f433dac00 (patch) | |
tree | 3af988a600e442519eb6cee59b8dec7499b1c3e5 /fs/cifs/smb2pdu.c | |
parent | 97ea499883cc0566b1fafdc12ca49d0926aab332 (diff) | |
download | linux-stable-9a1c67e8d5dad143d5166dac1ee6776f433dac00.tar.gz linux-stable-9a1c67e8d5dad143d5166dac1ee6776f433dac00.tar.bz2 linux-stable-9a1c67e8d5dad143d5166dac1ee6776f433dac00.zip |
CIFS: Adjust MTU credits before reopening a file
Currently we adjust MTU credits before sending an IO request
and after reopening a file. This approach doesn't allow the
reopen routine to use existing credits that are not needed
for IO. Reorder credit adjustment and reopening a file to
use credits available to the client more efficiently. Also
unwrap complex if statement into few pieces to improve
readability.
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/smb2pdu.c')
-rw-r--r-- | fs/cifs/smb2pdu.c | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 710531245ed7..7d1e069cdcb8 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -3322,21 +3322,11 @@ smb2_async_readv(struct cifs_readdata *rdata) SMB2_MAX_BUFFER_SIZE)); shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 1); - spin_lock(&server->req_lock); - if (server->reconnect_instance == rdata->credits.instance) - server->credits += rdata->credits.value - - le16_to_cpu(shdr->CreditCharge); - else { - spin_unlock(&server->req_lock); - cifs_dbg(VFS, "trying to return %u credits to old session\n", - rdata->credits.value - - le16_to_cpu(shdr->CreditCharge)); - rc = -EAGAIN; + + rc = adjust_credits(server, &rdata->credits, rdata->bytes); + if (rc) goto async_readv_out; - } - spin_unlock(&server->req_lock); - wake_up(&server->request_q); - rdata->credits.value = le16_to_cpu(shdr->CreditCharge); + flags |= CIFS_HAS_CREDITS; } @@ -3626,21 +3616,11 @@ smb2_async_writev(struct cifs_writedata *wdata, SMB2_MAX_BUFFER_SIZE)); shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 1); - spin_lock(&server->req_lock); - if (server->reconnect_instance == wdata->credits.instance) - server->credits += wdata->credits.value - - le16_to_cpu(shdr->CreditCharge); - else { - spin_unlock(&server->req_lock); - cifs_dbg(VFS, "trying to return %d credits to old session\n", - wdata->credits.value - - le16_to_cpu(shdr->CreditCharge)); - rc = -EAGAIN; + + rc = adjust_credits(server, &wdata->credits, wdata->bytes); + if (rc) goto async_writev_out; - } - spin_unlock(&server->req_lock); - wake_up(&server->request_q); - wdata->credits.value = le16_to_cpu(shdr->CreditCharge); + flags |= CIFS_HAS_CREDITS; } |