Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp833640rdb; Wed, 6 Dec 2023 00:51:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZRaAr+wIktY43rCNAXCvEREgGlcUSdVFlhekC1qI9zn9k7EjaBFxu5l2H8jbz7I99bYNe X-Received: by 2002:a05:6a20:5603:b0:18c:4f:ce9e with SMTP id ir3-20020a056a20560300b0018c004fce9emr651332pzc.43.1701852667845; Wed, 06 Dec 2023 00:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701852667; cv=none; d=google.com; s=arc-20160816; b=xIlqwri3Tn1yUnsCm9GJIbrVs4+exTlLf+UnY8eoWrx0f3260J/4x98EUtNV1m1ZUJ 3h7y4u+sPUAkCRJKJhr7gYTc+m8kM9SgaVYokKCirOxFM39jv0EywY4dB9ybxlZaS18/ /rharRbumaZFLTVMSSm4tOIKvNQrgdgwf1lH8b6AAk95GABdaq1pfv1IPwXRqc3G+MQD fjxLniReoylnDEht8sfZAVKgAdVqwvhx448HMWuLIeMg/oI/kgug+HEfQCdaTGYO/UR0 R2nUKC6IWrh4S8TvDxM8jdPlmLSny545nhPUZmBHjQJX6L1wI/XqLBEa2tr4VCxaZgXd g0Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=M9/Oyle9CfbuXa6DFmnOWnRMbGsT+NSzmFrrsRTerok=; fh=JWieladFfeaIwBj69e66MtYgIw576fUcTLVAEUXiV9w=; b=jmJ5/czReXFTh/0m2yVbIVMfuNt+QpcGO7fEKgU/c6G7PLDYWPtcWPqC0NgsLDp4Jv yQuZvgOLiAP98UM6O98GWF9oTqhcHnVAbWl6HBWVCkN6twx/dhISdRAH/shctJP8abPX Bi1PUHm49WPj4ipP7UIYCpmimxYOwjHLnC0KgwU1EMZufEVUXxtUyh70n3hNy4kzq8kD lXx38VR8V72o4iqR0atJ2CBqm1T2ggbEybxmaK1Yaa9j7CPDKBotwssTkl7etYVeMvhM Z4PhEWqZwI2QmMNgLd+XeC88r12693Kgk1HCz82FBPC5s80pIc8++yfpLp0w3G/APgqA o5Eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l6-20020a17090a408600b00286ef2fc253si1870559pjg.97.2023.12.06.00.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 00:51:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1F096807F94B; Wed, 6 Dec 2023 00:51:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbjLFIuq (ORCPT + 99 others); Wed, 6 Dec 2023 03:50:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbjLFIup (ORCPT ); Wed, 6 Dec 2023 03:50:45 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 860B21BE5 for ; Wed, 6 Dec 2023 00:50:48 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id EE058227A8E; Wed, 6 Dec 2023 09:50:44 +0100 (CET) Date: Wed, 6 Dec 2023 09:50:44 +0100 From: Christoph Hellwig To: Daniel Wagner Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke Subject: Re: [PATCH v3 2/4] nvme: initialize head before namespace Message-ID: <20231206085044.GA24484@lst.de> References: <20231206081244.32733-1-dwagner@suse.de> <20231206081244.32733-3-dwagner@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231206081244.32733-3-dwagner@suse.de> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 00:51:05 -0800 (PST) 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 > --- > 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.