* [PATCH] scsi_logging: print cdb into new line after opcode
@ 2021-01-22 8:39 Martin Kepplinger
2021-01-22 19:52 ` Ewan D. Milne
0 siblings, 1 reply; 4+ messages in thread
From: Martin Kepplinger @ 2021-01-22 8:39 UTC (permalink / raw)
To: jejb, martin.petersen
Cc: dgilbert, bvanassche, linux-scsi, linux-kernel, Martin Kepplinger
The current log message results in a line like the following where
the first byte is duplicated, giving a wrong impression:
sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28 28 00 00 00 60 40 00 00 01 00
Print the cdb into a new line in any case, not only when cmd_len is
greater than 16. The above example error will then read:
sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28
28 00 01 c0 09 00 00 00 08 00
Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
drivers/scsi/scsi_logging.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c
index 8ea44c6595ef..0081d3936f83 100644
--- a/drivers/scsi/scsi_logging.c
+++ b/drivers/scsi/scsi_logging.c
@@ -200,10 +200,11 @@ void scsi_print_command(struct scsi_cmnd *cmd)
if (off >= logbuf_len)
goto out_printk;
+ /* Print opcode in one line and use separate lines for CDB */
+ off += scnprintf(logbuf + off, logbuf_len - off, "\n");
+
/* print out all bytes in cdb */
if (cmd->cmd_len > 16) {
- /* Print opcode in one line and use separate lines for CDB */
- off += scnprintf(logbuf + off, logbuf_len - off, "\n");
dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf);
for (k = 0; k < cmd->cmd_len; k += 16) {
size_t linelen = min(cmd->cmd_len - k, 16);
@@ -224,7 +225,6 @@ void scsi_print_command(struct scsi_cmnd *cmd)
goto out;
}
if (!WARN_ON(off > logbuf_len - 49)) {
- off += scnprintf(logbuf + off, logbuf_len - off, " ");
hex_dump_to_buffer(cmd->cmnd, cmd->cmd_len, 16, 1,
logbuf + off, logbuf_len - off,
false);
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi_logging: print cdb into new line after opcode
2021-01-22 8:39 [PATCH] scsi_logging: print cdb into new line after opcode Martin Kepplinger
@ 2021-01-22 19:52 ` Ewan D. Milne
2021-01-23 3:09 ` Martin K. Petersen
0 siblings, 1 reply; 4+ messages in thread
From: Ewan D. Milne @ 2021-01-22 19:52 UTC (permalink / raw)
To: Martin Kepplinger, jejb, martin.petersen
Cc: dgilbert, bvanassche, linux-scsi, linux-kernel
On Fri, 2021-01-22 at 09:39 +0100, Martin Kepplinger wrote:
> The current log message results in a line like the following where
> the first byte is duplicated, giving a wrong impression:
>
> sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28 28 00 00 00 60 40 00 00 01
> 00
>
> Print the cdb into a new line in any case, not only when cmd_len is
> greater than 16. The above example error will then read:
>
> sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28
> 28 00 01 c0 09 00 00 00 08 00
>
> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> ---
> drivers/scsi/scsi_logging.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/scsi_logging.c
> b/drivers/scsi/scsi_logging.c
> index 8ea44c6595ef..0081d3936f83 100644
> --- a/drivers/scsi/scsi_logging.c
> +++ b/drivers/scsi/scsi_logging.c
> @@ -200,10 +200,11 @@ void scsi_print_command(struct scsi_cmnd *cmd)
> if (off >= logbuf_len)
> goto out_printk;
>
> + /* Print opcode in one line and use separate lines for CDB */
> + off += scnprintf(logbuf + off, logbuf_len - off, "\n");
> +
> /* print out all bytes in cdb */
> if (cmd->cmd_len > 16) {
> - /* Print opcode in one line and use separate lines for
> CDB */
> - off += scnprintf(logbuf + off, logbuf_len - off, "\n");
> dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s",
> logbuf);
> for (k = 0; k < cmd->cmd_len; k += 16) {
> size_t linelen = min(cmd->cmd_len - k, 16);
> @@ -224,7 +225,6 @@ void scsi_print_command(struct scsi_cmnd *cmd)
> goto out;
> }
> if (!WARN_ON(off > logbuf_len - 49)) {
> - off += scnprintf(logbuf + off, logbuf_len - off, " ");
> hex_dump_to_buffer(cmd->cmnd, cmd->cmd_len, 16, 1,
> logbuf + off, logbuf_len - off,
> false);
I'd rather we not change this.
-Ewan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi_logging: print cdb into new line after opcode
2021-01-22 19:52 ` Ewan D. Milne
@ 2021-01-23 3:09 ` Martin K. Petersen
2021-01-25 7:29 ` Martin Kepplinger
0 siblings, 1 reply; 4+ messages in thread
From: Martin K. Petersen @ 2021-01-23 3:09 UTC (permalink / raw)
To: Ewan D. Milne
Cc: Martin Kepplinger, jejb, martin.petersen, dgilbert, bvanassche,
linux-scsi, linux-kernel
Ewan,
>> sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28 28 00 00 00 60 40 00 00 01
>> 00
>>
>> Print the cdb into a new line in any case, not only when cmd_len is
>> greater than 16. The above example error will then read:
>>
>> sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28
>> 28 00 01 c0 09 00 00 00 08 00
>
> I'd rather we not change this.
I agree. While the current format is suboptimal, there are lots of
things out there parsing these error messages.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi_logging: print cdb into new line after opcode
2021-01-23 3:09 ` Martin K. Petersen
@ 2021-01-25 7:29 ` Martin Kepplinger
0 siblings, 0 replies; 4+ messages in thread
From: Martin Kepplinger @ 2021-01-25 7:29 UTC (permalink / raw)
To: Martin K. Petersen, Ewan D. Milne
Cc: jejb, dgilbert, bvanassche, linux-scsi, linux-kernel
On 23.01.21 04:09, Martin K. Petersen wrote:
>
> Ewan,
>
>>> sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28 28 00 00 00 60 40 00 00 01
>>> 00
>>>
>>> Print the cdb into a new line in any case, not only when cmd_len is
>>> greater than 16. The above example error will then read:
>>>
>>> sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28
>>> 28 00 01 c0 09 00 00 00 08 00
>>
>> I'd rather we not change this.
>
> I agree. While the current format is suboptimal, there are lots of
> things out there parsing these error messages.
>
hi Ewan, hi Martin,
That's totally fine. I had this on my list since Douglas suggested to
change this during a discussion back in july and I basically wanted to
get opinions:
https://lore.kernel.org/linux-scsi/31f1ec62-7047-a34b-fdcb-5ea2a2104292@interlog.com/
thanks,
martin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-01-25 7:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 8:39 [PATCH] scsi_logging: print cdb into new line after opcode Martin Kepplinger
2021-01-22 19:52 ` Ewan D. Milne
2021-01-23 3:09 ` Martin K. Petersen
2021-01-25 7:29 ` Martin Kepplinger
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).