diff options
author | Eric Van Hensbergen <ericvh@gmail.com> | 2008-10-17 17:20:07 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2008-10-17 17:20:07 -0400 |
commit | e7f4b8f1a5893ff8296b5b581e16a0b96f60a3b5 (patch) | |
tree | dcf52d5919d2ba1a5f7af7449839c4ada85e11cd /net/9p | |
parent | 02da398b950c5d079c20afaa23f322383e96070a (diff) |
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 <ericvh@gmail.com>
Diffstat (limited to 'net/9p')
-rw-r--r-- | net/9p/client.c | 76 | ||||
-rw-r--r-- | net/9p/protocol.c | 21 |
2 files changed, 70 insertions, 27 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index 2a166bfb95a3..bbac2f72b4d2 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -389,8 +389,8 @@ p9_parse_header(struct p9_fcall *pdu, int32_t *size, int8_t *type, int16_t *tag, | |||
389 | pdu->id = r_type; | 389 | pdu->id = r_type; |
390 | pdu->tag = r_tag; | 390 | pdu->tag = r_tag; |
391 | 391 | ||
392 | P9_DPRINTK(P9_DEBUG_MUX, "pdu: type: %d tag: %d size=%d offset=%d\n", | 392 | P9_DPRINTK(P9_DEBUG_9P, "<<< size=%d type: %d tag: %d\n", pdu->size, |
393 | pdu->id, pdu->tag, pdu->size, pdu->offset); | 393 | pdu->id, pdu->tag); |
394 | 394 | ||
395 | if (type) | 395 | if (type) |
396 | *type = r_type; | 396 | *type = r_type; |
@@ -672,6 +672,7 @@ int p9_client_version(struct p9_client *c) | |||
672 | err = p9pdu_readf(req->rc, c->dotu, "ds", &msize, &version); | 672 | err = p9pdu_readf(req->rc, c->dotu, "ds", &msize, &version); |
673 | if (err) { | 673 | if (err) { |
674 | P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); | 674 | P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); |
675 | p9pdu_dump(1, req->rc); | ||
675 | goto error; | 676 | goto error; |
676 | } | 677 | } |
677 | 678 | ||
@@ -810,6 +811,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, | |||
810 | 811 | ||
811 | err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); | 812 | err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); |
812 | if (err) { | 813 | if (err) { |
814 | p9pdu_dump(1, req->rc); | ||
813 | p9_free_req(clnt, req); | 815 | p9_free_req(clnt, req); |
814 | goto error; | 816 | goto error; |
815 | } | 817 | } |
@@ -856,6 +858,7 @@ p9_client_auth(struct p9_client *clnt, char *uname, u32 n_uname, char *aname) | |||
856 | 858 | ||
857 | err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); | 859 | err = p9pdu_readf(req->rc, clnt->dotu, "Q", &qid); |
858 | if (err) { | 860 | if (err) { |
861 | p9pdu_dump(1, req->rc); | ||
859 | p9_free_req(clnt, req); | 862 | p9_free_req(clnt, req); |
860 | goto error; | 863 | goto error; |
861 | } | 864 | } |
@@ -910,9 +913,12 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, | |||
910 | } | 913 | } |
911 | 914 | ||
912 | err = p9pdu_readf(req->rc, clnt->dotu, "R", &nwqids, &wqids); | 915 | err = p9pdu_readf(req->rc, clnt->dotu, "R", &nwqids, &wqids); |
913 | p9_free_req(clnt, req); | 916 | if (err) { |
914 | if (err) | 917 | p9pdu_dump(1, req->rc); |
918 | p9_free_req(clnt, req); | ||
915 | goto clunk_fid; | 919 | goto clunk_fid; |
920 | } | ||
921 | p9_free_req(clnt, req); | ||
916 | 922 | ||
917 | P9_DPRINTK(P9_DEBUG_9P, "<<< RWALK nwqid %d:\n", nwqids); | 923 | P9_DPRINTK(P9_DEBUG_9P, "<<< RWALK nwqid %d:\n", nwqids); |
918 | 924 | ||
@@ -967,9 +973,10 @@ int p9_client_open(struct p9_fid *fid, int mode) | |||
967 | } | 973 | } |
968 | 974 | ||
969 | err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); | 975 | err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); |
970 | p9_free_req(clnt, req); | 976 | if (err) { |
971 | if (err) | 977 | p9pdu_dump(1, req->rc); |
972 | goto error; | 978 | goto free_and_error; |
979 | } | ||
973 | 980 | ||
974 | P9_DPRINTK(P9_DEBUG_9P, "<<< ROPEN qid %x.%llx.%x iounit %x\n", | 981 | P9_DPRINTK(P9_DEBUG_9P, "<<< ROPEN qid %x.%llx.%x iounit %x\n", |
975 | qid.type, qid.path, qid.version, iounit); | 982 | qid.type, qid.path, qid.version, iounit); |
@@ -977,6 +984,8 @@ int p9_client_open(struct p9_fid *fid, int mode) | |||
977 | fid->mode = mode; | 984 | fid->mode = mode; |
978 | fid->iounit = iounit; | 985 | fid->iounit = iounit; |
979 | 986 | ||
987 | free_and_error: | ||
988 | p9_free_req(clnt, req); | ||
980 | error: | 989 | error: |
981 | return err; | 990 | return err; |
982 | } | 991 | } |
@@ -1007,9 +1016,10 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, | |||
1007 | } | 1016 | } |
1008 | 1017 | ||
1009 | err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); | 1018 | err = p9pdu_readf(req->rc, clnt->dotu, "Qd", &qid, &iounit); |
1010 | p9_free_req(clnt, req); | 1019 | if (err) { |
1011 | if (err) | 1020 | p9pdu_dump(1, req->rc); |
1012 | goto error; | 1021 | goto free_and_error; |
1022 | } | ||
1013 | 1023 | ||
1014 | P9_DPRINTK(P9_DEBUG_9P, "<<< RCREATE qid %x.%llx.%x iounit %x\n", | 1024 | P9_DPRINTK(P9_DEBUG_9P, "<<< RCREATE qid %x.%llx.%x iounit %x\n", |
1015 | qid.type, qid.path, qid.version, iounit); | 1025 | 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 | fid->mode = mode; | 1027 | fid->mode = mode; |
1018 | fid->iounit = iounit; | 1028 | fid->iounit = iounit; |
1019 | 1029 | ||
1030 | free_and_error: | ||
1031 | p9_free_req(clnt, req); | ||
1020 | error: | 1032 | error: |
1021 | return err; | 1033 | return err; |
1022 | } | 1034 | } |
@@ -1103,8 +1115,10 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, | |||
1103 | } | 1115 | } |
1104 | 1116 | ||
1105 | err = p9pdu_readf(req->rc, clnt->dotu, "D", &count, &dataptr); | 1117 | err = p9pdu_readf(req->rc, clnt->dotu, "D", &count, &dataptr); |
1106 | if (err) | 1118 | if (err) { |
1119 | p9pdu_dump(1, req->rc); | ||
1107 | goto free_and_error; | 1120 | goto free_and_error; |
1121 | } | ||
1108 | 1122 | ||
1109 | P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count); | 1123 | P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count); |
1110 | 1124 | ||
@@ -1163,8 +1177,11 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, | |||
1163 | } | 1177 | } |
1164 | 1178 | ||
1165 | err = p9pdu_readf(req->rc, clnt->dotu, "d", &count); | 1179 | err = p9pdu_readf(req->rc, clnt->dotu, "d", &count); |
1166 | if (err) | 1180 | if (err) { |
1181 | p9pdu_dump(1, req->rc); | ||
1167 | goto free_and_error; | 1182 | goto free_and_error; |
1183 | } | ||
1184 | |||
1168 | P9_DPRINTK(P9_DEBUG_9P, "<<< RWRITE count %d\n", count); | 1185 | P9_DPRINTK(P9_DEBUG_9P, "<<< RWRITE count %d\n", count); |
1169 | 1186 | ||
1170 | p9_free_req(clnt, req); | 1187 | p9_free_req(clnt, req); |
@@ -1200,20 +1217,27 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid) | |||
1200 | } | 1217 | } |
1201 | 1218 | ||
1202 | err = p9pdu_readf(req->rc, clnt->dotu, "wS", &ignored, ret); | 1219 | err = p9pdu_readf(req->rc, clnt->dotu, "wS", &ignored, ret); |
1203 | p9_free_req(clnt, req); | 1220 | if (err) { |
1204 | if (err) | 1221 | ret = ERR_PTR(err); |
1205 | goto error; | 1222 | p9pdu_dump(1, req->rc); |
1223 | goto free_and_error; | ||
1224 | } | ||
1206 | 1225 | ||
1207 | P9_DPRINTK(P9_DEBUG_9P, | 1226 | P9_DPRINTK(P9_DEBUG_9P, |
1208 | "<<< RSTAT sz=%x type=%x dev=%x qid=%2.2x %4.4x %8.8llx" | 1227 | "<<< RSTAT sz=%x type=%x dev=%x qid=%x.%llx.%x\n" |
1209 | " mode=%8.8x uid=%d gid=%d size=%lld %s\n", | 1228 | "<<< mode=%8.8x atime=%8.8x mtime=%8.8x length=%llx\n" |
1229 | "<<< name=%s uid=%s gid=%s muid=%s extension=(%s)\n" | ||
1230 | "<<< uid=%d gid=%d n_muid=%d\n", | ||
1210 | ret->size, ret->type, ret->dev, ret->qid.type, | 1231 | ret->size, ret->type, ret->dev, ret->qid.type, |
1211 | ret->qid.version, ret->qid.path, ret->mode, | 1232 | ret->qid.path, ret->qid.version, ret->mode, |
1212 | ret->n_uid, ret->n_gid, ret->length, ret->name); | 1233 | ret->atime, ret->mtime, ret->length, ret->name, |
1234 | ret->uid, ret->gid, ret->muid, ret->extension, | ||
1235 | ret->n_uid, ret->n_gid, ret->n_muid); | ||
1213 | 1236 | ||
1214 | return ret; | 1237 | free_and_error: |
1238 | p9_free_req(clnt, req); | ||
1215 | error: | 1239 | error: |
1216 | return ERR_PTR(err); | 1240 | return ret; |
1217 | } | 1241 | } |
1218 | EXPORT_SYMBOL(p9_client_stat); | 1242 | EXPORT_SYMBOL(p9_client_stat); |
1219 | 1243 | ||
@@ -1224,6 +1248,16 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst) | |||
1224 | struct p9_client *clnt; | 1248 | struct p9_client *clnt; |
1225 | 1249 | ||
1226 | P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid); | 1250 | P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid); |
1251 | P9_DPRINTK(P9_DEBUG_9P, | ||
1252 | " sz=%x type=%x dev=%x qid=%x.%llx.%x\n" | ||
1253 | " mode=%8.8x atime=%8.8x mtime=%8.8x length=%llx\n" | ||
1254 | " name=%s uid=%s gid=%s muid=%s extension=(%s)\n" | ||
1255 | " uid=%d gid=%d n_muid=%d\n", | ||
1256 | wst->size, wst->type, wst->dev, wst->qid.type, | ||
1257 | wst->qid.path, wst->qid.version, wst->mode, | ||
1258 | wst->atime, wst->mtime, wst->length, wst->name, | ||
1259 | wst->uid, wst->gid, wst->muid, wst->extension, | ||
1260 | wst->n_uid, wst->n_gid, wst->n_muid); | ||
1227 | err = 0; | 1261 | err = 0; |
1228 | clnt = fid->clnt; | 1262 | clnt = fid->clnt; |
1229 | 1263 | ||
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 @@ | |||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/errno.h> | 29 | #include <linux/errno.h> |
30 | #include <linux/uaccess.h> | 30 | #include <linux/uaccess.h> |
31 | #include <linux/sched.h> | ||
31 | #include <net/9p/9p.h> | 32 | #include <net/9p/9p.h> |
32 | #include <net/9p/client.h> | 33 | #include <net/9p/client.h> |
33 | #include "protocol.h" | 34 | #include "protocol.h" |
@@ -52,8 +53,6 @@ | |||
52 | static int | 53 | static int |
53 | p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...); | 54 | p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...); |
54 | 55 | ||
55 | #define PACKET_DEBUG 0 | ||
56 | |||
57 | void | 56 | void |
58 | p9pdu_dump(int way, struct p9_fcall *pdu) | 57 | p9pdu_dump(int way, struct p9_fcall *pdu) |
59 | { | 58 | { |
@@ -78,9 +77,9 @@ p9pdu_dump(int way, struct p9_fcall *pdu) | |||
78 | n += scnprintf(buf + n, buflen - n, "\n"); | 77 | n += scnprintf(buf + n, buflen - n, "\n"); |
79 | 78 | ||
80 | if (way) | 79 | if (way) |
81 | printk(KERN_NOTICE "[[(%d)[ %s\n", datalen, buf); | 80 | P9_DPRINTK(P9_DEBUG_PKT, "[[[(%d) %s\n", datalen, buf); |
82 | else | 81 | else |
83 | printk(KERN_NOTICE "]](%d)] %s\n", datalen, buf); | 82 | P9_DPRINTK(P9_DEBUG_PKT, "]]](%d) %s\n", datalen, buf); |
84 | } | 83 | } |
85 | EXPORT_SYMBOL(p9pdu_dump); | 84 | EXPORT_SYMBOL(p9pdu_dump); |
86 | 85 | ||
@@ -512,13 +511,20 @@ p9pdu_writef(struct p9_fcall *pdu, int optional, const char *fmt, ...) | |||
512 | int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu) | 511 | int p9stat_read(char *buf, int len, struct p9_wstat *st, int dotu) |
513 | { | 512 | { |
514 | struct p9_fcall fake_pdu; | 513 | struct p9_fcall fake_pdu; |
514 | int ret; | ||
515 | 515 | ||
516 | fake_pdu.size = len; | 516 | fake_pdu.size = len; |
517 | fake_pdu.capacity = len; | 517 | fake_pdu.capacity = len; |
518 | fake_pdu.sdata = buf; | 518 | fake_pdu.sdata = buf; |
519 | fake_pdu.offset = 0; | 519 | fake_pdu.offset = 0; |
520 | 520 | ||
521 | return p9pdu_readf(&fake_pdu, dotu, "S", st); | 521 | ret = p9pdu_readf(&fake_pdu, dotu, "S", st); |
522 | if (ret) { | ||
523 | P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); | ||
524 | p9pdu_dump(1, &fake_pdu); | ||
525 | } | ||
526 | |||
527 | return ret; | ||
522 | } | 528 | } |
523 | EXPORT_SYMBOL(p9stat_read); | 529 | EXPORT_SYMBOL(p9stat_read); |
524 | 530 | ||
@@ -536,9 +542,12 @@ int p9pdu_finalize(struct p9_fcall *pdu) | |||
536 | err = p9pdu_writef(pdu, 0, "d", size); | 542 | err = p9pdu_writef(pdu, 0, "d", size); |
537 | pdu->size = size; | 543 | pdu->size = size; |
538 | 544 | ||
539 | if (PACKET_DEBUG) | 545 | if ((p9_debug_level & P9_DEBUG_PKT) == P9_DEBUG_PKT) |
540 | p9pdu_dump(0, pdu); | 546 | p9pdu_dump(0, pdu); |
541 | 547 | ||
548 | P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size, | ||
549 | pdu->id, pdu->tag); | ||
550 | |||
542 | return err; | 551 | return err; |
543 | } | 552 | } |
544 | 553 | ||