diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2011-08-06 15:16:59 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2011-10-24 12:13:12 -0400 |
commit | 348b59012e5c6402741d067cf6eeeb6271999d06 (patch) | |
tree | 38041cac7af6f020fa2756eded6a2d9f31132ffc | |
parent | ef6b0807e2c986d5f1cb878e1b32a7cf4c32b4c8 (diff) |
net/9p: Convert net/9p protocol dumps to tracepoints
This helps in more control over debugging.
root@qemu-img-64:~# ls /pass/123
ls: cannot access /pass/123: No such file or directory
root@qemu-img-64:~# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | |
ls-1536 [001] 70.928584: 9p_protocol_dump: clnt 18446612132784021504 P9_TWALK(tag = 1)
000: 16 00 00 00 6e 01 00 01 00 00 00 02 00 00 00 01
010: 00 03 00 31 32 33 00 00 00 ff ff ff ff 00 00 00
ls-1536 [001] 70.928587: <stack trace>
=> trace_9p_protocol_dump
=> p9pdu_finalize
=> p9_client_rpc
=> p9_client_walk
=> v9fs_vfs_lookup
=> d_alloc_and_lookup
=> walk_component
=> path_lookupat
ls-1536 [000] 70.929696: 9p_protocol_dump: clnt 18446612132784021504 P9_RLERROR(tag = 1)
000: 0b 00 00 00 07 01 00 02 00 00 00 4e 03 00 02 00
010: 00 00 00 00 03 00 02 00 00 00 00 00 ff 43 00 00
ls-1536 [000] 70.929697: <stack trace>
=> trace_9p_protocol_dump
=> p9_client_rpc
=> p9_client_walk
=> v9fs_vfs_lookup
=> d_alloc_and_lookup
=> walk_component
=> path_lookupat
=> do_path_lookup
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
-rw-r--r-- | fs/9p/vfs_dir.c | 12 | ||||
-rw-r--r-- | include/net/9p/9p.h | 3 | ||||
-rw-r--r-- | include/net/9p/client.h | 6 | ||||
-rw-r--r-- | include/trace/events/9p.h | 176 | ||||
-rw-r--r-- | net/9p/client.c | 77 | ||||
-rw-r--r-- | net/9p/protocol.c | 53 | ||||
-rw-r--r-- | net/9p/protocol.h | 3 |
7 files changed, 238 insertions, 92 deletions
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index ce6600f33659..598fff1a54e5 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c | |||
@@ -165,9 +165,8 @@ static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
165 | } | 165 | } |
166 | while (rdir->head < rdir->tail) { | 166 | while (rdir->head < rdir->tail) { |
167 | p9stat_init(&st); | 167 | p9stat_init(&st); |
168 | err = p9stat_read(rdir->buf + rdir->head, | 168 | err = p9stat_read(fid->clnt, rdir->buf + rdir->head, |
169 | rdir->tail - rdir->head, &st, | 169 | rdir->tail - rdir->head, &st); |
170 | fid->clnt->proto_version); | ||
171 | if (err) { | 170 | if (err) { |
172 | P9_DPRINTK(P9_DEBUG_VFS, "returned %d\n", err); | 171 | P9_DPRINTK(P9_DEBUG_VFS, "returned %d\n", err); |
173 | err = -EIO; | 172 | err = -EIO; |
@@ -241,10 +240,9 @@ static int v9fs_dir_readdir_dotl(struct file *filp, void *dirent, | |||
241 | 240 | ||
242 | while (rdir->head < rdir->tail) { | 241 | while (rdir->head < rdir->tail) { |
243 | 242 | ||
244 | err = p9dirent_read(rdir->buf + rdir->head, | 243 | err = p9dirent_read(fid->clnt, rdir->buf + rdir->head, |
245 | rdir->tail - rdir->head, | 244 | rdir->tail - rdir->head, |
246 | &curdirent, | 245 | &curdirent); |
247 | fid->clnt->proto_version); | ||
248 | if (err < 0) { | 246 | if (err < 0) { |
249 | P9_DPRINTK(P9_DEBUG_VFS, "returned %d\n", err); | 247 | P9_DPRINTK(P9_DEBUG_VFS, "returned %d\n", err); |
250 | err = -EIO; | 248 | err = -EIO; |
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index d83a01300871..2d70b95b3b55 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h | |||
@@ -76,11 +76,8 @@ do { \ | |||
76 | } \ | 76 | } \ |
77 | } while (0) | 77 | } while (0) |
78 | 78 | ||
79 | #define P9_DUMP_PKT(way, pdu) p9pdu_dump(way, pdu) | ||
80 | |||
81 | #else | 79 | #else |
82 | #define P9_DPRINTK(level, format, arg...) do { } while (0) | 80 | #define P9_DPRINTK(level, format, arg...) do { } while (0) |
83 | #define P9_DUMP_PKT(way, pdu) do { } while (0) | ||
84 | #endif | 81 | #endif |
85 | 82 | ||
86 | 83 | ||
diff --git a/include/net/9p/client.h b/include/net/9p/client.h index d479d7dcc4d5..fc9b90b0c052 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h | |||
@@ -240,8 +240,8 @@ int p9_client_read(struct p9_fid *fid, char *data, char __user *udata, | |||
240 | int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, | 240 | int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, |
241 | u64 offset, u32 count); | 241 | u64 offset, u32 count); |
242 | int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset); | 242 | int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset); |
243 | int p9dirent_read(char *buf, int len, struct p9_dirent *dirent, | 243 | int p9dirent_read(struct p9_client *clnt, char *buf, int len, |
244 | int proto_version); | 244 | struct p9_dirent *dirent); |
245 | struct p9_wstat *p9_client_stat(struct p9_fid *fid); | 245 | struct p9_wstat *p9_client_stat(struct p9_fid *fid); |
246 | int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst); | 246 | int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst); |
247 | int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *attr); | 247 | int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *attr); |
@@ -259,7 +259,7 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *, u16); | |||
259 | void p9_client_cb(struct p9_client *c, struct p9_req_t *req); | 259 | void p9_client_cb(struct p9_client *c, struct p9_req_t *req); |
260 | 260 | ||
261 | int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int); | 261 | int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int); |
262 | int p9stat_read(char *, int, struct p9_wstat *, int); | 262 | int p9stat_read(struct p9_client *, char *, int, struct p9_wstat *); |
263 | void p9stat_free(struct p9_wstat *); | 263 | void p9stat_free(struct p9_wstat *); |
264 | 264 | ||
265 | int p9_is_proto_dotu(struct p9_client *clnt); | 265 | int p9_is_proto_dotu(struct p9_client *clnt); |
diff --git a/include/trace/events/9p.h b/include/trace/events/9p.h new file mode 100644 index 000000000000..beeaed8398ec --- /dev/null +++ b/include/trace/events/9p.h | |||
@@ -0,0 +1,176 @@ | |||
1 | #undef TRACE_SYSTEM | ||
2 | #define TRACE_SYSTEM 9p | ||
3 | |||
4 | #if !defined(_TRACE_9P_H) || defined(TRACE_HEADER_MULTI_READ) | ||
5 | #define _TRACE_9P_H | ||
6 | |||
7 | #include <linux/tracepoint.h> | ||
8 | |||
9 | #define show_9p_op(type) \ | ||
10 | __print_symbolic(type, \ | ||
11 | { P9_TLERROR, "P9_TLERROR" }, \ | ||
12 | { P9_RLERROR, "P9_RLERROR" }, \ | ||
13 | { P9_TSTATFS, "P9_TSTATFS" }, \ | ||
14 | { P9_RSTATFS, "P9_RSTATFS" }, \ | ||
15 | { P9_TLOPEN, "P9_TLOPEN" }, \ | ||
16 | { P9_RLOPEN, "P9_RLOPEN" }, \ | ||
17 | { P9_TLCREATE, "P9_TLCREATE" }, \ | ||
18 | { P9_RLCREATE, "P9_RLCREATE" }, \ | ||
19 | { P9_TSYMLINK, "P9_TSYMLINK" }, \ | ||
20 | { P9_RSYMLINK, "P9_RSYMLINK" }, \ | ||
21 | { P9_TMKNOD, "P9_TMKNOD" }, \ | ||
22 | { P9_RMKNOD, "P9_RMKNOD" }, \ | ||
23 | { P9_TRENAME, "P9_TRENAME" }, \ | ||
24 | { P9_RRENAME, "P9_RRENAME" }, \ | ||
25 | { P9_TREADLINK, "P9_TREADLINK" }, \ | ||
26 | { P9_RREADLINK, "P9_RREADLINK" }, \ | ||
27 | { P9_TGETATTR, "P9_TGETATTR" }, \ | ||
28 | { P9_RGETATTR, "P9_RGETATTR" }, \ | ||
29 | { P9_TSETATTR, "P9_TSETATTR" }, \ | ||
30 | { P9_RSETATTR, "P9_RSETATTR" }, \ | ||
31 | { P9_TXATTRWALK, "P9_TXATTRWALK" }, \ | ||
32 | { P9_RXATTRWALK, "P9_RXATTRWALK" }, \ | ||
33 | { P9_TXATTRCREATE, "P9_TXATTRCREATE" }, \ | ||
34 | { P9_RXATTRCREATE, "P9_RXATTRCREATE" }, \ | ||
35 | { P9_TREADDIR, "P9_TREADDIR" }, \ | ||
36 | { P9_RREADDIR, "P9_RREADDIR" }, \ | ||
37 | { P9_TFSYNC, "P9_TFSYNC" }, \ | ||
38 | { P9_RFSYNC, "P9_RFSYNC" }, \ | ||
39 | { P9_TLOCK, "P9_TLOCK" }, \ | ||
40 | { P9_RLOCK, "P9_RLOCK" }, \ | ||
41 | { P9_TGETLOCK, "P9_TGETLOCK" }, \ | ||
42 | { P9_RGETLOCK, "P9_RGETLOCK" }, \ | ||
43 | { P9_TLINK, "P9_TLINK" }, \ | ||
44 | { P9_RLINK, "P9_RLINK" }, \ | ||
45 | { P9_TMKDIR, "P9_TMKDIR" }, \ | ||
46 | { P9_RMKDIR, "P9_RMKDIR" }, \ | ||
47 | { P9_TRENAMEAT, "P9_TRENAMEAT" }, \ | ||
48 | { P9_RRENAMEAT, "P9_RRENAMEAT" }, \ | ||
49 | { P9_TUNLINKAT, "P9_TUNLINKAT" }, \ | ||
50 | { P9_RUNLINKAT, "P9_RUNLINKAT" }, \ | ||
51 | { P9_TVERSION, "P9_TVERSION" }, \ | ||
52 | { P9_RVERSION, "P9_RVERSION" }, \ | ||
53 | { P9_TAUTH, "P9_TAUTH" }, \ | ||
54 | { P9_RAUTH, "P9_RAUTH" }, \ | ||
55 | { P9_TATTACH, "P9_TATTACH" }, \ | ||
56 | { P9_RATTACH, "P9_RATTACH" }, \ | ||
57 | { P9_TERROR, "P9_TERROR" }, \ | ||
58 | { P9_RERROR, "P9_RERROR" }, \ | ||
59 | { P9_TFLUSH, "P9_TFLUSH" }, \ | ||
60 | { P9_RFLUSH, "P9_RFLUSH" }, \ | ||
61 | { P9_TWALK, "P9_TWALK" }, \ | ||
62 | { P9_RWALK, "P9_RWALK" }, \ | ||
63 | { P9_TOPEN, "P9_TOPEN" }, \ | ||
64 | { P9_ROPEN, "P9_ROPEN" }, \ | ||
65 | { P9_TCREATE, "P9_TCREATE" }, \ | ||
66 | { P9_RCREATE, "P9_RCREATE" }, \ | ||
67 | { P9_TREAD, "P9_TREAD" }, \ | ||
68 | { P9_RREAD, "P9_RREAD" }, \ | ||
69 | { P9_TWRITE, "P9_TWRITE" }, \ | ||
70 | { P9_RWRITE, "P9_RWRITE" }, \ | ||
71 | { P9_TCLUNK, "P9_TCLUNK" }, \ | ||
72 | { P9_RCLUNK, "P9_RCLUNK" }, \ | ||
73 | { P9_TREMOVE, "P9_TREMOVE" }, \ | ||
74 | { P9_RREMOVE, "P9_RREMOVE" }, \ | ||
75 | { P9_TSTAT, "P9_TSTAT" }, \ | ||
76 | { P9_RSTAT, "P9_RSTAT" }, \ | ||
77 | { P9_TWSTAT, "P9_TWSTAT" }, \ | ||
78 | { P9_RWSTAT, "P9_RWSTAT" }) | ||
79 | |||
80 | TRACE_EVENT(9p_client_req, | ||
81 | TP_PROTO(struct p9_client *clnt, int8_t type, int tag), | ||
82 | |||
83 | TP_ARGS(clnt, type, tag), | ||
84 | |||
85 | TP_STRUCT__entry( | ||
86 | __field( void *, clnt ) | ||
87 | __field( __u8, type ) | ||
88 | __field( __u32, tag ) | ||
89 | ), | ||
90 | |||
91 | TP_fast_assign( | ||
92 | __entry->clnt = clnt; | ||
93 | __entry->type = type; | ||
94 | __entry->tag = tag; | ||
95 | ), | ||
96 | |||
97 | TP_printk("client %lu request %s tag %d", | ||
98 | (long)__entry->clnt, show_9p_op(__entry->type), | ||
99 | __entry->tag) | ||
100 | ); | ||
101 | |||
102 | TRACE_EVENT(9p_client_res, | ||
103 | TP_PROTO(struct p9_client *clnt, int8_t type, int tag, int err), | ||
104 | |||
105 | TP_ARGS(clnt, type, tag, err), | ||
106 | |||
107 | TP_STRUCT__entry( | ||
108 | __field( void *, clnt ) | ||
109 | __field( __u8, type ) | ||
110 | __field( __u32, tag ) | ||
111 | __field( __u32, err ) | ||
112 | ), | ||
113 | |||
114 | TP_fast_assign( | ||
115 | __entry->clnt = clnt; | ||
116 | __entry->type = type; | ||
117 | __entry->tag = tag; | ||
118 | __entry->err = err; | ||
119 | ), | ||
120 | |||
121 | TP_printk("client %lu response %s tag %d err %d", | ||
122 | (long)__entry->clnt, show_9p_op(__entry->type), | ||
123 | __entry->tag, __entry->err) | ||
124 | ); | ||
125 | |||
126 | /* dump 32 bytes of protocol data */ | ||
127 | #define P9_PROTO_DUMP_SZ 32 | ||
128 | TRACE_EVENT(9p_protocol_dump, | ||
129 | TP_PROTO(struct p9_client *clnt, struct p9_fcall *pdu), | ||
130 | |||
131 | TP_ARGS(clnt, pdu), | ||
132 | |||
133 | TP_STRUCT__entry( | ||
134 | __field( void *, clnt ) | ||
135 | __field( __u8, type ) | ||
136 | __field( __u16, tag ) | ||
137 | __array( unsigned char, line, P9_PROTO_DUMP_SZ ) | ||
138 | ), | ||
139 | |||
140 | TP_fast_assign( | ||
141 | __entry->clnt = clnt; | ||
142 | __entry->type = pdu->id; | ||
143 | __entry->tag = pdu->tag; | ||
144 | memcpy(__entry->line, pdu->sdata, P9_PROTO_DUMP_SZ); | ||
145 | ), | ||
146 | TP_printk("clnt %lu %s(tag = %d)\n%.3x: " | ||
147 | "%02x %02x %02x %02x %02x %02x %02x %02x " | ||
148 | "%02x %02x %02x %02x %02x %02x %02x %02x\n" | ||
149 | "%.3x: " | ||
150 | "%02x %02x %02x %02x %02x %02x %02x %02x " | ||
151 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
152 | (long)__entry->clnt, show_9p_op(__entry->type), | ||
153 | __entry->tag, 0, | ||
154 | __entry->line[0], __entry->line[1], | ||
155 | __entry->line[2], __entry->line[3], | ||
156 | __entry->line[4], __entry->line[5], | ||
157 | __entry->line[6], __entry->line[7], | ||
158 | __entry->line[8], __entry->line[9], | ||
159 | __entry->line[10], __entry->line[11], | ||
160 | __entry->line[12], __entry->line[13], | ||
161 | __entry->line[14], __entry->line[15], | ||
162 | 16, | ||
163 | __entry->line[16], __entry->line[17], | ||
164 | __entry->line[18], __entry->line[19], | ||
165 | __entry->line[20], __entry->line[21], | ||
166 | __entry->line[22], __entry->line[23], | ||
167 | __entry->line[24], __entry->line[25], | ||
168 | __entry->line[26], __entry->line[27], | ||
169 | __entry->line[28], __entry->line[29], | ||
170 | __entry->line[30], __entry->line[31]) | ||
171 | ); | ||
172 | |||
173 | #endif /* _TRACE_9P_H */ | ||
174 | |||
175 | /* This part must be outside protection */ | ||
176 | #include <trace/define_trace.h> | ||
diff --git a/net/9p/client.c b/net/9p/client.c index b1c02187f862..854ca7a911c4 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -38,6 +38,9 @@ | |||
38 | #include <net/9p/transport.h> | 38 | #include <net/9p/transport.h> |
39 | #include "protocol.h" | 39 | #include "protocol.h" |
40 | 40 | ||
41 | #define CREATE_TRACE_POINTS | ||
42 | #include <trace/events/9p.h> | ||
43 | |||
41 | /* | 44 | /* |
42 | * Client Option Parsing (code inspired by NFS code) | 45 | * Client Option Parsing (code inspired by NFS code) |
43 | * - a little lazy - parse all client options | 46 | * - a little lazy - parse all client options |
@@ -464,11 +467,15 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req) | |||
464 | int ecode; | 467 | int ecode; |
465 | 468 | ||
466 | err = p9_parse_header(req->rc, NULL, &type, NULL, 0); | 469 | err = p9_parse_header(req->rc, NULL, &type, NULL, 0); |
470 | /* | ||
471 | * dump the response from server | ||
472 | * This should be after check errors which poplulate pdu_fcall. | ||
473 | */ | ||
474 | trace_9p_protocol_dump(c, req->rc); | ||
467 | if (err) { | 475 | if (err) { |
468 | P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse header %d\n", err); | 476 | P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse header %d\n", err); |
469 | return err; | 477 | return err; |
470 | } | 478 | } |
471 | |||
472 | if (type != P9_RERROR && type != P9_RLERROR) | 479 | if (type != P9_RERROR && type != P9_RLERROR) |
473 | return 0; | 480 | return 0; |
474 | 481 | ||
@@ -525,6 +532,11 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req, | |||
525 | char *ename = NULL; | 532 | char *ename = NULL; |
526 | 533 | ||
527 | err = p9_parse_header(req->rc, NULL, &type, NULL, 0); | 534 | err = p9_parse_header(req->rc, NULL, &type, NULL, 0); |
535 | /* | ||
536 | * dump the response from server | ||
537 | * This should be after parse_header which poplulate pdu_fcall. | ||
538 | */ | ||
539 | trace_9p_protocol_dump(c, req->rc); | ||
528 | if (err) { | 540 | if (err) { |
529 | P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse header %d\n", err); | 541 | P9_DPRINTK(P9_DEBUG_ERROR, "couldn't parse header %d\n", err); |
530 | return err; | 542 | return err; |
@@ -684,7 +696,8 @@ static struct p9_req_t *p9_client_prepare_req(struct p9_client *c, | |||
684 | err = p9pdu_vwritef(req->tc, c->proto_version, fmt, ap); | 696 | err = p9pdu_vwritef(req->tc, c->proto_version, fmt, ap); |
685 | if (err) | 697 | if (err) |
686 | goto reterr; | 698 | goto reterr; |
687 | p9pdu_finalize(req->tc); | 699 | p9pdu_finalize(c, req->tc); |
700 | trace_9p_client_req(c, type, tag); | ||
688 | return req; | 701 | return req; |
689 | reterr: | 702 | reterr: |
690 | p9_free_req(c, req); | 703 | p9_free_req(c, req); |
@@ -755,13 +768,10 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) | |||
755 | goto reterr; | 768 | goto reterr; |
756 | 769 | ||
757 | err = p9_check_errors(c, req); | 770 | err = p9_check_errors(c, req); |
758 | if (!err) { | 771 | trace_9p_client_res(c, type, req->rc->tag, err); |
759 | P9_DPRINTK(P9_DEBUG_MUX, "exit: client %p op %d\n", c, type); | 772 | if (!err) |
760 | return req; | 773 | return req; |
761 | } | ||
762 | reterr: | 774 | reterr: |
763 | P9_DPRINTK(P9_DEBUG_MUX, | ||
764 | "exit: client %p op %d error: %d\n", c, type, err); | ||
765 | p9_free_req(c, req); | 775 | p9_free_req(c, req); |
766 | return ERR_PTR(err); | 776 | return ERR_PTR(err); |
767 | } | 777 | } |
@@ -841,13 +851,10 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type, | |||
841 | goto reterr; | 851 | goto reterr; |
842 | 852 | ||
843 | err = p9_check_zc_errors(c, req, uidata, in_hdrlen, kern_buf); | 853 | err = p9_check_zc_errors(c, req, uidata, in_hdrlen, kern_buf); |
844 | if (!err) { | 854 | trace_9p_client_res(c, type, req->rc->tag, err); |
845 | P9_DPRINTK(P9_DEBUG_MUX, "exit: client %p op %d\n", c, type); | 855 | if (!err) |
846 | return req; | 856 | return req; |
847 | } | ||
848 | reterr: | 857 | reterr: |
849 | P9_DPRINTK(P9_DEBUG_MUX, "exit: client %p op %d error: %d\n", c, type, | ||
850 | err); | ||
851 | p9_free_req(c, req); | 858 | p9_free_req(c, req); |
852 | return ERR_PTR(err); | 859 | return ERR_PTR(err); |
853 | } | 860 | } |
@@ -935,7 +942,7 @@ static int p9_client_version(struct p9_client *c) | |||
935 | err = p9pdu_readf(req->rc, c->proto_version, "ds", &msize, &version); | 942 | err = p9pdu_readf(req->rc, c->proto_version, "ds", &msize, &version); |
936 | if (err) { | 943 | if (err) { |
937 | P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); | 944 | P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); |
938 | P9_DUMP_PKT(1, req->rc); | 945 | trace_9p_protocol_dump(c, req->rc); |
939 | goto error; | 946 | goto error; |
940 | } | 947 | } |
941 | 948 | ||
@@ -1072,15 +1079,14 @@ EXPORT_SYMBOL(p9_client_begin_disconnect); | |||
1072 | struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, | 1079 | struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, |
1073 | char *uname, u32 n_uname, char *aname) | 1080 | char *uname, u32 n_uname, char *aname) |
1074 | { | 1081 | { |
1075 | int err; | 1082 | int err = 0; |
1076 | struct p9_req_t *req; | 1083 | struct p9_req_t *req; |
1077 | struct p9_fid *fid; | 1084 | struct p9_fid *fid; |
1078 | struct p9_qid qid; | 1085 | struct p9_qid qid; |
1079 | 1086 | ||
1080 | P9_DPRINTK(P9_DEBUG_9P, ">>> TATTACH afid %d uname %s aname %s\n", | ||
1081 | afid ? afid->fid : -1, uname, aname); | ||
1082 | err = 0; | ||
1083 | 1087 | ||
1088 | P9_DPRINTK(P9_DEBUG_9P, ">>> TATTACH afid %d uname %s aname %s\n", | ||
1089 | afid ? afid->fid : -1, uname, aname); | ||
1084 | fid = p9_fid_create(clnt); | 1090 | fid = p9_fid_create(clnt); |
1085 | if (IS_ERR(fid)) { | 1091 | if (IS_ERR(fid)) { |
1086 | err = PTR_ERR(fid); | 1092 | err = PTR_ERR(fid); |
@@ -1097,7 +1103,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, | |||
1097 | 1103 | ||
1098 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid); | 1104 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid); |
1099 | if (err) { | 1105 | if (err) { |
1100 | P9_DUMP_PKT(1, req->rc); | 1106 | trace_9p_protocol_dump(clnt, req->rc); |
1101 | p9_free_req(clnt, req); | 1107 | p9_free_req(clnt, req); |
1102 | goto error; | 1108 | goto error; |
1103 | } | 1109 | } |
@@ -1157,7 +1163,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname, | |||
1157 | 1163 | ||
1158 | err = p9pdu_readf(req->rc, clnt->proto_version, "R", &nwqids, &wqids); | 1164 | err = p9pdu_readf(req->rc, clnt->proto_version, "R", &nwqids, &wqids); |
1159 | if (err) { | 1165 | if (err) { |
1160 | P9_DUMP_PKT(1, req->rc); | 1166 | trace_9p_protocol_dump(clnt, req->rc); |
1161 | p9_free_req(clnt, req); | 1167 | p9_free_req(clnt, req); |
1162 | goto clunk_fid; | 1168 | goto clunk_fid; |
1163 | } | 1169 | } |
@@ -1224,7 +1230,7 @@ int p9_client_open(struct p9_fid *fid, int mode) | |||
1224 | 1230 | ||
1225 | err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); | 1231 | err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); |
1226 | if (err) { | 1232 | if (err) { |
1227 | P9_DUMP_PKT(1, req->rc); | 1233 | trace_9p_protocol_dump(clnt, req->rc); |
1228 | goto free_and_error; | 1234 | goto free_and_error; |
1229 | } | 1235 | } |
1230 | 1236 | ||
@@ -1267,7 +1273,7 @@ int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode, | |||
1267 | 1273 | ||
1268 | err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", qid, &iounit); | 1274 | err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", qid, &iounit); |
1269 | if (err) { | 1275 | if (err) { |
1270 | P9_DUMP_PKT(1, req->rc); | 1276 | trace_9p_protocol_dump(clnt, req->rc); |
1271 | goto free_and_error; | 1277 | goto free_and_error; |
1272 | } | 1278 | } |
1273 | 1279 | ||
@@ -1312,7 +1318,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, | |||
1312 | 1318 | ||
1313 | err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); | 1319 | err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); |
1314 | if (err) { | 1320 | if (err) { |
1315 | P9_DUMP_PKT(1, req->rc); | 1321 | trace_9p_protocol_dump(clnt, req->rc); |
1316 | goto free_and_error; | 1322 | goto free_and_error; |
1317 | } | 1323 | } |
1318 | 1324 | ||
@@ -1351,7 +1357,7 @@ int p9_client_symlink(struct p9_fid *dfid, char *name, char *symtgt, gid_t gid, | |||
1351 | 1357 | ||
1352 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); | 1358 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); |
1353 | if (err) { | 1359 | if (err) { |
1354 | P9_DUMP_PKT(1, req->rc); | 1360 | trace_9p_protocol_dump(clnt, req->rc); |
1355 | goto free_and_error; | 1361 | goto free_and_error; |
1356 | } | 1362 | } |
1357 | 1363 | ||
@@ -1542,12 +1548,11 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, | |||
1542 | 1548 | ||
1543 | err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); | 1549 | err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); |
1544 | if (err) { | 1550 | if (err) { |
1545 | P9_DUMP_PKT(1, req->rc); | 1551 | trace_9p_protocol_dump(clnt, req->rc); |
1546 | goto free_and_error; | 1552 | goto free_and_error; |
1547 | } | 1553 | } |
1548 | 1554 | ||
1549 | P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count); | 1555 | P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count); |
1550 | P9_DUMP_PKT(1, req->rc); | ||
1551 | 1556 | ||
1552 | if (non_zc) { | 1557 | if (non_zc) { |
1553 | if (data) { | 1558 | if (data) { |
@@ -1617,7 +1622,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, | |||
1617 | 1622 | ||
1618 | err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count); | 1623 | err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count); |
1619 | if (err) { | 1624 | if (err) { |
1620 | P9_DUMP_PKT(1, req->rc); | 1625 | trace_9p_protocol_dump(clnt, req->rc); |
1621 | goto free_and_error; | 1626 | goto free_and_error; |
1622 | } | 1627 | } |
1623 | 1628 | ||
@@ -1657,7 +1662,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid) | |||
1657 | 1662 | ||
1658 | err = p9pdu_readf(req->rc, clnt->proto_version, "wS", &ignored, ret); | 1663 | err = p9pdu_readf(req->rc, clnt->proto_version, "wS", &ignored, ret); |
1659 | if (err) { | 1664 | if (err) { |
1660 | P9_DUMP_PKT(1, req->rc); | 1665 | trace_9p_protocol_dump(clnt, req->rc); |
1661 | p9_free_req(clnt, req); | 1666 | p9_free_req(clnt, req); |
1662 | goto error; | 1667 | goto error; |
1663 | } | 1668 | } |
@@ -1708,7 +1713,7 @@ struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid, | |||
1708 | 1713 | ||
1709 | err = p9pdu_readf(req->rc, clnt->proto_version, "A", ret); | 1714 | err = p9pdu_readf(req->rc, clnt->proto_version, "A", ret); |
1710 | if (err) { | 1715 | if (err) { |
1711 | P9_DUMP_PKT(1, req->rc); | 1716 | trace_9p_protocol_dump(clnt, req->rc); |
1712 | p9_free_req(clnt, req); | 1717 | p9_free_req(clnt, req); |
1713 | goto error; | 1718 | goto error; |
1714 | } | 1719 | } |
@@ -1856,7 +1861,7 @@ int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb) | |||
1856 | &sb->bsize, &sb->blocks, &sb->bfree, &sb->bavail, | 1861 | &sb->bsize, &sb->blocks, &sb->bfree, &sb->bavail, |
1857 | &sb->files, &sb->ffree, &sb->fsid, &sb->namelen); | 1862 | &sb->files, &sb->ffree, &sb->fsid, &sb->namelen); |
1858 | if (err) { | 1863 | if (err) { |
1859 | P9_DUMP_PKT(1, req->rc); | 1864 | trace_9p_protocol_dump(clnt, req->rc); |
1860 | p9_free_req(clnt, req); | 1865 | p9_free_req(clnt, req); |
1861 | goto error; | 1866 | goto error; |
1862 | } | 1867 | } |
@@ -1963,7 +1968,7 @@ struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid, | |||
1963 | } | 1968 | } |
1964 | err = p9pdu_readf(req->rc, clnt->proto_version, "q", attr_size); | 1969 | err = p9pdu_readf(req->rc, clnt->proto_version, "q", attr_size); |
1965 | if (err) { | 1970 | if (err) { |
1966 | P9_DUMP_PKT(1, req->rc); | 1971 | trace_9p_protocol_dump(clnt, req->rc); |
1967 | p9_free_req(clnt, req); | 1972 | p9_free_req(clnt, req); |
1968 | goto clunk_fid; | 1973 | goto clunk_fid; |
1969 | } | 1974 | } |
@@ -2047,7 +2052,7 @@ int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset) | |||
2047 | 2052 | ||
2048 | err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); | 2053 | err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); |
2049 | if (err) { | 2054 | if (err) { |
2050 | P9_DUMP_PKT(1, req->rc); | 2055 | trace_9p_protocol_dump(clnt, req->rc); |
2051 | goto free_and_error; | 2056 | goto free_and_error; |
2052 | } | 2057 | } |
2053 | 2058 | ||
@@ -2084,7 +2089,7 @@ int p9_client_mknod_dotl(struct p9_fid *fid, char *name, int mode, | |||
2084 | 2089 | ||
2085 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); | 2090 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); |
2086 | if (err) { | 2091 | if (err) { |
2087 | P9_DUMP_PKT(1, req->rc); | 2092 | trace_9p_protocol_dump(clnt, req->rc); |
2088 | goto error; | 2093 | goto error; |
2089 | } | 2094 | } |
2090 | P9_DPRINTK(P9_DEBUG_9P, "<<< RMKNOD qid %x.%llx.%x\n", qid->type, | 2095 | P9_DPRINTK(P9_DEBUG_9P, "<<< RMKNOD qid %x.%llx.%x\n", qid->type, |
@@ -2115,7 +2120,7 @@ int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode, | |||
2115 | 2120 | ||
2116 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); | 2121 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); |
2117 | if (err) { | 2122 | if (err) { |
2118 | P9_DUMP_PKT(1, req->rc); | 2123 | trace_9p_protocol_dump(clnt, req->rc); |
2119 | goto error; | 2124 | goto error; |
2120 | } | 2125 | } |
2121 | P9_DPRINTK(P9_DEBUG_9P, "<<< RMKDIR qid %x.%llx.%x\n", qid->type, | 2126 | P9_DPRINTK(P9_DEBUG_9P, "<<< RMKDIR qid %x.%llx.%x\n", qid->type, |
@@ -2150,7 +2155,7 @@ int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status) | |||
2150 | 2155 | ||
2151 | err = p9pdu_readf(req->rc, clnt->proto_version, "b", status); | 2156 | err = p9pdu_readf(req->rc, clnt->proto_version, "b", status); |
2152 | if (err) { | 2157 | if (err) { |
2153 | P9_DUMP_PKT(1, req->rc); | 2158 | trace_9p_protocol_dump(clnt, req->rc); |
2154 | goto error; | 2159 | goto error; |
2155 | } | 2160 | } |
2156 | P9_DPRINTK(P9_DEBUG_9P, "<<< RLOCK status %i\n", *status); | 2161 | P9_DPRINTK(P9_DEBUG_9P, "<<< RLOCK status %i\n", *status); |
@@ -2183,7 +2188,7 @@ int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *glock) | |||
2183 | &glock->start, &glock->length, &glock->proc_id, | 2188 | &glock->start, &glock->length, &glock->proc_id, |
2184 | &glock->client_id); | 2189 | &glock->client_id); |
2185 | if (err) { | 2190 | if (err) { |
2186 | P9_DUMP_PKT(1, req->rc); | 2191 | trace_9p_protocol_dump(clnt, req->rc); |
2187 | goto error; | 2192 | goto error; |
2188 | } | 2193 | } |
2189 | P9_DPRINTK(P9_DEBUG_9P, "<<< RGETLOCK type %i start %lld length %lld " | 2194 | P9_DPRINTK(P9_DEBUG_9P, "<<< RGETLOCK type %i start %lld length %lld " |
@@ -2211,7 +2216,7 @@ int p9_client_readlink(struct p9_fid *fid, char **target) | |||
2211 | 2216 | ||
2212 | err = p9pdu_readf(req->rc, clnt->proto_version, "s", target); | 2217 | err = p9pdu_readf(req->rc, clnt->proto_version, "s", target); |
2213 | if (err) { | 2218 | if (err) { |
2214 | P9_DUMP_PKT(1, req->rc); | 2219 | trace_9p_protocol_dump(clnt, req->rc); |
2215 | goto error; | 2220 | goto error; |
2216 | } | 2221 | } |
2217 | P9_DPRINTK(P9_DEBUG_9P, "<<< RREADLINK target %s\n", *target); | 2222 | P9_DPRINTK(P9_DEBUG_9P, "<<< RREADLINK target %s\n", *target); |
diff --git a/net/9p/protocol.c b/net/9p/protocol.c index b7d4e8aa5383..55e10a96c902 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c | |||
@@ -37,40 +37,11 @@ | |||
37 | #include <net/9p/client.h> | 37 | #include <net/9p/client.h> |
38 | #include "protocol.h" | 38 | #include "protocol.h" |
39 | 39 | ||
40 | #include <trace/events/9p.h> | ||
41 | |||
40 | static int | 42 | static int |
41 | p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...); | 43 | p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...); |
42 | 44 | ||
43 | #ifdef CONFIG_NET_9P_DEBUG | ||
44 | void | ||
45 | p9pdu_dump(int way, struct p9_fcall *pdu) | ||
46 | { | ||
47 | int len = pdu->size; | ||
48 | |||
49 | if ((p9_debug_level & P9_DEBUG_VPKT) != P9_DEBUG_VPKT) { | ||
50 | if ((p9_debug_level & P9_DEBUG_PKT) == P9_DEBUG_PKT) { | ||
51 | if (len > 32) | ||
52 | len = 32; | ||
53 | } else { | ||
54 | /* shouldn't happen */ | ||
55 | return; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | if (way) | ||
60 | print_hex_dump_bytes("[9P] ", DUMP_PREFIX_OFFSET, pdu->sdata, | ||
61 | len); | ||
62 | else | ||
63 | print_hex_dump_bytes("]9P[ ", DUMP_PREFIX_OFFSET, pdu->sdata, | ||
64 | len); | ||
65 | } | ||
66 | #else | ||
67 | void | ||
68 | p9pdu_dump(int way, struct p9_fcall *pdu) | ||
69 | { | ||
70 | } | ||
71 | #endif | ||
72 | EXPORT_SYMBOL(p9pdu_dump); | ||
73 | |||
74 | void p9stat_free(struct p9_wstat *stbuf) | 45 | void p9stat_free(struct p9_wstat *stbuf) |
75 | { | 46 | { |
76 | kfree(stbuf->name); | 47 | kfree(stbuf->name); |
@@ -551,7 +522,7 @@ p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...) | |||
551 | return ret; | 522 | return ret; |
552 | } | 523 | } |
553 | 524 | ||
554 | int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version) | 525 | int p9stat_read(struct p9_client *clnt, char *buf, int len, struct p9_wstat *st) |
555 | { | 526 | { |
556 | struct p9_fcall fake_pdu; | 527 | struct p9_fcall fake_pdu; |
557 | int ret; | 528 | int ret; |
@@ -561,10 +532,10 @@ int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version) | |||
561 | fake_pdu.sdata = buf; | 532 | fake_pdu.sdata = buf; |
562 | fake_pdu.offset = 0; | 533 | fake_pdu.offset = 0; |
563 | 534 | ||
564 | ret = p9pdu_readf(&fake_pdu, proto_version, "S", st); | 535 | ret = p9pdu_readf(&fake_pdu, clnt->proto_version, "S", st); |
565 | if (ret) { | 536 | if (ret) { |
566 | P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); | 537 | P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); |
567 | P9_DUMP_PKT(0, &fake_pdu); | 538 | trace_9p_protocol_dump(clnt, &fake_pdu); |
568 | } | 539 | } |
569 | 540 | ||
570 | return ret; | 541 | return ret; |
@@ -577,7 +548,7 @@ int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type) | |||
577 | return p9pdu_writef(pdu, 0, "dbw", 0, type, tag); | 548 | return p9pdu_writef(pdu, 0, "dbw", 0, type, tag); |
578 | } | 549 | } |
579 | 550 | ||
580 | int p9pdu_finalize(struct p9_fcall *pdu) | 551 | int p9pdu_finalize(struct p9_client *clnt, struct p9_fcall *pdu) |
581 | { | 552 | { |
582 | int size = pdu->size; | 553 | int size = pdu->size; |
583 | int err; | 554 | int err; |
@@ -586,7 +557,7 @@ int p9pdu_finalize(struct p9_fcall *pdu) | |||
586 | err = p9pdu_writef(pdu, 0, "d", size); | 557 | err = p9pdu_writef(pdu, 0, "d", size); |
587 | pdu->size = size; | 558 | pdu->size = size; |
588 | 559 | ||
589 | P9_DUMP_PKT(0, pdu); | 560 | trace_9p_protocol_dump(clnt, pdu); |
590 | P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size, | 561 | P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size, |
591 | pdu->id, pdu->tag); | 562 | pdu->id, pdu->tag); |
592 | 563 | ||
@@ -599,8 +570,8 @@ void p9pdu_reset(struct p9_fcall *pdu) | |||
599 | pdu->size = 0; | 570 | pdu->size = 0; |
600 | } | 571 | } |
601 | 572 | ||
602 | int p9dirent_read(char *buf, int len, struct p9_dirent *dirent, | 573 | int p9dirent_read(struct p9_client *clnt, char *buf, int len, |
603 | int proto_version) | 574 | struct p9_dirent *dirent) |
604 | { | 575 | { |
605 | struct p9_fcall fake_pdu; | 576 | struct p9_fcall fake_pdu; |
606 | int ret; | 577 | int ret; |
@@ -611,11 +582,11 @@ int p9dirent_read(char *buf, int len, struct p9_dirent *dirent, | |||
611 | fake_pdu.sdata = buf; | 582 | fake_pdu.sdata = buf; |
612 | fake_pdu.offset = 0; | 583 | fake_pdu.offset = 0; |
613 | 584 | ||
614 | ret = p9pdu_readf(&fake_pdu, proto_version, "Qqbs", &dirent->qid, | 585 | ret = p9pdu_readf(&fake_pdu, clnt->proto_version, "Qqbs", &dirent->qid, |
615 | &dirent->d_off, &dirent->d_type, &nameptr); | 586 | &dirent->d_off, &dirent->d_type, &nameptr); |
616 | if (ret) { | 587 | if (ret) { |
617 | P9_DPRINTK(P9_DEBUG_9P, "<<< p9dirent_read failed: %d\n", ret); | 588 | P9_DPRINTK(P9_DEBUG_9P, "<<< p9dirent_read failed: %d\n", ret); |
618 | P9_DUMP_PKT(1, &fake_pdu); | 589 | trace_9p_protocol_dump(clnt, &fake_pdu); |
619 | goto out; | 590 | goto out; |
620 | } | 591 | } |
621 | 592 | ||
diff --git a/net/9p/protocol.h b/net/9p/protocol.h index a0eb8ff11f22..2cc525fa49fa 100644 --- a/net/9p/protocol.h +++ b/net/9p/protocol.h | |||
@@ -29,7 +29,6 @@ int p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt, | |||
29 | va_list ap); | 29 | va_list ap); |
30 | int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...); | 30 | int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...); |
31 | int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type); | 31 | int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type); |
32 | int p9pdu_finalize(struct p9_fcall *pdu); | 32 | int p9pdu_finalize(struct p9_client *clnt, struct p9_fcall *pdu); |
33 | void p9pdu_dump(int, struct p9_fcall *); | ||
34 | void p9pdu_reset(struct p9_fcall *pdu); | 33 | void p9pdu_reset(struct p9_fcall *pdu); |
35 | size_t pdu_read(struct p9_fcall *pdu, void *data, size_t size); | 34 | size_t pdu_read(struct p9_fcall *pdu, void *data, size_t size); |