Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4342348pxb; Mon, 27 Sep 2021 15:02:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGG4f6g9q8ij9LSPIybPrBlxsTv2E5fyA5TIixSS0wgxv3VpHrcRZlnN9OIU/YuWWrmmTq X-Received: by 2002:a17:90b:4b82:: with SMTP id lr2mr1495888pjb.94.1632780156786; Mon, 27 Sep 2021 15:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632780156; cv=none; d=google.com; s=arc-20160816; b=N/jPUWM5Jwif0hIRnzDiAEU0ddu0uPiNuGCyqFCgwlj3jwWrszQKPtMj3/HBO5lQn2 CmAree4CdLpp4V2FMlr9IG/fe8imL9Bd4KtKmQXBAPEkbBiPZwB02Mk2Rz0c1HH40qx9 U6dvQl1ymQmrZSwWeLn7DXxDXG5oECEKPB/940bCjvyvIskz2Vy2H4zlPE0h8HWCCUtl ysZLtimoZ/OBpoYLF7bmZhMD81jVixQ9uwz1j3Qei+92pcDxgDgejXo3aGzOHKJbta6B 23De4xGfJRprBWMqytmyop41LqRCv0rInuhdmMPUTwjIrxzOppfV4nSViOU52GrV5oGA Wk2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7F58wxD/dEQonKrzNoWM7DkNk/UH9ZF8NZLJCFZZJo4=; b=c+mzsuQfJ9Xs01qwLOTyVz4t3feCA+dQP9l0J140zRWuDG/dgOnYbn/G0BBLs5ftH4 xUg70isjK59e0gQ0dPTB+EFaTs1mjj1t1qYps9v/5Nn6SSGwkf00sDIM30f3PG/QfE5F OKfuS9Y/EfzTr0cNVpa8GTyxQUf+u/fXNLzP+ym8ac1t2qreZ4pPjMWIQu1gEYwjF6Hx YKS/sDf7tu6ZNRteIsuafT09711NBr0dJzZqQyHuJrdpZ9p5AiZhloXq50+Ce9TMh0Cr HReeK1ECA4TZTINoyOODLKqIJczwLvcIbEYg7l0xGMfmQR8wePl3B50Lc57oXwP3g9sw kpyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=ZnlFI8fL; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lx2si1451205pjb.61.2021.09.27.15.02.23; Mon, 27 Sep 2021 15:02:36 -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=@infradead.org header.s=bombadil.20210309 header.b=ZnlFI8fL; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237860AbhI0WCp (ORCPT + 99 others); Mon, 27 Sep 2021 18:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237735AbhI0WCa (ORCPT ); Mon, 27 Sep 2021 18:02:30 -0400 Received: from bombadil.infradead.org (unknown [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B370FC061770; Mon, 27 Sep 2021 15:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=7F58wxD/dEQonKrzNoWM7DkNk/UH9ZF8NZLJCFZZJo4=; b=ZnlFI8fLEZC+pXL09OaLsKjdn8 sG2hdDcnkdd7ZQAAOmWguGc7OnVMevoBr9Iei6cSMyXAQixEc8APBeN/A8M4gCqUCYojYyBiRia7O 7wDEec/aFp7xuN5F775zNLNzsTp/rSR3Ay3VTbK1PNHfZokfRNvqNAX9BvqfJMUKuSdi3rm3MuWeX L6a8Q4FjRtkn9UeJ4Lhp3Lt/jbaePXbm+u8tO6lhIOBWl8Zvgdk3hjBymTruCXrQy+1R0u429f+a4 B0bkzO9hXCn6QDiaV77uGrK+Hfqt+kENvWzGuFAfXSbunwOgQu1cHy4uiqeb5kU5vGXxTPlHBSNa9 7+WGTsLw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUyfw-004Suk-EY; Mon, 27 Sep 2021 22:00:40 +0000 From: Luis Chamberlain To: 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, Luis Chamberlain Subject: [PATCH v2 03/10] nvme-multipath: add error handling support for add_disk() Date: Mon, 27 Sep 2021 15:00:32 -0700 Message-Id: <20210927220039.1064193-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210927220039.1064193-1-mcgrof@kernel.org> References: <20210927220039.1064193-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } -- 2.30.2