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>
This commit is contained in:
Pavel Shilovsky
2019-01-23 18:15:52 -08:00
committed by Steve French
parent 97ea499883
commit 9a1c67e8d5
4 changed files with 94 additions and 42 deletions

View File

@@ -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;
}