public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org, Christoph Hellwig <hch@lst.de>,
	Hannes Reinecke <hare@suse.de>, Keith Busch <kbusch@kernel.org>,
	Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
Subject: Re: [PATCH 12/16] nvme-auth: convert dhchap_auth_list to an array
Date: Wed, 9 Nov 2022 07:48:55 +0100	[thread overview]
Message-ID: <20221109064855.GC10893@lst.de> (raw)
In-Reply-To: <20221109034420.1000086-13-sagi@grimberg.me>

> Make dhchap_auth_mutex protect only the ctrl host_key and ctrl_key
> in a fine-graned lock such that there is no long lasting acuisition
> of the lock.

Can you split that part into a separate patch?  Right now the patch
is a bit confusing because it does multiple things.


> +#define nvme_auth_chap_from_qid(ctrl, qid) \
> +	&((struct nvme_dhchap_queue_context*)(ctrl)->dhchap_ctxs)[qid]

Please properly type dhchap_ctxs instead of the ugly cast here.  That
also removed the need for the macro.
functions instead of macros.

> +#define ctrl_max_dhchaps(ctrl) \
> +	(ctrl)->opts->nr_io_queues + (ctrl)->opts->nr_write_queues + \
> +			(ctrl)->opts->nr_poll_queues + 1

This overallocates in case the controller supports less queues than
requested, but I guess that's not a big problem in practice.

Also please make this an inline function to add type safety and to make
it more readable.

> +#define nvme_foreach_dhchap(i, chap, ctrl) \
> +	for (i = 0, chap = (ctrl)->dhchap_ctxs; \
> +	     i < ctrl_max_dhchaps(ctrl) && chap != NULL; i++, chap++)

I find this macro a bit obsfucating.  There's only three callers anyway,
and they only use chap 1, 2 or three times respectively.

So I'd just loop:

	for (i = 0, i < ctrl_max_dhchaps(ctrl); i++)

and then do the dereference of >dhchap_ctxs in the loop.

>  			    void *data, size_t data_len, bool auth_send)
> @@ -330,7 +338,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,
>  	struct nvmf_auth_dhchap_success1_data *data = chap->buf;
>  	size_t size = sizeof(*data);
>  
> -	if (ctrl->ctrl_key)
> +	if (chap->ctrl_key)

How is this related to the rest of the patch?

> +		INIT_WORK(&chap->auth_work, __nvme_auth_work);

Btw, this really should lose the __ prefix in another prep patch.

> +	}
> +
> +out:
>  	return ret;

We can just drop the out label and return directly.


  reply	other threads:[~2022-11-09  6:49 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  3:44 [PATCH 00/16] nvme: rework dhchap authentication host code Sagi Grimberg
2022-11-09  3:44 ` [PATCH 01/16] nvme-auth: rename __nvme_auth_[reset|free] to nvme_auth[reset|free]_dhchap Sagi Grimberg
2022-11-09 17:35   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 02/16] nvme-auth: remove symbol export from nvme_auth_reset Sagi Grimberg
2022-11-09  7:30   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 03/16] nvme-auth: don't re-authenticate if the controller is not LIVE Sagi Grimberg
2022-11-09  7:33   ` Hannes Reinecke
2022-11-09 19:00     ` Sagi Grimberg
2022-11-09  3:44 ` [PATCH 04/16] nvme-auth: remove redundant buffer deallocations Sagi Grimberg
2022-11-09 17:36   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 05/16] nvme-auth: don't ignore key generation failures when initializing ctrl keys Sagi Grimberg
2022-11-09  7:33   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 06/16] nvme-auth: don't override ctrl keys before validation Sagi Grimberg
2022-11-09  7:34   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 07/16] nvme-auth: remove redundant if statement Sagi Grimberg
2022-11-09  6:37   ` Christoph Hellwig
2022-11-09 18:42     ` Sagi Grimberg
2022-11-09  7:34   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 08/16] nvme-auth: don't keep long lived 4k dhchap buffer Sagi Grimberg
2022-11-09  6:39   ` Christoph Hellwig
2022-11-09 18:05     ` Sagi Grimberg
2022-11-09 17:37   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 09/16] nvme-auth: clear sensitive info right after authentication completes Sagi Grimberg
2022-11-09  7:35   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 10/16] nvme-auth: remove redundant deallocations Sagi Grimberg
2022-11-09  3:44 ` [PATCH 11/16] nvme-auth: no need to reset chap contexts on re-authentication Sagi Grimberg
2022-11-09  7:36   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 12/16] nvme-auth: convert dhchap_auth_list to an array Sagi Grimberg
2022-11-09  6:48   ` Christoph Hellwig [this message]
2022-11-09 19:06     ` Sagi Grimberg
2022-11-09 17:40   ` Hannes Reinecke
2022-11-09 19:05     ` Sagi Grimberg
2022-11-09  3:44 ` [PATCH 13/16] nvme-auth: remove redundant auth_work flush Sagi Grimberg
2022-11-09 17:41   ` Hannes Reinecke
2022-11-09  3:44 ` [PATCH 14/16] nvme-auth: have dhchap_auth_work wait for queues auth to complete Sagi Grimberg
2022-11-09  7:44   ` Hannes Reinecke
2022-11-09 19:01     ` Sagi Grimberg
2022-11-09  3:44 ` [PATCH 15/16] nvme-tcp: stop auth work after tearing down queues in error recovery Sagi Grimberg
2022-11-09  3:44 ` [PATCH 16/16] nvme-rdma: " Sagi Grimberg
2022-11-09  3:44 ` [PATCH 17/16 blktests] nvme: add re-authentication running concurrently with reset Sagi Grimberg
2022-11-09  3:47 ` [PATCH 00/16] nvme: rework dhchap authentication host code Sagi Grimberg
2022-11-09  7:45 ` Hannes Reinecke
2022-11-09 17:42   ` Sagi Grimberg

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=20221109064855.GC10893@lst.de \
    --to=hch@lst.de \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --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