All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <jejb@linux.vnet.ibm.com>
To: Bart Van Assche <bart.vanassche@sandisk.com>,
	Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org, gabriel@krisman.be,
	brking@linux.vnet.ibm.com
Subject: Re: [PATCH v3 1/2] scsi: Handle Unit Attention when issuing SCSI command
Date: Tue, 25 Oct 2016 15:23:57 -0700	[thread overview]
Message-ID: <1477434237.3079.84.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <27d08f8f-bbf5-1298-1985-f0c3ee45d2d1@sandisk.com>

On Tue, 2016-10-25 at 15:16 -0700, Bart Van Assche wrote:
> On 10/23/2016 08:20 PM, Gabriel Krisman Bertazi wrote:
> > +
> >  /**
> >   * scsi_execute - insert request and wait for the result
> >   * @sdev:	scsi device
> > @@ -187,7 +197,14 @@ int scsi_execute(struct scsi_device *sdev,
> > const unsigned char *cmd,
> >  	struct request *req;
> >  	int write = (data_direction == DMA_TO_DEVICE);
> >  	int ret = DRIVER_ERROR << 24;
> > +	unsigned char sense_buf[SCSI_SENSE_BUFFERSIZE];
> > 
> > +	if (!sense) {
> > +		sense = sense_buf;
> > +		memset(sense, 0, SCSI_SENSE_BUFFERSIZE);
> > +	}
> > +
> > + retry:
> >  	req = blk_get_request(sdev->request_queue, write,
> > __GFP_RECLAIM);
> >  	if (IS_ERR(req))
> >  		return ret;
> > @@ -210,6 +227,13 @@ int scsi_execute(struct scsi_device *sdev,
> > const unsigned char *cmd,
> >  	 */
> >  	blk_execute_rq(req->q, NULL, req, 1);
> > 
> > +	if (scsi_sense_unit_attention(sense) && req->retries > 0)
> > {
> > +		memset(sense, 0, SCSI_SENSE_BUFFERSIZE);
> > +		retries = req->retries - 1;
> > +		blk_put_request(req);
> > +		goto retry;
> > +	}
> > +
> >  	/*
> >  	 * Some devices (USB mass-storage in particular) may
> > transfer
> >  	 * garbage data together with a residue indicating that
> > the data
> 
>  From scsi_io_completion():
> 
> 	if (sense_valid && !sense_deferred) {
> 		switch (sshdr.sense_key) {
> 		case UNIT_ATTENTION:
> 			if (cmd->device->removable) {
> 				cmd->device->changed = 1;
> 				action = ACTION_FAIL;
> 			} else {
> 				action = ACTION_RETRY;
> 			}
> 			[ ... ]
> 
> Why do you think new retry code is needed in scsi_execute()?

Because scsi_execute uses REQ_BLOCK_PC which is completed before you
get to that code.

James



  reply	other threads:[~2016-10-25 22:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24  3:20 [PATCH v3 1/2] scsi: Handle Unit Attention when issuing SCSI command Gabriel Krisman Bertazi
2016-10-24  3:20 ` [PATCH v3 2/2] scsi: sr: Drop custom handling of unit attention Gabriel Krisman Bertazi
2016-10-25 13:00 ` [PATCH v3 1/2] scsi: Handle Unit Attention when issuing SCSI command Benjamin Block
2016-10-25 22:16 ` Bart Van Assche
2016-10-25 22:23   ` James Bottomley [this message]
2016-10-25 23:18     ` Bart Van Assche
2016-10-25 23:50       ` James Bottomley
2016-10-26 15:42         ` Bart Van Assche
2016-10-26 15:52           ` James Bottomley
2016-10-26 16:15             ` Bart Van Assche
2016-10-26 17:38               ` Brian King
2016-10-27  9:00                 ` Hannes Reinecke
2016-10-28  7:32                   ` 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=1477434237.3079.84.camel@linux.vnet.ibm.com \
    --to=jejb@linux.vnet.ibm.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=gabriel@krisman.be \
    --cc=krisman@linux.vnet.ibm.com \
    --cc=linux-scsi@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 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.