Commit 3d3003fc authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French
Browse files

CIFS: Fix credit calculations in compound mid callback



The current code doesn't do proper accounting for credits
in SMB1 case: it adds one credit per response only if we get
a complete response while it needs to return it unconditionally.
Fix this and also include malformed responses for SMB2+ into
accounting for credits because such responses have Credit
Granted field, thus nothing prevents to get a proper credit
value from them.

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 ec678eae
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -154,7 +154,11 @@ smb2_get_credits(struct mid_q_entry *mid)
{
	struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)mid->resp_buf;

	if (mid->mid_state == MID_RESPONSE_RECEIVED
	    || mid->mid_state == MID_RESPONSE_MALFORMED)
		return le16_to_cpu(shdr->CreditRequest);

	return 0;
}

static int
+1 −10
Original line number Diff line number Diff line
@@ -786,17 +786,8 @@ static void
cifs_compound_callback(struct mid_q_entry *mid)
{
	struct TCP_Server_Info *server = mid->server;
	unsigned int optype = mid->optype;
	unsigned int credits_received = 0;

	if (mid->mid_state == MID_RESPONSE_RECEIVED) {
		if (mid->resp_buf)
			credits_received = server->ops->get_credits(mid);
		else
			cifs_dbg(FYI, "Bad state for cancelled MID\n");
	}

	add_credits(server, credits_received, optype);
	add_credits(server, server->ops->get_credits(mid), mid->optype);
}

static void