diff mbox series

sg: remove bad blk_end_request_all() call

Message ID c7d6a8d6-ec82-e57a-632d-dcea643ce9ab@kernel.dk (mailing list archive)
State Accepted
Headers show
Series sg: remove bad blk_end_request_all() call | expand

Commit Message

Jens Axboe Oct. 16, 2018, 2:38 p.m. UTC
We just need to free the request here. Additionally, this is
currently wrong for a queue that's using MQ currently, it'll
crash.

Cc: Doug Gilbert <dgilbert@interlog.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/sg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Douglas Gilbert Oct. 16, 2018, 3:23 p.m. UTC | #1
On 2018-10-16 10:38 a.m., Jens Axboe wrote:
> We just need to free the request here. Additionally, this is
> currently wrong for a queue that's using MQ currently, it'll
> crash.

Surprise removals are difficult code paths to check. That snippet
is after the request has been generated and before the call to:
   blk_execute_rq_nowait()

IOWs a small window.

Currently if a surprise removal is detected by the completion
callback (sg_rq_end_io() ) then a pr_info() is called and it
otherwise follows the main path out: free-ing the request,
keeping the bio. Is that okay?

More generally, once a request is "in flight" and a surprise
removal occurs, can the sg driver expect the block layer (or
scsi mid-level) to react (and clean-up) or is it up to the
sg driver to force those actions?

Acked-by: Douglas Gilbert <dgilbert@interlog.com>

> Cc: Doug Gilbert <dgilbert@interlog.com>
> Cc: linux-scsi@vger.kernel.org
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
>   drivers/scsi/sg.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 8a254bb46a9b..c6ad00703c5b 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -822,7 +822,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
>   	if (atomic_read(&sdp->detaching)) {
>   		if (srp->bio) {
>   			scsi_req_free_cmd(scsi_req(srp->rq));
> -			blk_end_request_all(srp->rq, BLK_STS_IOERR);
> +			blk_put_request(srp->rq);
>   			srp->rq = NULL;
>   		}
>   
>
Martin K. Petersen Oct. 16, 2018, 9:50 p.m. UTC | #2
Jens,

> We just need to free the request here. Additionally, this is
> currently wrong for a queue that's using MQ currently, it'll
> crash.

Applied to 4.20/scsi-queue.
diff mbox series

Patch

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 8a254bb46a9b..c6ad00703c5b 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -822,7 +822,7 @@  sg_common_write(Sg_fd * sfp, Sg_request * srp,
 	if (atomic_read(&sdp->detaching)) {
 		if (srp->bio) {
 			scsi_req_free_cmd(scsi_req(srp->rq));
-			blk_end_request_all(srp->rq, BLK_STS_IOERR);
+			blk_put_request(srp->rq);
 			srp->rq = NULL;
 		}