* [PATCH v4 0/3] SCSI core patches
@ 2023-05-18 19:31 Bart Van Assche
2023-05-18 19:31 ` [PATCH v4 1/3] scsi: core: Use min() instead of open-coding it Bart Van Assche
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Bart Van Assche @ 2023-05-18 19:31 UTC (permalink / raw)
To: Martin K . Petersen; +Cc: Christoph Hellwig, linux-scsi, Bart Van Assche
Hi Martin,
Please consider these SCSI core patches for the next merge window.
Thanks,
Bart.
Changes compared to v3:
- Changed the SCSI tracing format to make it less likely to break existing
user space software that parses SCSI trace information.
- Dropped patch "Delay running the queue if the host is blocked".
Changes compared to v2:
- Dropped patch "Update a source code comment".
- In patch "Trace SCSI sense data", changed the format for the sense key and
left out a superfluous parenthese.
- In patch "Only kick the requeue list if necessary", moved the
blk_mq_kick_requeue_list() call from scsi_run_host_queues() into
scsi_run_queue().
Changes compared to v1:
- Improved the SCSI tracing patch as requested by Steven Rostedt and
Niklas Cassel.
- Added patch "Delay running the queue if the host is blocked".
Bart Van Assche (3):
scsi: core: Use min() instead of open-coding it
scsi: core: Trace SCSI sense data
scsi: core: Only kick the requeue list if necessary
drivers/scsi/scsi_common.c | 3 +--
drivers/scsi/scsi_lib.c | 13 ++++++++-----
include/trace/events/scsi.h | 21 +++++++++++++++++++--
3 files changed, 28 insertions(+), 9 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 1/3] scsi: core: Use min() instead of open-coding it
2023-05-18 19:31 [PATCH v4 0/3] SCSI core patches Bart Van Assche
@ 2023-05-18 19:31 ` Bart Van Assche
2023-05-18 19:31 ` [PATCH v4 2/3] scsi: core: Trace SCSI sense data Bart Van Assche
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2023-05-18 19:31 UTC (permalink / raw)
To: Martin K . Petersen
Cc: Christoph Hellwig, linux-scsi, Bart Van Assche, Benjamin Block,
Douglas Gilbert
Use min() instead of open-coding it in scsi_normalize_sense().
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/scsi_common.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_common.c b/drivers/scsi/scsi_common.c
index 6e50e81a8216..24dec80a6253 100644
--- a/drivers/scsi/scsi_common.c
+++ b/drivers/scsi/scsi_common.c
@@ -176,8 +176,7 @@ bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
if (sb_len > 2)
sshdr->sense_key = (sense_buffer[2] & 0xf);
if (sb_len > 7) {
- sb_len = (sb_len < (sense_buffer[7] + 8)) ?
- sb_len : (sense_buffer[7] + 8);
+ sb_len = min(sb_len, sense_buffer[7] + 8);
if (sb_len > 12)
sshdr->asc = sense_buffer[12];
if (sb_len > 13)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 2/3] scsi: core: Trace SCSI sense data
2023-05-18 19:31 [PATCH v4 0/3] SCSI core patches Bart Van Assche
2023-05-18 19:31 ` [PATCH v4 1/3] scsi: core: Use min() instead of open-coding it Bart Van Assche
@ 2023-05-18 19:31 ` Bart Van Assche
2023-05-19 7:03 ` Ming Lei
2023-05-19 9:35 ` Niklas Cassel
2023-05-18 19:31 ` [PATCH v4 3/3] scsi: core: Only kick the requeue list if necessary Bart Van Assche
` (2 subsequent siblings)
4 siblings, 2 replies; 8+ messages in thread
From: Bart Van Assche @ 2023-05-18 19:31 UTC (permalink / raw)
To: Martin K . Petersen
Cc: Christoph Hellwig, linux-scsi, Bart Van Assche, Niklas Cassel,
Ming Lei, Hannes Reinecke, John Garry, Mike Christie
If a command fails, SCSI sense data is essential to determine why it
failed. Hence make the sense key, ASC and ASCQ codes available in the
ftrace output.
Cc: Niklas Cassel <niklas.cassel@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
include/trace/events/scsi.h | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h
index a2c7befd451a..8e2d9b1b0e77 100644
--- a/include/trace/events/scsi.h
+++ b/include/trace/events/scsi.h
@@ -269,9 +269,14 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
__field( unsigned int, prot_sglen )
__field( unsigned char, prot_op )
__dynamic_array(unsigned char, cmnd, cmd->cmd_len)
+ __field( u8, sense_key )
+ __field( u8, asc )
+ __field( u8, ascq )
),
TP_fast_assign(
+ struct scsi_sense_hdr sshdr;
+
__entry->host_no = cmd->device->host->host_no;
__entry->channel = cmd->device->channel;
__entry->id = cmd->device->id;
@@ -285,11 +290,22 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
__entry->prot_sglen = scsi_prot_sg_count(cmd);
__entry->prot_op = scsi_get_prot_op(cmd);
memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
+ if (cmd->sense_buffer && SCSI_SENSE_VALID(cmd) &&
+ scsi_command_normalize_sense(cmd, &sshdr)) {
+ __entry->sense_key = sshdr.sense_key;
+ __entry->asc = sshdr.asc;
+ __entry->ascq = sshdr.ascq;
+ } else {
+ __entry->sense_key = 0;
+ __entry->asc = 0;
+ __entry->ascq = 0;
+ }
),
TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u " \
"prot_op=%s driver_tag=%d scheduler_tag=%d cmnd=(%s %s raw=%s) " \
- "result=(driver=%s host=%s message=%s status=%s)",
+ "result=(driver=%s host=%s message=%s status=%s) "
+ "sense=(key=%#x asc=%#x ascq=%#x)",
__entry->host_no, __entry->channel, __entry->id,
__entry->lun, __entry->data_sglen, __entry->prot_sglen,
show_prot_op_name(__entry->prot_op), __entry->driver_tag,
@@ -299,7 +315,8 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
"DRIVER_OK",
show_hostbyte_name(((__entry->result) >> 16) & 0xff),
"COMMAND_COMPLETE",
- show_statusbyte_name(__entry->result & 0xff))
+ show_statusbyte_name(__entry->result & 0xff),
+ __entry->sense_key, __entry->asc, __entry->ascq)
);
DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done,
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 3/3] scsi: core: Only kick the requeue list if necessary
2023-05-18 19:31 [PATCH v4 0/3] SCSI core patches Bart Van Assche
2023-05-18 19:31 ` [PATCH v4 1/3] scsi: core: Use min() instead of open-coding it Bart Van Assche
2023-05-18 19:31 ` [PATCH v4 2/3] scsi: core: Trace SCSI sense data Bart Van Assche
@ 2023-05-18 19:31 ` Bart Van Assche
2023-05-31 15:06 ` [PATCH v4 0/3] SCSI core patches Martin K. Petersen
2023-06-08 1:42 ` Martin K. Petersen
4 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2023-05-18 19:31 UTC (permalink / raw)
To: Martin K . Petersen
Cc: Christoph Hellwig, linux-scsi, Bart Van Assche, Ming Lei,
Hannes Reinecke, John Garry, Mike Christie
Instead of running the request queue of each device associated with a
host every 3 ms (BLK_MQ_RESOURCE_DELAY) while host error handling is in
progress, run the request queue after error handling has finished.
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/scsi_lib.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index e59eb0cbfc83..e4f34217b879 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -122,11 +122,9 @@ static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd, unsigned long msecs)
WARN_ON_ONCE(true);
}
- if (msecs) {
- blk_mq_requeue_request(rq, false);
+ blk_mq_requeue_request(rq, false);
+ if (!scsi_host_in_recovery(cmd->device->host))
blk_mq_delay_kick_requeue_list(rq->q, msecs);
- } else
- blk_mq_requeue_request(rq, true);
}
/**
@@ -165,7 +163,8 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, bool unbusy)
*/
cmd->result = 0;
- blk_mq_requeue_request(scsi_cmd_to_rq(cmd), true);
+ blk_mq_requeue_request(scsi_cmd_to_rq(cmd),
+ !scsi_host_in_recovery(cmd->device->host));
}
/**
@@ -449,6 +448,7 @@ static void scsi_run_queue(struct request_queue *q)
if (!list_empty(&sdev->host->starved_list))
scsi_starved_list_run(sdev->host);
+ blk_mq_kick_requeue_list(q);
blk_mq_run_hw_queues(q, false);
}
@@ -499,6 +499,9 @@ static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
static void scsi_run_queue_async(struct scsi_device *sdev)
{
+ if (scsi_host_in_recovery(sdev->host))
+ return;
+
if (scsi_target(sdev)->single_lun ||
!list_empty(&sdev->host->starved_list)) {
kblockd_schedule_work(&sdev->requeue_work);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/3] scsi: core: Trace SCSI sense data
2023-05-18 19:31 ` [PATCH v4 2/3] scsi: core: Trace SCSI sense data Bart Van Assche
@ 2023-05-19 7:03 ` Ming Lei
2023-05-19 9:35 ` Niklas Cassel
1 sibling, 0 replies; 8+ messages in thread
From: Ming Lei @ 2023-05-19 7:03 UTC (permalink / raw)
To: Bart Van Assche
Cc: Martin K . Petersen, Christoph Hellwig, linux-scsi, Niklas Cassel,
Hannes Reinecke, John Garry, Mike Christie
On Thu, May 18, 2023 at 12:31:58PM -0700, Bart Van Assche wrote:
> If a command fails, SCSI sense data is essential to determine why it
> failed. Hence make the sense key, ASC and ASCQ codes available in the
> ftrace output.
>
> Cc: Niklas Cassel <niklas.cassel@wdc.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: John Garry <john.g.garry@oracle.com>
> Cc: Mike Christie <michael.christie@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Thanks,
Ming
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/3] scsi: core: Trace SCSI sense data
2023-05-18 19:31 ` [PATCH v4 2/3] scsi: core: Trace SCSI sense data Bart Van Assche
2023-05-19 7:03 ` Ming Lei
@ 2023-05-19 9:35 ` Niklas Cassel
1 sibling, 0 replies; 8+ messages in thread
From: Niklas Cassel @ 2023-05-19 9:35 UTC (permalink / raw)
To: Bart Van Assche
Cc: Martin K . Petersen, Christoph Hellwig,
linux-scsi@vger.kernel.org, Ming Lei, Hannes Reinecke, John Garry,
Mike Christie
On Thu, May 18, 2023 at 12:31:58PM -0700, Bart Van Assche wrote:
> If a command fails, SCSI sense data is essential to determine why it
> failed. Hence make the sense key, ASC and ASCQ codes available in the
> ftrace output.
>
> Cc: Niklas Cassel <niklas.cassel@wdc.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: John Garry <john.g.garry@oracle.com>
> Cc: Mike Christie <michael.christie@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> include/trace/events/scsi.h | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h
> index a2c7befd451a..8e2d9b1b0e77 100644
> --- a/include/trace/events/scsi.h
> +++ b/include/trace/events/scsi.h
> @@ -269,9 +269,14 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
> __field( unsigned int, prot_sglen )
> __field( unsigned char, prot_op )
> __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
> + __field( u8, sense_key )
> + __field( u8, asc )
> + __field( u8, ascq )
> ),
>
> TP_fast_assign(
> + struct scsi_sense_hdr sshdr;
> +
> __entry->host_no = cmd->device->host->host_no;
> __entry->channel = cmd->device->channel;
> __entry->id = cmd->device->id;
> @@ -285,11 +290,22 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
> __entry->prot_sglen = scsi_prot_sg_count(cmd);
> __entry->prot_op = scsi_get_prot_op(cmd);
> memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
> + if (cmd->sense_buffer && SCSI_SENSE_VALID(cmd) &&
> + scsi_command_normalize_sense(cmd, &sshdr)) {
> + __entry->sense_key = sshdr.sense_key;
> + __entry->asc = sshdr.asc;
> + __entry->ascq = sshdr.ascq;
> + } else {
> + __entry->sense_key = 0;
> + __entry->asc = 0;
> + __entry->ascq = 0;
> + }
> ),
>
> TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u " \
> "prot_op=%s driver_tag=%d scheduler_tag=%d cmnd=(%s %s raw=%s) " \
> - "result=(driver=%s host=%s message=%s status=%s)",
> + "result=(driver=%s host=%s message=%s status=%s) "
> + "sense=(key=%#x asc=%#x ascq=%#x)",
> __entry->host_no, __entry->channel, __entry->id,
> __entry->lun, __entry->data_sglen, __entry->prot_sglen,
> show_prot_op_name(__entry->prot_op), __entry->driver_tag,
> @@ -299,7 +315,8 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
> "DRIVER_OK",
> show_hostbyte_name(((__entry->result) >> 16) & 0xff),
> "COMMAND_COMPLETE",
> - show_statusbyte_name(__entry->result & 0xff))
> + show_statusbyte_name(__entry->result & 0xff),
> + __entry->sense_key, __entry->asc, __entry->ascq)
> );
>
> DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done,
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 0/3] SCSI core patches
2023-05-18 19:31 [PATCH v4 0/3] SCSI core patches Bart Van Assche
` (2 preceding siblings ...)
2023-05-18 19:31 ` [PATCH v4 3/3] scsi: core: Only kick the requeue list if necessary Bart Van Assche
@ 2023-05-31 15:06 ` Martin K. Petersen
2023-06-08 1:42 ` Martin K. Petersen
4 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2023-05-31 15:06 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Martin K . Petersen, Christoph Hellwig, linux-scsi
Bart,
> Please consider these SCSI core patches for the next merge window.
Applied to 6.5/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 0/3] SCSI core patches
2023-05-18 19:31 [PATCH v4 0/3] SCSI core patches Bart Van Assche
` (3 preceding siblings ...)
2023-05-31 15:06 ` [PATCH v4 0/3] SCSI core patches Martin K. Petersen
@ 2023-06-08 1:42 ` Martin K. Petersen
4 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2023-06-08 1:42 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Martin K . Petersen, Christoph Hellwig, linux-scsi
On Thu, 18 May 2023 12:31:56 -0700, Bart Van Assche wrote:
> Please consider these SCSI core patches for the next merge window.
>
> Thanks,
>
> Bart.
>
> Changes compared to v3:
> - Changed the SCSI tracing format to make it less likely to break existing
> user space software that parses SCSI trace information.
> - Dropped patch "Delay running the queue if the host is blocked".
>
> [...]
Applied to 6.5/scsi-queue, thanks!
[1/3] scsi: core: Use min() instead of open-coding it
https://git.kernel.org/mkp/scsi/c/416dace649c4
[2/3] scsi: core: Trace SCSI sense data
https://git.kernel.org/mkp/scsi/c/8bb1c6243c4b
[3/3] scsi: core: Only kick the requeue list if necessary
https://git.kernel.org/mkp/scsi/c/8b566edbdbfb
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-06-08 1:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-18 19:31 [PATCH v4 0/3] SCSI core patches Bart Van Assche
2023-05-18 19:31 ` [PATCH v4 1/3] scsi: core: Use min() instead of open-coding it Bart Van Assche
2023-05-18 19:31 ` [PATCH v4 2/3] scsi: core: Trace SCSI sense data Bart Van Assche
2023-05-19 7:03 ` Ming Lei
2023-05-19 9:35 ` Niklas Cassel
2023-05-18 19:31 ` [PATCH v4 3/3] scsi: core: Only kick the requeue list if necessary Bart Van Assche
2023-05-31 15:06 ` [PATCH v4 0/3] SCSI core patches Martin K. Petersen
2023-06-08 1:42 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).