aboutsummaryrefslogtreecommitdiffstats
path: root/net/9p/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/9p/client.c')
-rw-r--r--net/9p/client.c77
1 files changed, 41 insertions, 36 deletions
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;
689reterr: 702reterr:
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 }
762reterr: 774reterr:
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 }
848reterr: 857reterr:
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);
1072struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, 1079struct 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);