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

scsi: Implement blk_mq_ops.show_rq()

Show the SCSI CDB for pending SCSI commands in
/sys/kernel/debug/block/*/mq/*/dispatch and */rq_list. An example
of how SCSI commands are displayed by this code:

ffff8801703245c0 {.op=READ, .cmd_flags=META PRIO, .rq_flags=DONTPREP IO_STAT STATS, .tag=14, .internal_tag=-1, .cmd=Read(10) 28 00 2a 81 1b 30 00 00 08 00}

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: <linux-scsi@vger.kernel.org>
Signed-off-by: Jens Axboe <axboe@fb.com>

authored by

Bart Van Assche and committed by
Jens Axboe
0eebd005 2836ee4b

+22
+1
drivers/scsi/Makefile
··· 166 166 scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o 167 167 scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o 168 168 scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o 169 + scsi_mod-$(CONFIG_BLK_DEBUG_FS) += scsi_debugfs.o 169 170 scsi_mod-y += scsi_trace.o scsi_logging.o 170 171 scsi_mod-$(CONFIG_PM) += scsi_pm.o 171 172 scsi_mod-$(CONFIG_SCSI_DH) += scsi_dh.o
+13
drivers/scsi/scsi_debugfs.c
··· 1 + #include <linux/seq_file.h> 2 + #include <scsi/scsi_cmnd.h> 3 + #include <scsi/scsi_dbg.h> 4 + #include "scsi_debugfs.h" 5 + 6 + void scsi_show_rq(struct seq_file *m, struct request *rq) 7 + { 8 + struct scsi_cmnd *cmd = container_of(scsi_req(rq), typeof(*cmd), req); 9 + char buf[80]; 10 + 11 + __scsi_format_command(buf, sizeof(buf), cmd->cmnd, cmd->cmd_len); 12 + seq_printf(m, ", .cmd=%s", buf); 13 + }
+4
drivers/scsi/scsi_debugfs.h
··· 1 + struct request; 2 + struct seq_file; 3 + 4 + void scsi_show_rq(struct seq_file *m, struct request *rq);
+4
drivers/scsi/scsi_lib.c
··· 34 34 35 35 #include <trace/events/scsi.h> 36 36 37 + #include "scsi_debugfs.h" 37 38 #include "scsi_priv.h" 38 39 #include "scsi_logging.h" 39 40 ··· 2158 2157 .queue_rq = scsi_queue_rq, 2159 2158 .complete = scsi_softirq_done, 2160 2159 .timeout = scsi_timeout, 2160 + #ifdef CONFIG_BLK_DEBUG_FS 2161 + .show_rq = scsi_show_rq, 2162 + #endif 2161 2163 .init_request = scsi_init_request, 2162 2164 .exit_request = scsi_exit_request, 2163 2165 .map_queues = scsi_map_queues,