linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: drop device references in bsg_queue_rq()
@ 2019-09-23 14:02 Martin Wilck
  2019-09-23 17:17 ` Jens Axboe
  2019-09-24  5:56 ` Hannes Reinecke
  0 siblings, 2 replies; 3+ messages in thread
From: Martin Wilck @ 2019-09-23 14:02 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Johannes Thumshirn, Hannes Reinecke, Martin Wilck, linux-block

From: Martin Wilck <mwilck@suse.com>

Make sure that bsg_queue_rq() calls put_device() if an error is
encountered after get_device() was successful.

Fixes: cd2f076f1d7a ("bsg: convert to use blk-mq")
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 block/bsg-lib.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/block/bsg-lib.c b/block/bsg-lib.c
index 785dd58..347dda1 100644
--- a/block/bsg-lib.c
+++ b/block/bsg-lib.c
@@ -266,6 +266,7 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,
 	struct request *req = bd->rq;
 	struct bsg_set *bset =
 		container_of(q->tag_set, struct bsg_set, tag_set);
+	int sts = BLK_STS_IOERR;
 	int ret;
 
 	blk_mq_start_request(req);
@@ -274,14 +275,15 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,
 		return BLK_STS_IOERR;
 
 	if (!bsg_prepare_job(dev, req))
-		return BLK_STS_IOERR;
+		goto out;
 
 	ret = bset->job_fn(blk_mq_rq_to_pdu(req));
-	if (ret)
-		return BLK_STS_IOERR;
+	if (!ret)
+		sts = BLK_STS_OK;
 
+out:
 	put_device(dev);
-	return BLK_STS_OK;
+	return sts;
 }
 
 /* called right after the request is allocated for the request_queue */
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: drop device references in bsg_queue_rq()
  2019-09-23 14:02 [PATCH] block: drop device references in bsg_queue_rq() Martin Wilck
@ 2019-09-23 17:17 ` Jens Axboe
  2019-09-24  5:56 ` Hannes Reinecke
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2019-09-23 17:17 UTC (permalink / raw)
  To: Martin Wilck; +Cc: Johannes Thumshirn, Hannes Reinecke, linux-block

On 9/23/19 8:02 AM, Martin Wilck wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> Make sure that bsg_queue_rq() calls put_device() if an error is
> encountered after get_device() was successful.

Thanks, looks good to me, applied.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: drop device references in bsg_queue_rq()
  2019-09-23 14:02 [PATCH] block: drop device references in bsg_queue_rq() Martin Wilck
  2019-09-23 17:17 ` Jens Axboe
@ 2019-09-24  5:56 ` Hannes Reinecke
  1 sibling, 0 replies; 3+ messages in thread
From: Hannes Reinecke @ 2019-09-24  5:56 UTC (permalink / raw)
  To: Martin Wilck, Jens Axboe; +Cc: Johannes Thumshirn, linux-block

On 9/23/19 4:02 PM, Martin Wilck wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> Make sure that bsg_queue_rq() calls put_device() if an error is
> encountered after get_device() was successful.
> 
> Fixes: cd2f076f1d7a ("bsg: convert to use blk-mq")
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  block/bsg-lib.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/block/bsg-lib.c b/block/bsg-lib.c
> index 785dd58..347dda1 100644
> --- a/block/bsg-lib.c
> +++ b/block/bsg-lib.c
> @@ -266,6 +266,7 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,
>  	struct request *req = bd->rq;
>  	struct bsg_set *bset =
>  		container_of(q->tag_set, struct bsg_set, tag_set);
> +	int sts = BLK_STS_IOERR;
>  	int ret;
>  
>  	blk_mq_start_request(req);
> @@ -274,14 +275,15 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,
>  		return BLK_STS_IOERR;
>  
>  	if (!bsg_prepare_job(dev, req))
> -		return BLK_STS_IOERR;
> +		goto out;
>  
>  	ret = bset->job_fn(blk_mq_rq_to_pdu(req));
> -	if (ret)
> -		return BLK_STS_IOERR;
> +	if (!ret)
> +		sts = BLK_STS_OK;
>  
> +out:
>  	put_device(dev);
> -	return BLK_STS_OK;
> +	return sts;
>  }
>  
>  /* called right after the request is allocated for the request_queue */
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      Teamlead Storage & Networking
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 247165 (AG München), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-24  5:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-23 14:02 [PATCH] block: drop device references in bsg_queue_rq() Martin Wilck
2019-09-23 17:17 ` Jens Axboe
2019-09-24  5:56 ` Hannes Reinecke

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).