From: Christoph Hellwig <hch@lst.de>
To: Daniel Wagner <dwagner@suse.de>
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>, Hannes Reinecke <hare@suse.de>
Subject: Re: [PATCH v3 2/4] nvme: initialize head before namespace
Date: Wed, 6 Dec 2023 09:50:44 +0100 [thread overview]
Message-ID: <20231206085044.GA24484@lst.de> (raw)
In-Reply-To: <20231206081244.32733-3-dwagner@suse.de>
On Wed, Dec 06, 2023 at 09:12:42AM +0100, Daniel Wagner wrote:
> In preparation to use struct nvme_ns_head pointers instead of a struct
> nvme_ns pointers, initialize the head pointer before we create the disk.
> This allows us to attach the head as private data to the disk object.
>
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
> drivers/nvme/host/core.c | 46 ++++++++++++++++++++++------------------
> 1 file changed, 25 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 900c045fcae0..1fabe1b81de0 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3474,10 +3474,11 @@ static int nvme_global_check_duplicate_ids(struct nvme_subsystem *this,
> return ret;
> }
>
> -static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
> +static int nvme_init_ns_head(struct nvme_ctrl *ctrl,
> + struct nvme_ns_info *info,
> + struct nvme_ns_head **head)
Can we just return the head or an ERR_PTR here instead of an additional
argument? That would also remove the need for the variable renaming
below.
I'd also rename the function to nvme_find_or_alloc_ns_head if you're at
it.
> + mutex_lock(&ctrl->subsys->lock);
> + list_add_tail_rcu(&ns->siblings, &ns->head->list);
> + mutex_unlock(&ctrl->subsys->lock);
This can't race with someone else adding the ns as all scanning is
from the scan work item. Maybe ad da comment on why this pattern is
safe? Because I think it wasn't when the code was originally added..
Otherwise this looks good to me.
next prev parent reply other threads:[~2023-12-06 8:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 8:12 [PATCH v3 0/4] nvme: add csi, ms and nuse to sysfs Daniel Wagner
2023-12-06 8:12 ` [PATCH v3 1/4] nvme: lookup ctrl from request instead from namespace Daniel Wagner
2023-12-06 8:12 ` [PATCH v3 2/4] nvme: initialize head before namespace Daniel Wagner
2023-12-06 8:50 ` Christoph Hellwig [this message]
2023-12-06 8:12 ` [PATCH v3 3/4] nvme: move ns id info to struct nvme_ns_head Daniel Wagner
2023-12-06 8:54 ` Christoph Hellwig
2023-12-07 10:53 ` Daniel Wagner
2023-12-06 17:38 ` kernel test robot
2023-12-06 17:38 ` kernel test robot
2023-12-07 5:36 ` Dan Carpenter
2023-12-06 8:12 ` [PATCH v3 4/4] nvme: add csi, ms and nuse to sysfs Daniel Wagner
2023-12-06 8:59 ` Christoph Hellwig
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=20231206085044.GA24484@lst.de \
--to=hch@lst.de \
--cc=dwagner@suse.de \
--cc=hare@suse.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.