Commit 0fd1d37b authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French

CIFS: Do not assume one credit for async responses

If we don't receive a response we can't assume that the server
granted one credit. Assume zero credits in such cases.
Signed-off-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 3d3003fc
...@@ -2924,9 +2924,10 @@ smb2_echo_callback(struct mid_q_entry *mid) ...@@ -2924,9 +2924,10 @@ smb2_echo_callback(struct mid_q_entry *mid)
{ {
struct TCP_Server_Info *server = mid->callback_data; struct TCP_Server_Info *server = mid->callback_data;
struct smb2_echo_rsp *rsp = (struct smb2_echo_rsp *)mid->resp_buf; struct smb2_echo_rsp *rsp = (struct smb2_echo_rsp *)mid->resp_buf;
unsigned int credits_received = 1; unsigned int credits_received = 0;
if (mid->mid_state == MID_RESPONSE_RECEIVED) if (mid->mid_state == MID_RESPONSE_RECEIVED
|| mid->mid_state == MID_RESPONSE_MALFORMED)
credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest); credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest);
DeleteMidQEntry(mid); DeleteMidQEntry(mid);
...@@ -3183,7 +3184,7 @@ smb2_readv_callback(struct mid_q_entry *mid) ...@@ -3183,7 +3184,7 @@ smb2_readv_callback(struct mid_q_entry *mid)
struct TCP_Server_Info *server = tcon->ses->server; struct TCP_Server_Info *server = tcon->ses->server;
struct smb2_sync_hdr *shdr = struct smb2_sync_hdr *shdr =
(struct smb2_sync_hdr *)rdata->iov[0].iov_base; (struct smb2_sync_hdr *)rdata->iov[0].iov_base;
unsigned int credits_received = 1; unsigned int credits_received = 0;
struct smb_rqst rqst = { .rq_iov = rdata->iov, struct smb_rqst rqst = { .rq_iov = rdata->iov,
.rq_nvec = 2, .rq_nvec = 2,
.rq_pages = rdata->pages, .rq_pages = rdata->pages,
...@@ -3222,6 +3223,9 @@ smb2_readv_callback(struct mid_q_entry *mid) ...@@ -3222,6 +3223,9 @@ smb2_readv_callback(struct mid_q_entry *mid)
task_io_account_read(rdata->got_bytes); task_io_account_read(rdata->got_bytes);
cifs_stats_bytes_read(tcon, rdata->got_bytes); cifs_stats_bytes_read(tcon, rdata->got_bytes);
break; break;
case MID_RESPONSE_MALFORMED:
credits_received = le16_to_cpu(shdr->CreditRequest);
/* fall through */
default: default:
if (rdata->result != -ENODATA) if (rdata->result != -ENODATA)
rdata->result = -EIO; rdata->result = -EIO;
...@@ -3407,7 +3411,7 @@ smb2_writev_callback(struct mid_q_entry *mid) ...@@ -3407,7 +3411,7 @@ smb2_writev_callback(struct mid_q_entry *mid)
struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
unsigned int written; unsigned int written;
struct smb2_write_rsp *rsp = (struct smb2_write_rsp *)mid->resp_buf; struct smb2_write_rsp *rsp = (struct smb2_write_rsp *)mid->resp_buf;
unsigned int credits_received = 1; unsigned int credits_received = 0;
switch (mid->mid_state) { switch (mid->mid_state) {
case MID_RESPONSE_RECEIVED: case MID_RESPONSE_RECEIVED:
...@@ -3435,6 +3439,9 @@ smb2_writev_callback(struct mid_q_entry *mid) ...@@ -3435,6 +3439,9 @@ smb2_writev_callback(struct mid_q_entry *mid)
case MID_RETRY_NEEDED: case MID_RETRY_NEEDED:
wdata->result = -EAGAIN; wdata->result = -EAGAIN;
break; break;
case MID_RESPONSE_MALFORMED:
credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest);
/* fall through */
default: default:
wdata->result = -EIO; wdata->result = -EIO;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment