mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jinlong Chen" <nickyc975@zju.edu.cn>
To: "Christoph Hellwig" <hch@lst.de>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH 4/4] blk-mq: improve readability of blk_mq_alloc_request()
Date: Wed, 2 Nov 2022 10:19:24 +0800 (GMT+08:00)	[thread overview]
Message-ID: <3caa5abc.16387a.1843622d8cf.Coremail.nickyc975@zju.edu.cn> (raw)
In-Reply-To: <20221101173727.GC20690@lst.de>

> On Tue, Nov 01, 2022 at 11:11:37PM +0800, Jinlong Chen wrote:
> > Add a helper blk_mq_alloc_request_nocache() to alloc request without
> > cache. This makes blk_mq_alloc_request() more readable.
> > 
> > Signed-off-by: Jinlong Chen <nickyc975@zju.edu.cn>
> > ---
> >  block/blk-mq.c | 47 +++++++++++++++++++++++++++++------------------
> >  1 file changed, 29 insertions(+), 18 deletions(-)
> > 
> > diff --git a/block/blk-mq.c b/block/blk-mq.c
> > index 87a6348a0d0a..2fae111a42c8 100644
> > --- a/block/blk-mq.c
> > +++ b/block/blk-mq.c
> > @@ -572,36 +572,47 @@ static struct request *blk_mq_alloc_cached_request(struct request_queue *q,
> >  	return rq;
> >  }
> >  
> > +static struct request *blk_mq_alloc_request_nocache(struct request_queue *q,
> > +		blk_opf_t opf, blk_mq_req_flags_t flags)
> 
> The name is a bit odd, but I can't think off a better one.
> 
> > +	struct blk_mq_alloc_data data = {
> >  			.q		= q,
> >  			.flags		= flags,
> >  			.cmd_flags	= opf,
> >  			.nr_tags	= 1,
> >  		};
> 
> And this now has superflous indenation.  Overall, while the separate
> helper looks marginally nicer, I'm not really sure it is worth the
> churn.

I'll drop the patch if you think it is not worth the churn. But I
started doing this because of the following goto statement:

	rq = blk_mq_alloc_cached_request(q, opf, flags);
	if (!rq) {
		[...]
		ret = blk_queue_enter(q, flags);
		[...]
		rq = __blk_mq_alloc_requests(&data);
		if (!rq)
			goto out_queue_exit;
	}
	[...]
out_queue_exit:
	blk_queue_exit(q);
	return ERR_PTR(-EWOULDBLOCK);

Queue entering has been moved into the fallback path, left queue exiting
outside. Should I just eliminate the goto statement and move the error
handling into the fallback path too? Like:

	rq = blk_mq_alloc_cached_request(q, opf, flags);
	if (!rq) {
		[...]
		ret = blk_queue_enter(q, flags);
		[...]
		rq = __blk_mq_alloc_requests(&data);
		if (!rq) {
			blk_queue_exit(q);
			return ERR_PTR(-EWOULDBLOCK);
		}
	}

Thanks!
Jinlong Chen

  parent reply	other threads:[~2022-11-02  2:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 15:11 [PATCH 0/4] some random cleanups for blk-mq.c Jinlong Chen
2022-11-01 15:11 ` [PATCH 1/4] blk-mq: update comment for blk_mq_quiesce_queue_nowait() Jinlong Chen
2022-11-01 17:27   ` Christoph Hellwig
2022-11-02  1:44     ` Jinlong Chen
2022-11-01 15:11 ` [PATCH 2/4] blk-mq: improve error handling in blk_mq_alloc_rq_map() Jinlong Chen
2022-11-01 17:34   ` Christoph Hellwig
2022-11-01 18:18     ` Jens Axboe
2022-11-01 15:11 ` [PATCH 3/4] blk-mq: use if-else instead of goto in blk_mq_alloc_cached_request() Jinlong Chen
2022-11-01 17:35   ` Christoph Hellwig
2022-11-01 15:11 ` [PATCH 4/4] blk-mq: improve readability of blk_mq_alloc_request() Jinlong Chen
2022-11-01 17:37   ` Christoph Hellwig
2022-11-02  1:16     ` Chaitanya Kulkarni
2022-11-02  2:19     ` Jinlong Chen [this message]
2022-11-02  2:25       ` Jens Axboe
2022-11-02  2:39         ` Jinlong Chen

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=3caa5abc.16387a.1843622d8cf.Coremail.nickyc975@zju.edu.cn \
    --to=nickyc975@zju.edu.cn \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®