forked from mirrors/linux
		
	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>
This commit is contained in:
		
							parent
							
								
									878ffa9f85
								
							
						
					
					
						commit
						860a0d9e51
					
				
					 3 changed files with 88 additions and 19 deletions
				
			
		| 
						 | 
					@ -6,6 +6,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <linux/sunrpc/sched.h>
 | 
					#include <linux/sunrpc/sched.h>
 | 
				
			||||||
#include <linux/sunrpc/clnt.h>
 | 
					#include <linux/sunrpc/clnt.h>
 | 
				
			||||||
 | 
					#include <linux/sunrpc/svc.h>
 | 
				
			||||||
#include <net/tcp_states.h>
 | 
					#include <net/tcp_states.h>
 | 
				
			||||||
#include <linux/net.h>
 | 
					#include <linux/net.h>
 | 
				
			||||||
#include <linux/tracepoint.h>
 | 
					#include <linux/tracepoint.h>
 | 
				
			||||||
| 
						 | 
					@ -306,6 +307,60 @@ DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_reset_connection);
 | 
				
			||||||
DEFINE_RPC_SOCKET_EVENT(rpc_socket_close);
 | 
					DEFINE_RPC_SOCKET_EVENT(rpc_socket_close);
 | 
				
			||||||
DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown);
 | 
					DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TRACE_EVENT(svc_recv,
 | 
				
			||||||
 | 
						TP_PROTO(struct svc_rqst *rqst, int status),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TP_ARGS(rqst, status),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TP_STRUCT__entry(
 | 
				
			||||||
 | 
							__field(struct sockaddr *, addr)
 | 
				
			||||||
 | 
							__field(__be32, xid)
 | 
				
			||||||
 | 
							__field(int, status)
 | 
				
			||||||
 | 
						),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TP_fast_assign(
 | 
				
			||||||
 | 
							__entry->addr = (struct sockaddr *)&rqst->rq_addr;
 | 
				
			||||||
 | 
							__entry->xid = status > 0 ? rqst->rq_xid : 0;
 | 
				
			||||||
 | 
							__entry->status = status;
 | 
				
			||||||
 | 
						),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TP_printk("addr=%pIScp xid=0x%x status=%d", __entry->addr,
 | 
				
			||||||
 | 
								be32_to_cpu(__entry->xid), __entry->status)
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DECLARE_EVENT_CLASS(svc_rqst_status,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TP_PROTO(struct svc_rqst *rqst, int status),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TP_ARGS(rqst, status),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TP_STRUCT__entry(
 | 
				
			||||||
 | 
							__field(struct sockaddr *, addr)
 | 
				
			||||||
 | 
							__field(__be32, xid)
 | 
				
			||||||
 | 
							__field(int, dropme)
 | 
				
			||||||
 | 
							__field(int, status)
 | 
				
			||||||
 | 
						),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TP_fast_assign(
 | 
				
			||||||
 | 
							__entry->addr = (struct sockaddr *)&rqst->rq_addr;
 | 
				
			||||||
 | 
							__entry->xid = rqst->rq_xid;
 | 
				
			||||||
 | 
							__entry->dropme = (int)rqst->rq_dropme;
 | 
				
			||||||
 | 
							__entry->status = status;
 | 
				
			||||||
 | 
						),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TP_printk("addr=%pIScp rq_xid=0x%x dropme=%d status=%d",
 | 
				
			||||||
 | 
							__entry->addr, be32_to_cpu(__entry->xid), __entry->dropme,
 | 
				
			||||||
 | 
							__entry->status)
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEFINE_EVENT(svc_rqst_status, svc_process,
 | 
				
			||||||
 | 
						TP_PROTO(struct svc_rqst *rqst, int status),
 | 
				
			||||||
 | 
						TP_ARGS(rqst, status));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEFINE_EVENT(svc_rqst_status, svc_send,
 | 
				
			||||||
 | 
						TP_PROTO(struct svc_rqst *rqst, int status),
 | 
				
			||||||
 | 
						TP_ARGS(rqst, status));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* _TRACE_SUNRPC_H */
 | 
					#endif /* _TRACE_SUNRPC_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <trace/define_trace.h>
 | 
					#include <trace/define_trace.h>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,8 @@
 | 
				
			||||||
#include <linux/sunrpc/clnt.h>
 | 
					#include <linux/sunrpc/clnt.h>
 | 
				
			||||||
#include <linux/sunrpc/bc_xprt.h>
 | 
					#include <linux/sunrpc/bc_xprt.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <trace/events/sunrpc.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define RPCDBG_FACILITY	RPCDBG_SVCDSP
 | 
					#define RPCDBG_FACILITY	RPCDBG_SVCDSP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void svc_unregister(const struct svc_serv *serv, struct net *net);
 | 
					static void svc_unregister(const struct svc_serv *serv, struct net *net);
 | 
				
			||||||
| 
						 | 
					@ -1314,25 +1316,26 @@ svc_process(struct svc_rqst *rqstp)
 | 
				
			||||||
	rqstp->rq_res.tail[0].iov_base = NULL;
 | 
						rqstp->rq_res.tail[0].iov_base = NULL;
 | 
				
			||||||
	rqstp->rq_res.tail[0].iov_len = 0;
 | 
						rqstp->rq_res.tail[0].iov_len = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rqstp->rq_xid = svc_getu32(argv);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	dir  = svc_getnl(argv);
 | 
						dir  = svc_getnl(argv);
 | 
				
			||||||
	if (dir != 0) {
 | 
						if (dir != 0) {
 | 
				
			||||||
		/* direction != CALL */
 | 
							/* direction != CALL */
 | 
				
			||||||
		svc_printk(rqstp, "bad direction %d, dropping request\n", dir);
 | 
							svc_printk(rqstp, "bad direction %d, dropping request\n", dir);
 | 
				
			||||||
		serv->sv_stats->rpcbadfmt++;
 | 
							serv->sv_stats->rpcbadfmt++;
 | 
				
			||||||
		svc_drop(rqstp);
 | 
							goto out_drop;
 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Returns 1 for send, 0 for drop */
 | 
						/* Returns 1 for send, 0 for drop */
 | 
				
			||||||
	if (svc_process_common(rqstp, argv, resv))
 | 
						if (likely(svc_process_common(rqstp, argv, resv))) {
 | 
				
			||||||
		return svc_send(rqstp);
 | 
							int ret = svc_send(rqstp);
 | 
				
			||||||
	else {
 | 
					
 | 
				
			||||||
 | 
							trace_svc_process(rqstp, ret);
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					out_drop:
 | 
				
			||||||
 | 
						trace_svc_process(rqstp, 0);
 | 
				
			||||||
	svc_drop(rqstp);
 | 
						svc_drop(rqstp);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(CONFIG_SUNRPC_BACKCHANNEL)
 | 
					#if defined(CONFIG_SUNRPC_BACKCHANNEL)
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,7 @@
 | 
				
			||||||
#include <linux/sunrpc/svcsock.h>
 | 
					#include <linux/sunrpc/svcsock.h>
 | 
				
			||||||
#include <linux/sunrpc/xprt.h>
 | 
					#include <linux/sunrpc/xprt.h>
 | 
				
			||||||
#include <linux/module.h>
 | 
					#include <linux/module.h>
 | 
				
			||||||
 | 
					#include <trace/events/sunrpc.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define RPCDBG_FACILITY	RPCDBG_SVCXPRT
 | 
					#define RPCDBG_FACILITY	RPCDBG_SVCXPRT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -773,35 +774,43 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = svc_alloc_arg(rqstp);
 | 
						err = svc_alloc_arg(rqstp);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	try_to_freeze();
 | 
						try_to_freeze();
 | 
				
			||||||
	cond_resched();
 | 
						cond_resched();
 | 
				
			||||||
 | 
						err = -EINTR;
 | 
				
			||||||
	if (signalled() || kthread_should_stop())
 | 
						if (signalled() || kthread_should_stop())
 | 
				
			||||||
		return -EINTR;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xprt = svc_get_next_xprt(rqstp, timeout);
 | 
						xprt = svc_get_next_xprt(rqstp, timeout);
 | 
				
			||||||
	if (IS_ERR(xprt))
 | 
						if (IS_ERR(xprt)) {
 | 
				
			||||||
		return PTR_ERR(xprt);
 | 
							err = PTR_ERR(xprt);
 | 
				
			||||||
 | 
							goto out;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	len = svc_handle_xprt(rqstp, xprt);
 | 
						len = svc_handle_xprt(rqstp, xprt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* No data, incomplete (TCP) read, or accept() */
 | 
						/* No data, incomplete (TCP) read, or accept() */
 | 
				
			||||||
 | 
						err = -EAGAIN;
 | 
				
			||||||
	if (len <= 0)
 | 
						if (len <= 0)
 | 
				
			||||||
		goto out;
 | 
							goto out_release;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	clear_bit(XPT_OLD, &xprt->xpt_flags);
 | 
						clear_bit(XPT_OLD, &xprt->xpt_flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rqstp->rq_secure = xprt->xpt_ops->xpo_secure_port(rqstp);
 | 
						rqstp->rq_secure = xprt->xpt_ops->xpo_secure_port(rqstp);
 | 
				
			||||||
	rqstp->rq_chandle.defer = svc_defer;
 | 
						rqstp->rq_chandle.defer = svc_defer;
 | 
				
			||||||
 | 
						rqstp->rq_xid = svc_getu32(&rqstp->rq_arg.head[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (serv->sv_stats)
 | 
						if (serv->sv_stats)
 | 
				
			||||||
		serv->sv_stats->netcnt++;
 | 
							serv->sv_stats->netcnt++;
 | 
				
			||||||
 | 
						trace_svc_recv(rqstp, len);
 | 
				
			||||||
	return len;
 | 
						return len;
 | 
				
			||||||
out:
 | 
					out_release:
 | 
				
			||||||
	rqstp->rq_res.len = 0;
 | 
						rqstp->rq_res.len = 0;
 | 
				
			||||||
	svc_xprt_release(rqstp);
 | 
						svc_xprt_release(rqstp);
 | 
				
			||||||
	return -EAGAIN;
 | 
					out:
 | 
				
			||||||
 | 
						trace_svc_recv(rqstp, err);
 | 
				
			||||||
 | 
						return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL_GPL(svc_recv);
 | 
					EXPORT_SYMBOL_GPL(svc_recv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -821,12 +830,12 @@ EXPORT_SYMBOL_GPL(svc_drop);
 | 
				
			||||||
int svc_send(struct svc_rqst *rqstp)
 | 
					int svc_send(struct svc_rqst *rqstp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct svc_xprt	*xprt;
 | 
						struct svc_xprt	*xprt;
 | 
				
			||||||
	int		len;
 | 
						int		len = -EFAULT;
 | 
				
			||||||
	struct xdr_buf	*xb;
 | 
						struct xdr_buf	*xb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xprt = rqstp->rq_xprt;
 | 
						xprt = rqstp->rq_xprt;
 | 
				
			||||||
	if (!xprt)
 | 
						if (!xprt)
 | 
				
			||||||
		return -EFAULT;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* release the receive skb before sending the reply */
 | 
						/* release the receive skb before sending the reply */
 | 
				
			||||||
	rqstp->rq_xprt->xpt_ops->xpo_release_rqst(rqstp);
 | 
						rqstp->rq_xprt->xpt_ops->xpo_release_rqst(rqstp);
 | 
				
			||||||
| 
						 | 
					@ -849,7 +858,9 @@ int svc_send(struct svc_rqst *rqstp)
 | 
				
			||||||
	svc_xprt_release(rqstp);
 | 
						svc_xprt_release(rqstp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN)
 | 
						if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN)
 | 
				
			||||||
		return 0;
 | 
							len = 0;
 | 
				
			||||||
 | 
					out:
 | 
				
			||||||
 | 
						trace_svc_send(rqstp, len);
 | 
				
			||||||
	return len;
 | 
						return len;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue