linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niklas Cassel <niklas.cassel@wdc.com>
To: "James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>, Hannes Reinecke <hare@suse.de>,
	Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
	linux-block@vger.kernel.org,
	Niklas Cassel <niklas.cassel@wdc.com>
Subject: [PATCH v4 04/19] scsi: core: allow libata to complete successful commands via EH
Date: Thu,  9 Mar 2023 22:54:56 +0100	[thread overview]
Message-ID: <20230309215516.3800571-5-niklas.cassel@wdc.com> (raw)
In-Reply-To: <20230309215516.3800571-1-niklas.cassel@wdc.com>

In SCSI, we get the sense data as part of the completion, for ATA
however, we need to fetch the sense data as an extra step. For an
aborted ATA command the sense data is fetched via libata's
->eh_strategy_handler().

For Command Duration Limits policy 0xD:
The device shall complete the command without error with the additional
sense code set to DATA CURRENTLY UNAVAILABLE.

In order to handle this policy in libata, we intend to send a successful
command via SCSI EH, and let libata's ->eh_strategy_handler() fetch the
sense data for the good command. This is similar to how we handle an
aborted ATA command, just that we need to read the Successful NCQ
Commands log instead of the NCQ Command Error log.

When we get a SATA completion with successful commands, ATA_SENSE will
be set, indicating that some commands in the completion have sense data.

The sense_valid bitmask in the Sense Data for Successful NCQ Commands
log will inform exactly which commands that had sense data, which might
be a subset of all the commands that was completed in the same
completion. (Yet all will have ATA_SENSE set, since the status is per
completion.)

The successful commands that have e.g. a "DATA CURRENTLY UNAVAILABLE"
sense data will have a SCSI ML byte set, so scsi_eh_flush_done_q() will
not set the scmd->result to DID_TIME_OUT for these commands. However,
the successful commands that did not have sense data, must not get their
result marked as DID_TIME_OUT by SCSI EH.

Add a new flag SCMD_FORCE_EH_SUCCESS, which tells SCSI EH to not mark a
command as DID_TIME_OUT, even if it has scmd->result == SAM_STAT_GOOD.

This will be used by libata in a follow-up patch.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/scsi_error.c | 3 ++-
 include/scsi/scsi_cmnd.h  | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 2aa2c2aee6e7..cf5ec5f5f4f6 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -2165,7 +2165,8 @@ void scsi_eh_flush_done_q(struct list_head *done_q)
 			 * scsi_eh_get_sense), scmd->result is already
 			 * set, do not set DID_TIME_OUT.
 			 */
-			if (!scmd->result)
+			if (!scmd->result &&
+			    !(scmd->flags & SCMD_FORCE_EH_SUCCESS))
 				scmd->result |= (DID_TIME_OUT << 16);
 			SCSI_LOG_ERROR_RECOVERY(3,
 				scmd_printk(KERN_INFO, scmd,
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index c2cb5f69635c..526def14e7fb 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -52,6 +52,11 @@ struct scsi_pointer {
 #define SCMD_TAGGED		(1 << 0)
 #define SCMD_INITIALIZED	(1 << 1)
 #define SCMD_LAST		(1 << 2)
+/*
+ * libata uses SCSI EH to fetch sense data for successful commands.
+ * SCSI EH should not overwrite scmd->result when SCMD_FORCE_EH_SUCCESS is set.
+ */
+#define SCMD_FORCE_EH_SUCCESS	(1 << 3)
 #define SCMD_FAIL_IF_RECOVERING	(1 << 4)
 /* flags preserved across unprep / reprep */
 #define SCMD_PRESERVED_FLAGS	(SCMD_INITIALIZED | SCMD_FAIL_IF_RECOVERING)
-- 
2.39.2


  parent reply	other threads:[~2023-03-09 21:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 21:54 [PATCH v4 00/19] Add Command Duration Limits support Niklas Cassel
2023-03-09 21:54 ` [PATCH v4 01/19] ioprio: cleanup interface definition Niklas Cassel
2023-03-16 17:58   ` Bart Van Assche
2023-03-16 18:09     ` Bart Van Assche
2023-03-09 21:54 ` [PATCH v4 02/19] block: introduce ioprio hints Niklas Cassel
2023-03-16  2:00   ` Damien Le Moal
2023-03-16 18:41     ` Bart Van Assche
2023-03-17  9:23       ` Niklas Cassel
2023-03-17 16:56         ` Bart Van Assche
2023-03-09 21:54 ` [PATCH v4 03/19] block: introduce BLK_STS_DURATION_LIMIT Niklas Cassel
2023-03-09 21:54 ` Niklas Cassel [this message]
2023-03-09 21:54 ` [PATCH v4 05/19] scsi: rename and move get_scsi_ml_byte() Niklas Cassel
2023-03-09 21:54 ` [PATCH v4 06/19] scsi: support retrieving sub-pages of mode pages Niklas Cassel
2023-03-09 21:54 ` [PATCH v4 07/19] scsi: support service action in scsi_report_opcode() Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 08/19] scsi: detect support for command duration limits Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 09/19] scsi: allow enabling and disabling " Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 10/19] scsi: sd: set read/write commands CDL index Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 11/19] scsi: sd: handle read/write CDL timeout failures Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 12/19] ata: libata-scsi: remove unnecessary !cmd checks Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 13/19] ata: libata: change ata_eh_request_sense() to not set CHECK_CONDITION Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 14/19] ata: libata: detect support for command duration limits Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 15/19] ata: libata-scsi: handle CDL bits in ata_scsiop_maint_in() Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 16/19] ata: libata-scsi: add support for CDL pages mode sense Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 17/19] ata: libata: add ATA feature control sub-page translation Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 18/19] ata: libata: set read/write commands CDL index Niklas Cassel
2023-03-09 21:55 ` [PATCH v4 19/19] ata: libata: handle completion of CDL commands using policy 0xD Niklas Cassel

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=20230309215516.3800571-5-niklas.cassel@wdc.com \
    --to=niklas.cassel@wdc.com \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jejb@linux.ibm.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --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 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).