Skip to content

Commit 90f359c

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: core: Report error list information in debugfs
Provide information in debugfs about SCSI error handling to make it easier to debug the SCSI error handler. Additionally, report the maximum number of retries in debugfs (.allowed). Reviewed-by: John Garry <john.g.garry@oracle.com> Cc: Hannes Reinecke <hare@suse.de> Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com> Cc: Mike Christie <michael.christie@oracle.com> Cc: Ming Lei <ming.lei@redhat.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20230822163811.219569-1-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 7951952 commit 90f359c

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

drivers/scsi/scsi_debugfs.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/seq_file.h>
44
#include <scsi/scsi_cmnd.h>
55
#include <scsi/scsi_dbg.h>
6+
#include <scsi/scsi_host.h>
67
#include "scsi_debugfs.h"
78

89
#define SCSI_CMD_FLAG_NAME(name)[const_ilog2(SCMD_##name)] = #name
@@ -33,14 +34,33 @@ static int scsi_flags_show(struct seq_file *m, const unsigned long flags,
3334

3435
void scsi_show_rq(struct seq_file *m, struct request *rq)
3536
{
36-
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
37+
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq), *cmd2;
38+
struct Scsi_Host *shost = cmd->device->host;
3739
int alloc_ms = jiffies_to_msecs(jiffies - cmd->jiffies_at_alloc);
3840
int timeout_ms = jiffies_to_msecs(rq->timeout);
41+
const char *list_info = NULL;
3942
char buf[80] = "(?)";
4043

44+
spin_lock_irq(shost->host_lock);
45+
list_for_each_entry(cmd2, &shost->eh_abort_list, eh_entry) {
46+
if (cmd == cmd2) {
47+
list_info = "on eh_abort_list";
48+
goto unlock;
49+
}
50+
}
51+
list_for_each_entry(cmd2, &shost->eh_cmd_q, eh_entry) {
52+
if (cmd == cmd2) {
53+
list_info = "on eh_cmd_q";
54+
goto unlock;
55+
}
56+
}
57+
unlock:
58+
spin_unlock_irq(shost->host_lock);
59+
4160
__scsi_format_command(buf, sizeof(buf), cmd->cmnd, cmd->cmd_len);
42-
seq_printf(m, ", .cmd=%s, .retries=%d, .result = %#x, .flags=", buf,
43-
cmd->retries, cmd->result);
61+
seq_printf(m, ", .cmd=%s, .retries=%d, .allowed=%d, .result = %#x, %s%s.flags=",
62+
buf, cmd->retries, cmd->allowed, cmd->result,
63+
list_info ? : "", list_info ? ", " : "");
4464
scsi_flags_show(m, cmd->flags, scsi_cmd_flags,
4565
ARRAY_SIZE(scsi_cmd_flags));
4666
seq_printf(m, ", .timeout=%d.%03d, allocated %d.%03d s ago",

0 commit comments

Comments
 (0)