Commit e7f4b8f1 authored by Eric Van Hensbergen's avatar Eric Van Hensbergen

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: default avatarEric Van Hensbergen <ericvh@gmail.com>



parent 02da398b
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#ifndef NET_9P_H #ifndef NET_9P_H
#define NET_9P_H #define NET_9P_H
#ifdef CONFIG_NET_9P_DEBUG
/** /**
* enum p9_debug_flags - bits for mount time debug parameter * enum p9_debug_flags - bits for mount time debug parameter
* @P9_DEBUG_ERROR: more verbose error messages including original error string * @P9_DEBUG_ERROR: more verbose error messages including original error string
...@@ -55,10 +53,12 @@ enum p9_debug_flags { ...@@ -55,10 +53,12 @@ enum p9_debug_flags {
P9_DEBUG_SLABS = (1<<7), P9_DEBUG_SLABS = (1<<7),
P9_DEBUG_FCALL = (1<<8), P9_DEBUG_FCALL = (1<<8),
P9_DEBUG_FID = (1<<9), P9_DEBUG_FID = (1<<9),
P9_DEBUG_PKT = (1<<10),
}; };
extern unsigned int p9_debug_level; extern unsigned int p9_debug_level;
#ifdef CONFIG_NET_9P_DEBUG
#define P9_DPRINTK(level, format, arg...) \ #define P9_DPRINTK(level, format, arg...) \
do { \ do { \
if ((p9_debug_level & level) == level) {\ if ((p9_debug_level & level) == level) {\
......
...@@ -389,8 +389,8 @@ p9_parse_header(struct p9_fcall *pdu, int32_t *size, int8_t *type, int16_t *tag, ...@@ -389,8 +389,8 @@ p9_parse_header(struct p9_fcall *pdu, int32_t *size, int8_t *type, int16_t *tag,
pdu->id = r_type; pdu->id = r_type;
pdu->tag = r_tag; pdu->tag = r_tag;
P9_DPRINTK(P9_DEBUG_MUX, "pdu: type: %d tag: %d size=%d offset=%d\n", P9_DPRINTK(P9_DEBUG_9P, "<<< size=%d type: %d tag: %d\n", pdu->size,
pdu->id, pdu->tag, pdu->size, pdu->offset); pdu->id, pdu->tag);
if (type) if (type)
*type = r_type; *type = r_type;
...@@ -672,6 +672,7 @@ int p9_client_version(struct p9_client *c) ...@@ -672,6 +672,7 @@ int p9_client_version(struct p9_client *c)
err = p9pdu_readf(req->rc, c->dotu, "ds", &msize, &version); err = p9pdu_readf(req->rc, c->dotu, "ds", &msize, &version);
if (err) { if (err) {
P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err);
p9pdu_dump(1, req->rc);
goto error; goto error;
} }
...@@ -810,6 +811,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, ...@@ -810,6 +811,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid);
if (err) { if (err) {
p9pdu_dump(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
goto error; goto error;
} }
...@@ -856,6 +858,7 @@ p9_client_auth(struct p9_client *clnt, char *uname, u32 n_uname, char *aname) ...@@ -856,6 +858,7 @@ p9_client_auth(struct p9_client *clnt, char *uname, u32 n_uname, char *aname)
err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid);
if (err) { if (err) {
p9pdu_dump(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
goto error; goto error;
} }
...@@ -910,9 +913,12 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, ...@@ -910,9 +913,12 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames,
} }
err = p9pdu_readf(req->rc, clnt->dotu, "R", &nwqids, &wqids); err = p9pdu_readf(req->rc, clnt->dotu, "R", &nwqids, &wqids);
p9_free_req(clnt, req); if (err) {
if (err) p9pdu_dump(1, req->rc);
p9_free_req(clnt, req);
goto clunk_fid; goto clunk_fid;
}
p9_free_req(clnt, req);
P9_DPRINTK(P9_DEBUG_9P, "<<< RWALK nwqid %d:\n", nwqids); P9_DPRINTK(P9_DEBUG_9P, "<<< RWALK nwqid %d:\n", nwqids);
...@@ -967,9 +973,10 @@ int p9_client_open(struct p9_fid *fid, int mode) ...@@ -967,9 +973,10 @@ int p9_client_open(struct p9_fid *fid, int mode)
} }
err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit);
p9_free_req(clnt, req); if (err) {
if (err) p9pdu_dump(1, req->rc);
goto error; goto free_and_error;
}
P9_DPRINTK(P9_DEBUG_9P, "<<< ROPEN qid %x.%llx.%x iounit %x\n", P9_DPRINTK(P9_DEBUG_9P, "<<< ROPEN qid %x.%llx.%x iounit %x\n",
qid.type, qid.path, qid.version, iounit); qid.type, qid.path, qid.version, iounit);
...@@ -977,6 +984,8 @@ int p9_client_open(struct p9_fid *fid, int mode) ...@@ -977,6 +984,8 @@ int p9_client_open(struct p9_fid *fid, int mode)
fid->mode = mode; fid->mode = mode;
fid->iounit = iounit; fid->iounit = iounit;
free_and_error:
p9_free_req(clnt, req);
error: error:
return err; return err;
} }
...@@ -1007,9 +1016,10 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, ...@@ -1007,9 +1016,10 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
} }
err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit);
p9_free_req(clnt, req); if (err) {
if (err) p9pdu_dump(1, req->rc);
goto error; goto free_and_error;
}
P9_DPRINTK(P9_DEBUG_9P, "<<< RCREATE qid %x.%llx.%x iounit %x\n", P9_DPRINTK(P9_DEBUG_9P, "<<< RCREATE qid %x.%llx.%x iounit %x\n",
qid.type, qid.path, qid.version, iounit); qid.type, qid.path, qid.version, iounit);
...@@ -1017,6 +1027,8 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, ...@@ -1017,6 +1027,8 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
fid->mode = mode; fid->mode = mode;
fid->iounit = iounit; fid->iounit = iounit;
free_and_error:
p9_free_req(clnt, req);
error: error:
return err; return err;
} }
...@@ -1103,8 +1115,10 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, ...@@ -1103,8 +1115,10 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
} }
err = p9pdu_readf(req->rc, clnt->dotu, "D", &count, &dataptr); err = p9pdu_readf(req->rc, clnt->dotu, "D", &count, &dataptr);
if (err) if (err) {
p9pdu_dump(1, req->rc);
goto free_and_error; goto free_and_error;
}
P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count); P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
...@@ -1163,8 +1177,11 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, ...@@ -1163,8 +1177,11 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
} }
err = p9pdu_readf(req->rc, clnt->dotu, "d", &count); err = p9pdu_readf(req->rc, clnt->dotu, "d", &count);
if (err) if (err) {
p9pdu_dump(1, req->rc);
goto free_and_error; goto free_and_error;
}
P9_DPRINTK(P9_DEBUG_9P, "<<< RWRITE count %d\n", count); P9_DPRINTK(P9_DEBUG_9P, "<<< RWRITE count %d\n", count);
p9_free_req(clnt, req); p9_free_req(clnt, req);
...@@ -1200,20 +1217,27 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid) ...@@ -1200,20 +1217,27 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
} }
err = p9pdu_readf(req->rc, clnt->dotu, "wS", &ignored, ret); err = p9pdu_readf(req->rc, clnt->dotu, "wS", &ignored, ret);
p9_free_req(clnt, req); if (err) {
if (err) ret = ERR_PTR(err);
goto error; p9pdu_dump(1, req->rc);
goto free_and_error;
}
P9_DPRINTK(P9_DEBUG_9P, P9_DPRINTK(P9_DEBUG_9P,
"<<< RSTAT sz=%x type=%x dev=%x qid=%2.2x %4.4x %8.8llx" "<<< RSTAT sz=%x type=%x dev=%x qid=%x.%llx.%x\n"
" mode=%8.8x uid=%d gid=%d size=%lld %s\n", "<<< mode=%8.8x atime=%8.8x mtime=%8.8x length=%llx\n"
"<<< name=%s uid=%s gid=%s muid=%s extension=(%s)\n"
"<<< uid=%d gid=%d n_muid=%d\n",
ret->size, ret->type, ret->dev, ret->qid.type, ret->size, ret->type, ret->dev, ret->qid.type,
ret->qid.version, ret->qid.path, ret->mode, ret->qid.path, ret->qid.version, ret->mode,
ret->n_uid, ret->n_gid, ret->length, ret->name); ret->atime, ret->mtime, ret->length, ret->name,
ret->uid, ret->gid, ret->muid, ret->extension,
ret->n_uid, ret->n_gid, ret->n_muid);
return ret; free_and_error:
p9_free_req(clnt, req);
error: error:
return ERR_PTR(err); return ret;
} }
EXPORT_SYMBOL(p9_client_stat); EXPORT_SYMBOL(p9_client_stat);
...@@ -1224,6 +1248,16 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst) ...@@ -1224,6 +1248,16 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst)
struct p9_client *clnt; struct p9_client *clnt;
P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid); P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid);
P9_DPRINTK(P9_DEBUG_9P,
" sz=%x type=%x dev=%x qid=%x.%llx.%x\n"
" mode=%8.8x atime=%8.8x mtime=%8.8x length=%llx\n"
" name=%s uid=%s gid=%s muid=%s extension=(%s)\n"
" uid=%d gid=%d n_muid=%d\n",
wst->size, wst->type, wst->dev, wst->qid.type,
wst->qid.path, wst->qid.version, wst->mode,
wst->atime, wst->mtime, wst->length, wst->name,
wst->uid, wst->gid, wst->muid, wst->extension,
wst->n_uid, wst->n_gid, wst->n_muid);
err = 0; err = 0;
clnt = fid->clnt; clnt = fid->clnt;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/sched.h>
#include <net/9p/9p.h> #include <net/9p/9p.h>
#include <net/9p/client.h> #include <net/9p/client.h>
#include "protocol.h" #include "protocol.h"
...@@ -52,8 +53,6 @@ ...@@ -52,8 +53,6 @@
static int static int
p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...); p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...);
#define PACKET_DEBUG 0
void void
p9pdu_dump(int way, struct p9_fcall *pdu) p9pdu_dump(int way, struct p9_fcall *pdu)
{ {
...@@ -78,9 +77,9 @@ 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"); n += scnprintf(buf + n, buflen - n, "\n");
if (way) if (way)
printk(KERN_NOTICE "[[(%d)[ %s\n", datalen, buf); P9_DPRINTK(P9_DEBUG_PKT, "[[[(%d) %s\n", datalen, buf);
else else
printk(KERN_NOTICE "]](%d)] %s\n", datalen, buf); P9_DPRINTK(P9_DEBUG_PKT, "]]](%d) %s\n", datalen, buf);
} }
EXPORT_SYMBOL(p9pdu_dump); EXPORT_SYMBOL(p9pdu_dump);
...@@ -512,13 +511,20 @@ p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...) ...@@ -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) int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu)
{ {
struct p9_fcall fake_pdu; struct p9_fcall fake_pdu;
int ret;
fake_pdu.size = len; fake_pdu.size = len;
fake_pdu.capacity = len; fake_pdu.capacity = len;
fake_pdu.sdata = buf; fake_pdu.sdata = buf;
fake_pdu.offset = 0; 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); EXPORT_SYMBOL(p9stat_read);
...@@ -536,9 +542,12 @@ int p9pdu_finalize(struct p9_fcall *pdu) ...@@ -536,9 +542,12 @@ int p9pdu_finalize(struct p9_fcall *pdu)
err = p9pdu_writef(pdu, 0, "d", size); err = p9pdu_writef(pdu, 0, "d", size);
pdu->size = size; pdu->size = size;
if (PACKET_DEBUG) if ((p9_debug_level & P9_DEBUG_PKT) == P9_DEBUG_PKT)
p9pdu_dump(0, pdu); p9pdu_dump(0, pdu);
P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size,
pdu->id, pdu->tag);
return err; return err;
} }
......
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