From e7f4b8f1a5893ff8296b5b581e16a0b96f60a3b5 Mon Sep 17 00:00:00 2001 From: Eric Van Hensbergen Date: Fri, 17 Oct 2008 16:20:07 -0500 Subject: 9p: Improve debug support The new debug support lacks some of the information that the previous fcprint code provided -- this patch focuses on better presentation of debug data along with more helpful debug along error paths. Signed-off-by: Eric Van Hensbergen --- net/9p/protocol.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'net/9p/protocol.c') diff --git a/net/9p/protocol.c b/net/9p/protocol.c index 92cb60bb191b..84fa21271876 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include "protocol.h" @@ -52,8 +53,6 @@ static int p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...); -#define PACKET_DEBUG 0 - void p9pdu_dump(int way, struct p9_fcall *pdu) { @@ -78,9 +77,9 @@ p9pdu_dump(int way, struct p9_fcall *pdu) n += scnprintf(buf + n, buflen - n, "\n"); if (way) - printk(KERN_NOTICE "[[(%d)[ %s\n", datalen, buf); + P9_DPRINTK(P9_DEBUG_PKT, "[[[(%d) %s\n", datalen, buf); else - printk(KERN_NOTICE "]](%d)] %s\n", datalen, buf); + P9_DPRINTK(P9_DEBUG_PKT, "]]](%d) %s\n", datalen, buf); } EXPORT_SYMBOL(p9pdu_dump); @@ -512,13 +511,20 @@ p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...) int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu) { struct p9_fcall fake_pdu; + int ret; fake_pdu.size = len; fake_pdu.capacity = len; fake_pdu.sdata = buf; fake_pdu.offset = 0; - return p9pdu_readf(&fake_pdu, dotu, "S", st); + ret = p9pdu_readf(&fake_pdu, dotu, "S", st); + if (ret) { + P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); + p9pdu_dump(1, &fake_pdu); + } + + return ret; } EXPORT_SYMBOL(p9stat_read); @@ -536,9 +542,12 @@ int p9pdu_finalize(struct p9_fcall *pdu) err = p9pdu_writef(pdu, 0, "d", size); pdu->size = size; - if (PACKET_DEBUG) + if ((p9_debug_level & P9_DEBUG_PKT) == P9_DEBUG_PKT) p9pdu_dump(0, pdu); + P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size, + pdu->id, pdu->tag); + return err; } -- cgit v1.2.3