Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1630335pxb; Fri, 27 Aug 2021 13:30:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0kTEIVfUDaK6u7Og+oTBLsWmQIwzqclfC9uSijFhc0oa84fobi+R8Q4fnW6vJL65c3Foc X-Received: by 2002:a02:970d:: with SMTP id x13mr9552208jai.57.1630096234707; Fri, 27 Aug 2021 13:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630096234; cv=none; d=google.com; s=arc-20160816; b=DacHfglOjUk5YUvAH/rOfEkVqAguyIcr8DJkVdjP3Nuc91KIoFhu5coyasmpAq9DdT +5mmjIvMQeDfpTTzndZr+VvbO+Z9oM9cUJiVICk06GBsHQFZOxNkb4diLxt/0Y7VNPdM QHkjz9xVNww7v+IJO3VpCiMIaQWzONTjtf8k47D/gy+8N3Y55OPAqckXjBJ3VrMYefbM T0V1vZzPD9O9Fdx3t0m2PjV+RJzO+M8zJeS88TlmRQ621uCQoOcy9+YhuA2lIf+R0LiW 6PB+4DxAhajoGI1ZUdruqf9AR6Es8XVUjRA16/si23OaNVoSkOFzkx4W/tlRhAPdMX0W R9OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0b0qj0HW48lP2+v5BMdyCJtl95BHh+quA0uSYRL2ULs=; b=rt127DWYoiyze5LTzoRAAuMIWRjnTXPhUfPpCRWAAXpbflJUdlYY8ALe5EPv0DasZR Zxgack98cjiqwaupnLbFYginePq0A9lm9HcNXCrrFx0O/s1spemc99AI3v47Qu1wKZQK OHM8P8XQvdRfScOnQK3IL+6IQnURNSW4de8ZPy7fQESUZ9/1FGZAtLOONp5TrlVhrcVb vgltlSXcFiAhJnemc5O/FUbu6RxDzr6NdjFEqT3pnuliAjQRDBV4p/UguF6yqj4Hlx7s jP1XaU5+gMnFFiQKFdzfm2QqOhXLHcK1ln2VC2xPQqJf/+CJnsPbnNbqe+l16ZXcNj0s LW5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VqgAkXLS; 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 132si1457147jaf.20.2021.08.27.13.30.23; Fri, 27 Aug 2021 13:30:34 -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=@kernel.org header.s=k20201202 header.b=VqgAkXLS; 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 S231537AbhH0Ua0 (ORCPT + 99 others); Fri, 27 Aug 2021 16:30:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:41968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbhH0UaZ (ORCPT ); Fri, 27 Aug 2021 16:30:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 977CB60FD8; Fri, 27 Aug 2021 20:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630096176; bh=88bih5eGKB9i2ESLsafMWzYIwyGke7MVW8Rm8LZaCJM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VqgAkXLSFQ2s8YBhV0/BkRbyvjYS7iN8wS3+vPnrfYwjeVZbT3EcOkpsbz+6iOIIg K59JPqJADG5mnk2BZMwXfm+2K/QX3GabYmGmJMq75CAhfxkg4e7sYb4W90iqXt4wjY CCBcmFMkK/fitfaaSpE06RYuhbvQkR1xSjgZLyqV+ldHSk85VfL/sYK3yuWYBDlle0 4C9yBY22Kb164kHW1308QMn1cbMYjo7ekT+NZW9nIbbZyeN7dvOl3QZ8uGzlQBiwYO xvNRlNxn6B/Q+DSji3QgnHGBcKriUM+BPc6qVP1hIdIo6lvljcLrqIlc4i6mgmBrgk KvuManA4RC1Fw== Date: Fri, 27 Aug 2021 13:29:32 -0700 From: Keith Busch To: Luis Chamberlain Cc: axboe@kernel.dk, colyli@suse.de, kent.overstreet@gmail.com, 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, 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 Subject: Re: [PATCH 03/10] nvme-multipath: add error handling support for add_disk() Message-ID: <20210827202932.GA82376@dhcp-10-100-145-180.wdc.com> References: <20210827191809.3118103-1-mcgrof@kernel.org> <20210827191809.3118103-4-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210827191809.3118103-4-mcgrof@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 27, 2021 at 12:18:02PM -0700, Luis Chamberlain wrote: > @@ -479,13 +479,17 @@ 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; > > - if (!test_and_set_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) { > - device_add_disk(&head->subsys->dev, head->disk, > - nvme_ns_id_attr_groups); > + if (!test_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) { This should still be test_and_set_bit() because it is protecting against two nvme paths simultaneously calling device_add_disk() on the same namespace head. > + 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); > }