diff mbox series

[1/2] block: get rid of useless goto and label in blk_mq_get_new_requests()

Message ID 20211202194741.810957-2-axboe@kernel.dk (mailing list archive)
State New, archived
Headers show
Series Fix bio merge off cached request path | expand

Commit Message

Jens Axboe Dec. 2, 2021, 7:47 p.m. UTC
Expected case is returning a request, just check for success and return
the request rather than having an error label.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Christoph Hellwig Dec. 3, 2021, 6:53 a.m. UTC | #1
On Thu, Dec 02, 2021 at 12:47:40PM -0700, Jens Axboe wrote:
> Expected case is returning a request, just check for success and return
> the request rather than having an error label.

I have to say the current flow is much easier to read, but the new
version is indeed shorter.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index ecfc47fad236..ca33cb755c5f 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2720,11 +2720,8 @@  static struct request *blk_mq_get_new_requests(struct request_queue *q,
 	}
 
 	rq = __blk_mq_alloc_requests(&data);
-	if (!rq)
-		goto fail;
-	return rq;
-
-fail:
+	if (rq)
+		return rq;
 	rq_qos_cleanup(q, bio);
 	if (bio->bi_opf & REQ_NOWAIT)
 		bio_wouldblock_error(bio);