Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4597511pxb; Mon, 27 Sep 2021 22:41:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwFmyAmd9i/mxfJU9D8/KoKxNfSuTDzkRN3x2v/wPfhyKKnn0D42BY7wvyg1PelurHamCY X-Received: by 2002:a17:902:760b:b0:13b:122:5ff0 with SMTP id k11-20020a170902760b00b0013b01225ff0mr3510418pll.22.1632807662285; Mon, 27 Sep 2021 22:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632807662; cv=none; d=google.com; s=arc-20160816; b=rQY9UzHw31LFxrP4Pb/WGMw40qw+MV97cfpWfm0NMtJKM0fOwhfoEt7awHKLZtNE27 jRXC1FlhIaIw7E9okkSIscWapEGKynuJliYtzSvQq3wYXVid/a3uNX4CDSK2H2uBcZOi 0Fwye/+xJLTakKcHBqnwD+w2FMUCdE/AwIIQsnNpEchtxQt1wpA7q0G4hIMGY3go+G+I JcTuO3Tp+kYeZOkkCIG5MX118azCZq3CH4KhZUTsQZZE3PlKgukWNoMTbjKQWh9rQ/TJ XocWZPwYliKwh7gijshHaixrAFQEH8vz2/Yem3FK0UE05Pc0/NGFMLomdWUpZrOTyKwq z/Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature; bh=13TnURwhS8h4t01lwoZLD/d/5oPL9agrfycanDfeTRQ=; b=xojlrs3PmFJ/q3GUJjH3RovMRTIT52qMmzhr2aoLluCRlGIzctpSRGe2acrrr7dB3i ZbyUnYikATQ/BU3KIjPmb3kmNg6vgZJBvXKSKj7Efuq9CU+xpdZFJx6vUYdXcO5jgjsj +XkQkuHYKgMt5UQohob6LzEu2O3FOadvChAwp56cxqzQ4A2+Buat1a7mDsNCXT7SiXZx zi5ZJQLTQjGferLEyKhY838vVK+06Tbt67zYy4D73OagAsXHMBiuSmq6mMhGFpaYVaxh uFXMo4yO6zpVeSjaKlfkxeQcCZ4z/GJDyEyTcV9hEHE2uZm18eCoa301OpcwOjybXGyJ XhRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PT9kgFrx; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=VnyBApxF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si24738880pgs.17.2021.09.27.22.40.50; Mon, 27 Sep 2021 22:41:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PT9kgFrx; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=VnyBApxF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235991AbhI1Flg (ORCPT + 99 others); Tue, 28 Sep 2021 01:41:36 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:42402 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234243AbhI1Flf (ORCPT ); Tue, 28 Sep 2021 01:41:35 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0C7BD201BB; Tue, 28 Sep 2021 05:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1632807595; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=13TnURwhS8h4t01lwoZLD/d/5oPL9agrfycanDfeTRQ=; b=PT9kgFrx9DkgIx21N+ey4rvrG+p5lgzclkflex7M8ulg7b/MPe/8YBUPSSqsTo2GTahbjJ Gey5RuOSF1hNpbYAFgKbf2oL0K4d67fdRAt+eRdY+iU4RsWpBKefK/X7oBdujgebC7iQbz cH9ujOHUnez6nwSvlDTdjkQYCRSdxBg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1632807595; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=13TnURwhS8h4t01lwoZLD/d/5oPL9agrfycanDfeTRQ=; b=VnyBApxFuoR87JCq7TgLnoYycKzbt1M/1osAF+bIrqg5sP1C+l/tWJFxYA8+084TxkpCY5 Hr8IhCD3XymifdAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AB01913A98; Tue, 28 Sep 2021 05:39:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id JO5JKKqqUmHUNQAAMHmgww (envelope-from ); Tue, 28 Sep 2021 05:39:54 +0000 Subject: Re: [PATCH v2 03/10] nvme-multipath: add error handling support for add_disk() To: Luis Chamberlain , axboe@kernel.dk, colyli@suse.de, kent.overstreet@gmail.com, kbusch@kernel.org, sagi@grimberg.me, vishal.l.verma@intel.com, dan.j.williams@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, konrad.wilk@oracle.com, roger.pau@citrix.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org Cc: xen-devel@lists.xenproject.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210927220039.1064193-1-mcgrof@kernel.org> <20210927220039.1064193-4-mcgrof@kernel.org> From: Hannes Reinecke Message-ID: <85d33b80-1d54-67ba-47f9-0298093b6d80@suse.de> Date: Tue, 28 Sep 2021 07:39:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210927220039.1064193-4-mcgrof@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/28/21 12:00 AM, Luis Chamberlain wrote: > We never checked for errors on add_disk() as this function > returned void. Now that this is fixed, use the shiny new > error handling. > > Since we now can tell for sure when a disk was added, move > setting the bit NVME_NSHEAD_DISK_LIVE only when we did > add the disk successfully. > > Nothing to do here as the cleanup is done elsewhere. We take > care and use test_and_set_bit() because it is protects against > two nvme paths simultaneously calling device_add_disk() on the > same namespace head. > > Signed-off-by: Luis Chamberlain > --- > drivers/nvme/host/multipath.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c > index e8ccdd398f78..35cace4f3f5f 100644 > --- a/drivers/nvme/host/multipath.c > +++ b/drivers/nvme/host/multipath.c > @@ -496,13 +496,22 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) > static void nvme_mpath_set_live(struct nvme_ns *ns) > { > struct nvme_ns_head *head = ns->head; > + int rc; > > if (!head->disk) > return; > > + /* > + * test_and_set_bit() is used because it is protecting against two nvme > + * paths simultaneously calling device_add_disk() on the same namespace > + * head. > + */ > if (!test_and_set_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) { > - device_add_disk(&head->subsys->dev, head->disk, > - nvme_ns_id_attr_groups); > + rc = device_add_disk(&head->subsys->dev, head->disk, > + nvme_ns_id_attr_groups); > + if (rc) > + return; > + set_bit(NVME_NSHEAD_DISK_LIVE, &head->flags); > nvme_add_ns_head_cdev(head); > } > > Errm. Setting the same bit twice? And shouldn't you unset the bit if 'device_add_disk()' fails? Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer