All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Jiri Slaby <jirislaby@kernel.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	Johannes Thumshirn <jthumshirn@suse.de>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Date: Thu, 10 Jun 2021 16:01:46 +0200	[thread overview]
Message-ID: <723d9d8b-5dde-839f-efe6-164177f5c1ce@suse.de> (raw)
In-Reply-To: <6d5c893d-61c1-fad9-78f5-17b41f19706d@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 2033 bytes --]

On 6/10/21 12:52 PM, Jiri Slaby wrote:
> On 07. 06. 21, 15:02, Hannes Reinecke wrote:
>> On 6/7/21 2:30 PM, Martin K. Petersen wrote:
>>>
>>> Hannes,
>>>
>>>>> Any ideas?
>>>
>>>>> Can you enable SCSI logging via
>>>>
>>>> scsi.scsi_logging_level=216
>>>>
>>>> on the kernel commandline and send me the output?
>>>
>>> You now effectively set SAM_STAT_CHECK_CONDITION if the scsi_cmnd has a
>>> sense buffer.
>>>
>>> The original code only set DRIVER_SENSE if the adapter response actually
>>> contained sense information:
>>>
>>> @@ -161,8 +161,7 @@ static void virtscsi_complete_cmd(struct
>>> virtio_scsi *vscsi, void *buf)
>>>                         min_t(u32,
>>>                               virtio32_to_cpu(vscsi->vdev,
>>> resp->sense_len),
>>>                               VIRTIO_SCSI_SENSE_SIZE));
>>> -               if (resp->sense_len)
>>> -                       set_driver_byte(sc, DRIVER_SENSE);
>>> +               set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
>>>          }
>>>
>> Oh, I know. But we're checking for a valid sense code during scanning:
>>
>>             if (scsi_status_is_check_condition(result) &&
>>                 scsi_sense_valid(&sshdr)) {
>>
>> so if that makes a difference it would mean that the virtio driver has
>> some stale sense data which then gets copied over.
>> Anyway.
>> Can you test with this patch?
> 
> Yes, that boots, but is somehow sloooow (hard to tell what is causing
> this).
> 
> Anyway, the new print is still there with the patch:
> [   11.549986] sd 0:0:0:0: Power-on or device reset occurred
> 
> Cool; one step further.
Can you check if the attached patch helps, too?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		        Kernel Storage Architect
hare@suse.de			               +49 911 74053 688
SUSE Software Solutions Germany GmbH, 90409 Nürnberg
GF: F. Imendörffer, HRB 36809 (AG Nürnberg)

[-- Attachment #2: 0002-scsi-do-not-assume-CHECK_CONDITION-is-set-for-valid-.patch --]
[-- Type: text/x-patch, Size: 2519 bytes --]

From f60b3ab985a555cd623b77f6da95cb094da08d2a Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Thu, 10 Jun 2021 15:46:56 +0200
Subject: [PATCH 2/2] scsi: do not assume CHECK_CONDITION is set for valid
 sense code

While the standard implies that a sense code should be returned in
response to CHECK CONDITION status, it _might_ be returned on other
status codes, too.
At least, that's what the original code assumed. So it's arguably
wrong to assume we only will have a valid sense code when CHECK
CONDITION is set.

Fixes: 464a00c9e0ad ("scsi: core: Kill DRIVER_SENSE")
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/sd.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 20739072f21a..821bbcfe68c9 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1722,8 +1722,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
 		if (res < 0)
 			return res;
 
-		if (scsi_status_is_check_condition(res) &&
-		    scsi_sense_valid(sshdr)) {
+		if (scsi_sense_valid(sshdr)) {
 			sd_print_sense_hdr(sdkp, sshdr);
 
 			/* we need to evaluate the error return  */
@@ -1829,10 +1828,10 @@ static int sd_pr_command(struct block_device *bdev, u8 sa,
 	result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data),
 			&sshdr, SD_TIMEOUT, sdkp->max_retries, NULL);
 
-	if (scsi_status_is_check_condition(result) &&
-	    scsi_sense_valid(&sshdr)) {
+	if (result) {
 		sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result);
-		scsi_print_sense_hdr(sdev, NULL, &sshdr);
+		if (scsi_sense_valid(&sshdr))
+			scsi_print_sense_hdr(sdev, NULL, &sshdr);
 	}
 
 	return result;
@@ -2073,7 +2072,7 @@ static int sd_done(struct scsi_cmnd *SCpnt)
 	}
 	sdkp->medium_access_timed_out = 0;
 
-	if (!scsi_status_is_check_condition(result) &&
+	if (result &&
 	    (!sense_valid || sense_deferred))
 		goto out;
 
@@ -2178,10 +2177,9 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 			retries++;
 		} while (retries < 3 &&
 			 (!scsi_status_is_good(the_result) ||
-			  (scsi_status_is_check_condition(the_result) &&
-			  sense_valid && sshdr.sense_key == UNIT_ATTENTION)));
+			  (sense_valid && sshdr.sense_key == UNIT_ATTENTION)));
 
-		if (!scsi_status_is_check_condition(the_result)) {
+		if (the_result < 0 || !sense_valid) {
 			/* no sense, TUR either succeeded or failed
 			 * with a status error */
 			if(!spintime && !scsi_status_is_good(the_result)) {
-- 
2.26.2


  reply	other threads:[~2021-06-10 14:01 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21  9:52 [PATCH RFC 00/24] scsi: Revamp result values Hannes Reinecke
2019-10-21  9:52 ` [PATCH 01/24] aic7xxx,aic79xxx: remove driver-defined SAM status definitions Hannes Reinecke
2019-10-21  9:53 ` [PATCH 02/24] bfa: drop driver-defined SCSI status codes Hannes Reinecke
2019-10-21  9:53 ` [PATCH 03/24] wd33c93: use SCSI status Hannes Reinecke
2019-10-21 18:41   ` kbuild test robot
2019-10-21 18:41     ` kbuild test robot
2019-10-21 23:16   ` Finn Thain
2019-10-22  5:59     ` Hannes Reinecke
2019-10-21  9:53 ` [PATCH 04/24] acornscsi: use standard defines Hannes Reinecke
2019-10-21  9:53 ` [PATCH 05/24] scsi: use standard SAM status codes Hannes Reinecke
2019-10-21 23:17   ` Finn Thain
2019-10-22  6:00     ` Hannes Reinecke
2019-10-21  9:53 ` [PATCH 06/24] scsi: change status_byte() to return the standard SCSI status Hannes Reinecke
2019-10-22 12:35   ` Steffen Maier
2019-10-21  9:53 ` [PATCH 07/24] target_core: Fixup target_complete_cmd() usage Hannes Reinecke
2019-10-21  9:53 ` [PATCH 08/24] sg: use SAM status definitions and avoid using masked_status Hannes Reinecke
2019-10-21  9:53 ` [PATCH 09/24] scsi: Kill obsolete linux-specific status codes Hannes Reinecke
2019-10-21 18:12   ` kbuild test robot
2019-10-21 18:12     ` kbuild test robot
2019-10-21 18:56   ` kbuild test robot
2019-10-21 18:56     ` kbuild test robot
2019-10-21  9:53 ` [PATCH 10/24] scsi: introduce set_status_byte() Hannes Reinecke
2019-10-21 22:12   ` Finn Thain
2019-10-22  5:56     ` Hannes Reinecke
2019-10-21  9:53 ` [PATCH 11/24] advansys: kill driver_defined status byte accessors Hannes Reinecke
2019-10-21 16:37   ` Bart Van Assche
2019-10-22  6:25     ` Hannes Reinecke
2019-10-21  9:53 ` [PATCH 12/24] scsi: introduce scsi_build_sense() Hannes Reinecke
2019-10-21 23:31   ` Finn Thain
2019-10-22  6:02     ` Hannes Reinecke
2019-10-22 12:21   ` Steffen Maier
2019-10-21  9:53 ` [PATCH 13/24] scsi: Kill DRIVER_SENSE Hannes Reinecke
2019-10-21 23:44   ` Finn Thain
2019-10-22  6:10     ` Hannes Reinecke
2021-06-04  6:40   ` Jiri Slaby
2021-06-07 12:21     ` Hannes Reinecke
2021-06-07 12:30       ` Martin K. Petersen
2021-06-07 13:02         ` Hannes Reinecke
2021-06-10 10:52           ` Jiri Slaby
2021-06-10 14:01             ` Hannes Reinecke [this message]
2021-06-11  4:50               ` Jiri Slaby
2021-06-11  7:38                 ` Hannes Reinecke
2021-06-14  6:29                   ` Jiri Slaby
2021-06-14  7:20                   ` Jiri Slaby
2019-10-21  9:53 ` [PATCH 14/24] scsi: Kill DRIVER_HARD Hannes Reinecke
2019-10-21  9:53 ` [PATCH 15/24] scsi_error: use DID_TIME_OUT instead of DRIVER_TIMEOUT Hannes Reinecke
2019-10-21  9:53 ` [PATCH 16/24] scsi: Kill DRIVER_TIMEOUT Hannes Reinecke
2019-10-21  9:53 ` [PATCH 17/24] scsi: do not use DRIVER_INVALID Hannes Reinecke
2019-10-21  9:53 ` [PATCH 18/24] st: return error code in st_scsi_execute() Hannes Reinecke
2019-10-21 16:41   ` Bart Van Assche
2019-10-22  6:28     ` Hannes Reinecke
2019-10-22 14:54       ` Bart Van Assche
2019-10-21  9:53 ` [PATCH 19/24] scsi_ioctl: return error code when blk_map_user() fails Hannes Reinecke
2019-10-21 16:44   ` Bart Van Assche
2019-10-22  6:32     ` Hannes Reinecke
2019-10-21  9:53 ` [PATCH 20/24] scsi_dh_alua: do not interpret DRIVER_ERROR Hannes Reinecke
2019-10-21  9:53 ` [PATCH 21/24] xen-scsiback: stop using DRIVER_ERROR Hannes Reinecke
2019-10-21  9:53 ` [PATCH 22/24] scsi: " Hannes Reinecke
2019-10-21  9:53 ` [PATCH 23/24] scsi: Kill DRIVER_MEDIA, DRIVER_SOFT, and DRIVER_BUSY Hannes Reinecke
2019-10-21  9:53 ` [PATCH 24/24] scsi: Drop now obsolete driver_byte definitions Hannes Reinecke
2019-10-21 18:32 ` [PATCH RFC 00/24] scsi: Revamp result values Douglas Gilbert
2019-10-21 23:20   ` Finn Thain
2019-10-22  6:24   ` Hannes Reinecke
2019-10-31 11:04 [PATCHv2 00/24] Revamp SCSI " Hannes Reinecke
2019-10-31 11:04 ` [PATCH 13/24] scsi: Kill DRIVER_SENSE Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=723d9d8b-5dde-839f-efe6-164177f5c1ce@suse.de \
    --to=hare@suse.de \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=jirislaby@kernel.org \
    --cc=jthumshirn@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.