[PATCH] cifs: better instrumentation for coalesce_t2

From: Jeff Layton
Date: Sat Dec 31 2011 - 06:53:26 EST


When coalesce_t2 returns an error, have it throw a cFYI message that
explains the reason.

Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
fs/cifs/connect.c | 29 +++++++++++++++++++++--------
1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 8cd4b52..cbf3b78 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -243,16 +243,21 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)

remaining = total_data_size - total_in_buf;

- if (remaining < 0)
+ if (remaining < 0) {
+ cFYI(1, "Server sent too much data. total_data_size=%hu "
+ "total_in_buf=%hu", total_data_size, total_in_buf);
return -EPROTO;
+ }

- if (remaining == 0) /* nothing to do, ignore */
+ if (remaining == 0) {
+ /* nothing to do, ignore */
+ cFYI(1, "no more data remains");
return 0;
+ }

total_in_buf2 = get_unaligned_le16(&pSMB2->t2_rsp.DataCount);
- if (remaining < total_in_buf2) {
+ if (remaining < total_in_buf2)
cFYI(1, "transact2 2nd response contains too much data");
- }

/* find end of first SMB data area */
data_area_of_target = (char *)&pSMBt->hdr.Protocol +
@@ -267,23 +272,29 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
/* copy second buffer into end of first buffer */
total_in_buf += total_in_buf2;
/* is the result too big for the field? */
- if (total_in_buf > USHRT_MAX)
+ if (total_in_buf > USHRT_MAX) {
+ cFYI(1, "coalesced total_in_buf too large (%u)", total_in_buf);
return -EPROTO;
+ }
put_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount);

/* fix up the BCC */
byte_count = get_bcc(pTargetSMB);
byte_count += total_in_buf2;
/* is the result too big for the field? */
- if (byte_count > USHRT_MAX)
+ if (byte_count > USHRT_MAX) {
+ cFYI(1, "coalesced BCC too large (%u)", byte_count);
return -EPROTO;
+ }
put_bcc(byte_count, pTargetSMB);

byte_count = be32_to_cpu(pTargetSMB->smb_buf_length);
byte_count += total_in_buf2;
/* don't allow buffer to overflow */
- if (byte_count > CIFSMaxBufSize)
+ if (byte_count > CIFSMaxBufSize) {
+ cFYI(1, "coalesced BCC exceeds buffer size (%u)", byte_count);
return -ENOBUFS;
+ }
pTargetSMB->smb_buf_length = cpu_to_be32(byte_count);

memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2);
@@ -291,8 +302,10 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
if (remaining == total_in_buf2) {
cFYI(1, "found the last secondary response");
return 0; /* we are done */
- } else /* more responses to go */
+ } else {/* more responses to go */
+ cFYI(1, "waiting for more secondary responses");
return 1;
+ }
}

static void
--
1.7.7.4


--MP_//.FiSwuzYm5ij6l1Hxxu2g4--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/