diff options
author | Jeff Layton <jlayton@primarydata.com> | 2014-10-28 14:24:12 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2014-11-24 12:53:34 -0500 |
commit | 860a0d9e511f278bedab62d555a457c18e0841d5 (patch) | |
tree | 4e5348dd4d2e9abf81dea3c9715fe887a4f3fedc | |
parent | 878ffa9f855e84d35d950f1abeb5a37b8435baea (diff) |
sunrpc: add some tracepoints in svc_rqst handling functions
...just around svc_send, svc_recv and svc_process for now.
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r-- | include/trace/events/sunrpc.h | 55 | ||||
-rw-r--r-- | net/sunrpc/svc.c | 21 | ||||
-rw-r--r-- | net/sunrpc/svc_xprt.c | 31 |
3 files changed, 88 insertions, 19 deletions
diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h index 1fef3e6e9436..6260f5134212 100644 --- a/include/trace/events/sunrpc.h +++ b/include/trace/events/sunrpc.h | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | #include <linux/sunrpc/sched.h> | 7 | #include <linux/sunrpc/sched.h> |
8 | #include <linux/sunrpc/clnt.h> | 8 | #include <linux/sunrpc/clnt.h> |
9 | #include <linux/sunrpc/svc.h> | ||
9 | #include <net/tcp_states.h> | 10 | #include <net/tcp_states.h> |
10 | #include <linux/net.h> | 11 | #include <linux/net.h> |
11 | #include <linux/tracepoint.h> | 12 | #include <linux/tracepoint.h> |
@@ -306,6 +307,60 @@ DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_reset_connection); | |||
306 | DEFINE_RPC_SOCKET_EVENT(rpc_socket_close); | 307 | DEFINE_RPC_SOCKET_EVENT(rpc_socket_close); |
307 | DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown); | 308 | DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown); |
308 | 309 | ||
310 | TRACE_EVENT(svc_recv, | ||
311 | TP_PROTO(struct svc_rqst *rqst, int status), | ||
312 | |||
313 | TP_ARGS(rqst, status), | ||
314 | |||
315 | TP_STRUCT__entry( | ||
316 | __field(struct sockaddr *, addr) | ||
317 | __field(__be32, xid) | ||
318 | __field(int, status) | ||
319 | ), | ||
320 | |||
321 | TP_fast_assign( | ||
322 | __entry->addr = (struct sockaddr *)&rqst->rq_addr; | ||
323 | __entry->xid = status > 0 ? rqst->rq_xid : 0; | ||
324 | __entry->status = status; | ||
325 | ), | ||
326 | |||
327 | TP_printk("addr=%pIScp xid=0x%x status=%d", __entry->addr, | ||
328 | be32_to_cpu(__entry->xid), __entry->status) | ||
329 | ); | ||
330 | |||
331 | DECLARE_EVENT_CLASS(svc_rqst_status, | ||
332 | |||
333 | TP_PROTO(struct svc_rqst *rqst, int status), | ||
334 | |||
335 | TP_ARGS(rqst, status), | ||
336 | |||
337 | TP_STRUCT__entry( | ||
338 | __field(struct sockaddr *, addr) | ||
339 | __field(__be32, xid) | ||
340 | __field(int, dropme) | ||
341 | __field(int, status) | ||
342 | ), | ||
343 | |||
344 | TP_fast_assign( | ||
345 | __entry->addr = (struct sockaddr *)&rqst->rq_addr; | ||
346 | __entry->xid = rqst->rq_xid; | ||
347 | __entry->dropme = (int)rqst->rq_dropme; | ||
348 | __entry->status = status; | ||
349 | ), | ||
350 | |||
351 | TP_printk("addr=%pIScp rq_xid=0x%x dropme=%d status=%d", | ||
352 | __entry->addr, be32_to_cpu(__entry->xid), __entry->dropme, | ||
353 | __entry->status) | ||
354 | ); | ||
355 | |||
356 | DEFINE_EVENT(svc_rqst_status, svc_process, | ||
357 | TP_PROTO(struct svc_rqst *rqst, int status), | ||
358 | TP_ARGS(rqst, status)); | ||
359 | |||
360 | DEFINE_EVENT(svc_rqst_status, svc_send, | ||
361 | TP_PROTO(struct svc_rqst *rqst, int status), | ||
362 | TP_ARGS(rqst, status)); | ||
363 | |||
309 | #endif /* _TRACE_SUNRPC_H */ | 364 | #endif /* _TRACE_SUNRPC_H */ |
310 | 365 | ||
311 | #include <trace/define_trace.h> | 366 | #include <trace/define_trace.h> |
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index ca8a7958f4e6..371a8bbb43d6 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <linux/sunrpc/clnt.h> | 28 | #include <linux/sunrpc/clnt.h> |
29 | #include <linux/sunrpc/bc_xprt.h> | 29 | #include <linux/sunrpc/bc_xprt.h> |
30 | 30 | ||
31 | #include <trace/events/sunrpc.h> | ||
32 | |||
31 | #define RPCDBG_FACILITY RPCDBG_SVCDSP | 33 | #define RPCDBG_FACILITY RPCDBG_SVCDSP |
32 | 34 | ||
33 | static void svc_unregister(const struct svc_serv *serv, struct net *net); | 35 | static void svc_unregister(const struct svc_serv *serv, struct net *net); |
@@ -1314,24 +1316,25 @@ svc_process(struct svc_rqst *rqstp) | |||
1314 | rqstp->rq_res.tail[0].iov_base = NULL; | 1316 | rqstp->rq_res.tail[0].iov_base = NULL; |
1315 | rqstp->rq_res.tail[0].iov_len = 0; | 1317 | rqstp->rq_res.tail[0].iov_len = 0; |
1316 | 1318 | ||
1317 | rqstp->rq_xid = svc_getu32(argv); | ||
1318 | |||
1319 | dir = svc_getnl(argv); | 1319 | dir = svc_getnl(argv); |
1320 | if (dir != 0) { | 1320 | if (dir != 0) { |
1321 | /* direction != CALL */ | 1321 | /* direction != CALL */ |
1322 | svc_printk(rqstp, "bad direction %d, dropping request\n", dir); | 1322 | svc_printk(rqstp, "bad direction %d, dropping request\n", dir); |
1323 | serv->sv_stats->rpcbadfmt++; | 1323 | serv->sv_stats->rpcbadfmt++; |
1324 | svc_drop(rqstp); | 1324 | goto out_drop; |
1325 | return 0; | ||
1326 | } | 1325 | } |
1327 | 1326 | ||
1328 | /* Returns 1 for send, 0 for drop */ | 1327 | /* Returns 1 for send, 0 for drop */ |
1329 | if (svc_process_common(rqstp, argv, resv)) | 1328 | if (likely(svc_process_common(rqstp, argv, resv))) { |
1330 | return svc_send(rqstp); | 1329 | int ret = svc_send(rqstp); |
1331 | else { | 1330 | |
1332 | svc_drop(rqstp); | 1331 | trace_svc_process(rqstp, ret); |
1333 | return 0; | 1332 | return ret; |
1334 | } | 1333 | } |
1334 | out_drop: | ||
1335 | trace_svc_process(rqstp, 0); | ||
1336 | svc_drop(rqstp); | ||
1337 | return 0; | ||
1335 | } | 1338 | } |
1336 | 1339 | ||
1337 | #if defined(CONFIG_SUNRPC_BACKCHANNEL) | 1340 | #if defined(CONFIG_SUNRPC_BACKCHANNEL) |
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index c179ca2a5aa4..bbb3b044b877 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/sunrpc/svcsock.h> | 15 | #include <linux/sunrpc/svcsock.h> |
16 | #include <linux/sunrpc/xprt.h> | 16 | #include <linux/sunrpc/xprt.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <trace/events/sunrpc.h> | ||
18 | 19 | ||
19 | #define RPCDBG_FACILITY RPCDBG_SVCXPRT | 20 | #define RPCDBG_FACILITY RPCDBG_SVCXPRT |
20 | 21 | ||
@@ -773,35 +774,43 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) | |||
773 | 774 | ||
774 | err = svc_alloc_arg(rqstp); | 775 | err = svc_alloc_arg(rqstp); |
775 | if (err) | 776 | if (err) |
776 | return err; | 777 | goto out; |
777 | 778 | ||
778 | try_to_freeze(); | 779 | try_to_freeze(); |
779 | cond_resched(); | 780 | cond_resched(); |
781 | err = -EINTR; | ||
780 | if (signalled() || kthread_should_stop()) | 782 | if (signalled() || kthread_should_stop()) |
781 | return -EINTR; | 783 | goto out; |
782 | 784 | ||
783 | xprt = svc_get_next_xprt(rqstp, timeout); | 785 | xprt = svc_get_next_xprt(rqstp, timeout); |
784 | if (IS_ERR(xprt)) | 786 | if (IS_ERR(xprt)) { |
785 | return PTR_ERR(xprt); | 787 | err = PTR_ERR(xprt); |
788 | goto out; | ||
789 | } | ||
786 | 790 | ||
787 | len = svc_handle_xprt(rqstp, xprt); | 791 | len = svc_handle_xprt(rqstp, xprt); |
788 | 792 | ||
789 | /* No data, incomplete (TCP) read, or accept() */ | 793 | /* No data, incomplete (TCP) read, or accept() */ |
794 | err = -EAGAIN; | ||
790 | if (len <= 0) | 795 | if (len <= 0) |
791 | goto out; | 796 | goto out_release; |
792 | 797 | ||
793 | clear_bit(XPT_OLD, &xprt->xpt_flags); | 798 | clear_bit(XPT_OLD, &xprt->xpt_flags); |
794 | 799 | ||
795 | rqstp->rq_secure = xprt->xpt_ops->xpo_secure_port(rqstp); | 800 | rqstp->rq_secure = xprt->xpt_ops->xpo_secure_port(rqstp); |
796 | rqstp->rq_chandle.defer = svc_defer; | 801 | rqstp->rq_chandle.defer = svc_defer; |
802 | rqstp->rq_xid = svc_getu32(&rqstp->rq_arg.head[0]); | ||
797 | 803 | ||
798 | if (serv->sv_stats) | 804 | if (serv->sv_stats) |
799 | serv->sv_stats->netcnt++; | 805 | serv->sv_stats->netcnt++; |
806 | trace_svc_recv(rqstp, len); | ||
800 | return len; | 807 | return len; |
801 | out: | 808 | out_release: |
802 | rqstp->rq_res.len = 0; | 809 | rqstp->rq_res.len = 0; |
803 | svc_xprt_release(rqstp); | 810 | svc_xprt_release(rqstp); |
804 | return -EAGAIN; | 811 | out: |
812 | trace_svc_recv(rqstp, err); | ||
813 | return err; | ||
805 | } | 814 | } |
806 | EXPORT_SYMBOL_GPL(svc_recv); | 815 | EXPORT_SYMBOL_GPL(svc_recv); |
807 | 816 | ||
@@ -821,12 +830,12 @@ EXPORT_SYMBOL_GPL(svc_drop); | |||
821 | int svc_send(struct svc_rqst *rqstp) | 830 | int svc_send(struct svc_rqst *rqstp) |
822 | { | 831 | { |
823 | struct svc_xprt *xprt; | 832 | struct svc_xprt *xprt; |
824 | int len; | 833 | int len = -EFAULT; |
825 | struct xdr_buf *xb; | 834 | struct xdr_buf *xb; |
826 | 835 | ||
827 | xprt = rqstp->rq_xprt; | 836 | xprt = rqstp->rq_xprt; |
828 | if (!xprt) | 837 | if (!xprt) |
829 | return -EFAULT; | 838 | goto out; |
830 | 839 | ||
831 | /* release the receive skb before sending the reply */ | 840 | /* release the receive skb before sending the reply */ |
832 | rqstp->rq_xprt->xpt_ops->xpo_release_rqst(rqstp); | 841 | rqstp->rq_xprt->xpt_ops->xpo_release_rqst(rqstp); |
@@ -849,7 +858,9 @@ int svc_send(struct svc_rqst *rqstp) | |||
849 | svc_xprt_release(rqstp); | 858 | svc_xprt_release(rqstp); |
850 | 859 | ||
851 | if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN) | 860 | if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN) |
852 | return 0; | 861 | len = 0; |
862 | out: | ||
863 | trace_svc_send(rqstp, len); | ||
853 | return len; | 864 | return len; |
854 | } | 865 | } |
855 | 866 | ||