From: Tejun Heo <tj@kernel.org>
To: Gwendal Grignou <gwendal@google.com>
Cc: linux-ide@vger.kernel.org
Subject: Re: [PATCH] Do not send RW commands to locked disks.
Date: Wed, 02 Sep 2009 10:39:18 +0900 [thread overview]
Message-ID: <4A9DCCC6.6040102@kernel.org> (raw)
In-Reply-To: <1251851285-9159-1-git-send-email-gwendal@google.com>
Gwendal Grignou wrote:
> Send a Read/Write command to a locked disk triggers the error handler.
> Given the disk returns a generic device error code, the error handler can come
> to the conclusion of reducing the link speed, which is bad.
> Also, if drives are still locked at boot, this fix speeds up the boot process
> by returning errors without invoquing the error handler thread.
>
> Signed-off-by: Gwendal Grignou <gwendal@google.com>
> ---
> drivers/ata/libata-core.c | 2 ++
> drivers/ata/libata-scsi.c | 6 ++++++
> include/linux/ata.h | 3 +++
> 3 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index 072ba5e..3f80570 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -5023,6 +5023,8 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
> qc->tf.feature != SETFEATURES_WC_OFF)
> break;
> /* fall through */
> + case ATA_CMD_SEC_UNLOCK: /* Read/Write access now work */
> + case ATA_CMD_SEC_ERASE_UNIT: /* Read/Write access now work */
> case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
> case ATA_CMD_SET_MULTI: /* multi_count changed */
> /* revalidate device */
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index d0dfeef..8a41767 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -1658,6 +1658,12 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
> u32 n_block;
> int rc;
>
> + if (unlikely(ata_id_locked(qc->dev->id))) {
> + /* Terminate RW commands early when the disk is locked */
> + ata_scsi_set_sense(scmd, ABORTED_COMMAND, 0, 0);
> + return 1;
> + }
> +
> if (cdb[0] == WRITE_10 || cdb[0] == WRITE_6 || cdb[0] == WRITE_16)
> tf_flags |= ATA_TFLAG_WRITE;
Hmmm... how sure are we that there aren't some braindead devices which
incorrectly would trigger the ata_id_locked() condition? I think it
would be safer to have an extra DFLAG, say ATA_DFLAG_LOCKED which gets
set when EH detects unknown device error && ata_id_locked(); then, in
the issue path, we can do
if (ATA_DFLAG_LOCKED is set) {
if (ata_id_locked())
Terminate early;
else
Clear ATA_DFLAG_LOCKED;
}
Thanks.
--
tejun
next prev parent reply other threads:[~2009-09-02 1:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-02 0:28 [PATCH] Do not send RW commands to locked disks Gwendal Grignou
2009-09-02 1:39 ` Tejun Heo [this message]
2009-09-02 21:43 ` Gwendal Grignou
2009-09-02 23:03 ` Tejun Heo
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=4A9DCCC6.6040102@kernel.org \
--to=tj@kernel.org \
--cc=gwendal@google.com \
--cc=linux-ide@vger.kernel.org \
/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).