|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | 2 | #include <linux/bitops.h> |
| 3 | +#include <linux/cleanup.h> |
3 | 4 | #include <linux/seq_file.h> |
4 | 5 | #include <scsi/scsi_cmnd.h> |
5 | 6 | #include <scsi/scsi_dbg.h> |
@@ -32,31 +33,32 @@ static int scsi_flags_show(struct seq_file *m, const unsigned long flags, |
32 | 33 | return 0; |
33 | 34 | } |
34 | 35 |
|
35 | | -void scsi_show_rq(struct seq_file *m, struct request *rq) |
| 36 | +static const char *scsi_cmd_list_info(struct scsi_cmnd *cmd) |
36 | 37 | { |
37 | | - struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq), *cmd2; |
38 | 38 | struct Scsi_Host *shost = cmd->device->host; |
| 39 | + struct scsi_cmnd *cmd2; |
| 40 | + |
| 41 | + guard(spinlock_irq)(shost->host_lock); |
| 42 | + |
| 43 | + list_for_each_entry(cmd2, &shost->eh_abort_list, eh_entry) |
| 44 | + if (cmd == cmd2) |
| 45 | + return "on eh_abort_list"; |
| 46 | + |
| 47 | + list_for_each_entry(cmd2, &shost->eh_cmd_q, eh_entry) |
| 48 | + if (cmd == cmd2) |
| 49 | + return "on eh_cmd_q"; |
| 50 | + |
| 51 | + return NULL; |
| 52 | +} |
| 53 | + |
| 54 | +void scsi_show_rq(struct seq_file *m, struct request *rq) |
| 55 | +{ |
| 56 | + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); |
39 | 57 | int alloc_ms = jiffies_to_msecs(jiffies - cmd->jiffies_at_alloc); |
40 | 58 | int timeout_ms = jiffies_to_msecs(rq->timeout); |
41 | | - const char *list_info = NULL; |
| 59 | + const char *list_info = scsi_cmd_list_info(cmd); |
42 | 60 | char buf[80] = "(?)"; |
43 | 61 |
|
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 | | - |
60 | 62 | __scsi_format_command(buf, sizeof(buf), cmd->cmnd, cmd->cmd_len); |
61 | 63 | seq_printf(m, ", .cmd=%s, .retries=%d, .allowed=%d, .result = %#x, %s%s.flags=", |
62 | 64 | buf, cmd->retries, cmd->allowed, cmd->result, |
|
0 commit comments