lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231206085044.GA24484@lst.de>
Date:   Wed, 6 Dec 2023 09:50:44 +0100
From:   Christoph Hellwig <hch@....de>
To:     Daniel Wagner <dwagner@...e.de>
Cc:     linux-nvme@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Keith Busch <kbusch@...nel.org>,
        Christoph Hellwig <hch@....de>,
        Sagi Grimberg <sagi@...mberg.me>,
        Hannes Reinecke <hare@...e.de>
Subject: Re: [PATCH v3 2/4] nvme: initialize head before namespace

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@...e.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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ