Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nbd: trace sending nbd requests

This adds a tracepoint that can both observe the nbd request being sent
to the server, as well as modify that request , e.g., setting a flag in
the request that will cause the server to collect detailed tracing data.

The struct request * being handled is included to permit correlation
with the block tracepoints.

Signed-off-by: Matt Mullins <mmullins@fb.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Matt Mullins and committed by
Alexei Starovoitov
ea106722 9df1c28b

+62
+1
MAINTAINERS
··· 10741 10741 L: nbd@other.debian.org 10742 10742 F: Documentation/blockdev/nbd.txt 10743 10743 F: drivers/block/nbd.c 10744 + F: include/trace/events/nbd.h 10744 10745 F: include/uapi/linux/nbd.h 10745 10746 10746 10747 NETWORK DROP MONITOR
+5
drivers/block/nbd.c
··· 44 44 #include <linux/nbd-netlink.h> 45 45 #include <net/genetlink.h> 46 46 47 + #define CREATE_TRACE_POINTS 48 + #include <trace/events/nbd.h> 49 + 47 50 static DEFINE_IDR(nbd_index_idr); 48 51 static DEFINE_MUTEX(nbd_index_mutex); 49 52 static int nbd_total_devices = 0; ··· 528 525 } 529 526 handle = nbd_cmd_handle(cmd); 530 527 memcpy(request.handle, &handle, sizeof(handle)); 528 + 529 + trace_nbd_send_request(&request, nbd->index, blk_mq_rq_from_pdu(cmd)); 531 530 532 531 dev_dbg(nbd_to_dev(nbd), "request %p: sending control (%s@%llu,%uB)\n", 533 532 req, nbdcmd_to_ascii(type),
+56
include/trace/events/nbd.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #undef TRACE_SYSTEM 3 + #define TRACE_SYSTEM nbd 4 + 5 + #if !defined(_TRACE_NBD_H) || defined(TRACE_HEADER_MULTI_READ) 6 + #define _TRACE_NBD_H 7 + 8 + #include <linux/tracepoint.h> 9 + 10 + DECLARE_EVENT_CLASS(nbd_send_request, 11 + 12 + TP_PROTO(struct nbd_request *nbd_request, int index, 13 + struct request *rq), 14 + 15 + TP_ARGS(nbd_request, index, rq), 16 + 17 + TP_STRUCT__entry( 18 + __field(struct nbd_request *, nbd_request) 19 + __field(u64, dev_index) 20 + __field(struct request *, request) 21 + ), 22 + 23 + TP_fast_assign( 24 + __entry->nbd_request = 0; 25 + __entry->dev_index = index; 26 + __entry->request = rq; 27 + ), 28 + 29 + TP_printk("nbd%lld: request %p", __entry->dev_index, __entry->request) 30 + ); 31 + 32 + #ifdef DEFINE_EVENT_WRITABLE 33 + #undef NBD_DEFINE_EVENT 34 + #define NBD_DEFINE_EVENT(template, call, proto, args, size) \ 35 + DEFINE_EVENT_WRITABLE(template, call, PARAMS(proto), \ 36 + PARAMS(args), size) 37 + #else 38 + #undef NBD_DEFINE_EVENT 39 + #define NBD_DEFINE_EVENT(template, call, proto, args, size) \ 40 + DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args)) 41 + #endif 42 + 43 + NBD_DEFINE_EVENT(nbd_send_request, nbd_send_request, 44 + 45 + TP_PROTO(struct nbd_request *nbd_request, int index, 46 + struct request *rq), 47 + 48 + TP_ARGS(nbd_request, index, rq), 49 + 50 + sizeof(struct nbd_request) 51 + ); 52 + 53 + #endif 54 + 55 + /* This part must be outside protection */ 56 + #include <trace/define_trace.h>