linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Jaesoo Lee <jalee@purestorage.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Jens Axboe <axboe@kernel.dk>,
	Douglas Gilbert <dgilbert@interlog.com>
Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
	Roland Dreier <roland@purestorage.com>
Subject: Re: [PATCHv2] scsi: core: set result when the command cannot be dispatched
Date: Wed, 10 Apr 2019 09:26:36 -0700	[thread overview]
Message-ID: <1554913596.161891.24.camel@acm.org> (raw)
In-Reply-To: <CAJX3CtgE5oN=uw2rAWS8hsqkEZHCgfy5r=McFTj0rhRd490HhQ@mail.gmail.com>

On Tue, 2019-04-09 at 17:02 -0700, Jaesoo Lee wrote:
> When SCSI blk-mq is enabled, there is a bug in handling errors in scsi_queue_rq.
> Specifically, the bug is not setting result field of scsi_request correctly when
> the dispatch of the command has been failed. Since the upper layer code
> including the sg_io ioctl expects to receive any error status from result field
> of scsi_request, the error is silently ignored and this could cause data
> corruptions for some applications.
> 
> Signed-off-by: Jaesoo Lee <jalee@purestorage.com>
> ---
>  drivers/scsi/scsi_lib.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 2018967..dc2550c 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1699,8 +1699,12 @@ static blk_status_t scsi_queue_rq(struct
> blk_mq_hw_ctx *hctx,
>                         ret = BLK_STS_DEV_RESOURCE;
>                 break;
>         default:
> +               if (unlikely(!scsi_device_online(sdev)))
> +                       scsi_req(req)->result = DID_NO_CONNECT << 16;
> +               else
> +                       scsi_req(req)->result = DID_ERROR << 16;
>                 /*
> -                * Make sure to release all allocated ressources when
> +                * Make sure to release all allocated resources when
>                  * we hit an error, as we will never see this command
>                  * again.
>                  */

Should "Fixes:" and "Cc: stable" tags be added to this patch?

Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>



  parent reply	other threads:[~2019-04-10 16:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1554854375-7708-1-git-send-email-jalee@purestorage.com>
2019-04-10  0:02 ` [PATCHv2] scsi: core: set result when the command cannot be dispatched Jaesoo Lee
2019-04-10  5:58   ` Hannes Reinecke
2019-04-10 16:26   ` Bart Van Assche [this message]
2019-04-16  2:36   ` Martin K. Petersen

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=1554913596.161891.24.camel@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=dgilbert@interlog.com \
    --cc=jalee@purestorage.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=roland@purestorage.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).