linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: James Bottomley <James.Bottomley@suse.de>
Cc: Mike Christie <michaelc@cs.wisc.edu>, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] Retry commands with UNIT_ATTENTION sense codes
Date: Wed, 05 May 2010 08:26:17 +0200	[thread overview]
Message-ID: <4BE10F89.4020101@suse.de> (raw)
In-Reply-To: <1273005003.16631.43.camel@mulgrave.site>

James Bottomley wrote:
> On Tue, 2010-05-04 at 15:27 -0500, Mike Christie wrote:
>> On 05/04/2010 03:15 PM, Mike Christie wrote:
>>> On 05/04/2010 11:26 AM, James Bottomley wrote:
>>>> The other patch is fine, but I don't think this is necessary. The
>>>> reason is that even returning SUCCESS here, we go straight into
>>>> scsi_finish_command() (which passes it up to the driver handler) and
>>>> then scsi_io_completion(). There's a catch for UNIT_ATTENTION in
>>>> scsi_io_completion
>>> The request is sent as a REQ_TYPE_BLOCK_PC (this flag is set for the
>>> request in sd_prepare_flush), and scsi_io_completion's blk_pc_request
>>> check() that returns the request upwards is before the UNIT_ATTENTION
>> I was looking at the wrong source.
>>
>> scsi_finish_command checks for REQ_TYPE_BLOCK_PC and sets good_bytes to 
>> scsi_bufflen, so when scsi_io_completion calls scsi_end_request, it 
>> fails the request before we can get to the UNIT_ATTENTION.
> 
> Ah, yes, missed that.
> 
> However there are other problems then.  We can't just eat all unit
> attentions on the BLOCK_PC path because some of the user programs want
> to see them (CD burners for one).  I know the patch allows some to
> proceed upwards, but it's risky making all except device not started do
> a retry.
> 
> I'm a bit stumped on this one ... the intention of BLOCK_PC is that the
> caller simply retries if they get a unit attention (which is what all
> SCSI code does).  The block code doesn't want to look at the sense data
> but at the error return.  I suppose we could make UNIT_ATTENTION
> translate to -EAGAIN and have block do the right thing?
> 
The intention of BLOCK_PC is ok, but the point here is the barrier
request isn't really a BLOCK_PC request. The caller precisely
does _not_ want to look the sense code but rather have the SCSI
layer do all the necessary things.

Why can't we just mark the barrier request as something else than
BLOCK_PC, eg REQ_TYPE_SPECIAL?
Then we'd avoid these pitfalls and everything should work as expected, right?

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index de6c603..b63f84e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1038,7 +1038,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)
 
 static void sd_prepare_flush(struct request_queue *q, struct request *rq)
 {
-       rq->cmd_type = REQ_TYPE_BLOCK_PC;
+       rq->cmd_type = REQ_TYPE_SPECIAL;
        rq->timeout = SD_TIMEOUT;
        rq->retries = SD_MAX_RETRIES;
        rq->cmd[0] = SYNCHRONIZE_CACHE;

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2010-05-05  6:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-04 14:48 [PATCH] Retry commands with UNIT_ATTENTION sense codes Hannes Reinecke
2010-05-04 16:26 ` James Bottomley
2010-05-04 20:15   ` Mike Christie
2010-05-04 20:27     ` Mike Christie
2010-05-04 20:30       ` James Bottomley
2010-05-04 20:51         ` James Bottomley
2010-05-05  6:26         ` Hannes Reinecke [this message]
2010-05-05 13:19           ` James Bottomley
2010-05-05 13:28             ` Christoph Hellwig

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=4BE10F89.4020101@suse.de \
    --to=hare@suse.de \
    --cc=James.Bottomley@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michaelc@cs.wisc.edu \
    /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).