public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Keith Busch <kbusch@kernel.org>,
	linux-nvme@lists.infradead.org
Subject: Re: [PATCH 1/3] nvme: split __nvme_submit_sync_cmd()
Date: Thu, 9 Feb 2023 06:33:30 +0100	[thread overview]
Message-ID: <20230209053330.GA8536@lst.de> (raw)
In-Reply-To: <20230208151720.109130-2-hare@suse.de>

On Wed, Feb 08, 2023 at 04:17:18PM +0100, Hannes Reinecke wrote:
> Split a __nvme_alloc_rq() function from __nvme_submit_sync_cmd()
> to reduce the number of arguments.

But now everyone has to call both?  

>  6 files changed, 83 insertions(+), 45 deletions(-)

.. and the code is a lot longer.  So this doesn't really seem like
much of a win?
> +struct request *__nvme_alloc_rq(struct request_queue *q,
> +				struct nvme_command *cmd, int qid,
> +				blk_mq_req_flags_t flags)

Why the double underscore profix?  Why _rq instead of _request
like blk_mq_alloc_request and nvme_init_request?

>  {
>  	struct request *req;
>  
>  	if (qid == NVME_QID_ANY)
>  		req = blk_mq_alloc_request(q, nvme_req_op(cmd), flags);
>  	else
>  		req = blk_mq_alloc_request_hctx(q, nvme_req_op(cmd), flags,
>  						qid - 1);
> +	if (!IS_ERR(req))
> +		nvme_init_request(req, cmd);
>  
> +	return req;

And I'd at very least split out the qid case as that is substantially
different and only used in very specific places.

> + */
> +int __nvme_submit_sync_cmd(struct request *req, union nvme_result *result,
> +			   void *buffer, unsigned bufflen, int at_head)
> +{
> +	int ret;
>  
>  	if (buffer && bufflen) {
> -		ret = blk_rq_map_kern(q, req, buffer, bufflen, GFP_KERNEL);
> +		ret = blk_rq_map_kern(req->q, req, buffer, bufflen, GFP_KERNEL);
>  		if (ret)
>  			goto out;

This new __nvme_submit_sync_cmd now consumes the request, which
is an odd calling conventions.

What do you think about:

 - passing the "union nvme_result *result" to nvme_execute_rq, and do the
   conditional assignment to it there, where it fits along with all the
   status management
 - make blk_rq_map_kern handle a NULL kbuf gracefully instead of doing
   that in a lot of the callers
 - just open code __nvme_submit_sync_cmd using these building blocks.


  reply	other threads:[~2023-02-09  5:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 15:17 [PATCHv2 0/3] nvme: rework __nvme_submit_sync_cmd() Hannes Reinecke
2023-02-08 15:17 ` [PATCH 1/3] nvme: split __nvme_submit_sync_cmd() Hannes Reinecke
2023-02-09  5:33   ` Christoph Hellwig [this message]
2023-02-09  7:58     ` Hannes Reinecke
2023-02-08 15:17 ` [PATCH 2/3] nvme: retry authentication commands if DNR status bit is not set Hannes Reinecke
2023-02-08 15:17 ` [PATCH 3/3] nvme: make 'at_head' parameter for __nvme_submit_sync_cmd() boolean Hannes Reinecke
2023-02-09  5:20   ` Christoph Hellwig
2023-02-09 10:59     ` Hannes Reinecke
2023-02-09 14:24       ` Kanchan Joshi
2023-02-08 15:30 ` [PATCHv2 0/3] nvme: rework __nvme_submit_sync_cmd() Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2023-02-08  8:49 [PATCH " Hannes Reinecke
2023-02-08  8:49 ` [PATCH 1/3] nvme: split __nvme_submit_sync_cmd() Hannes Reinecke
2023-02-08 14:10   ` Kanchan Joshi
2023-02-08 15:03     ` Hannes Reinecke

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=20230209053330.GA8536@lst.de \
    --to=hch@lst.de \
    --cc=hare@suse.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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