Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5186087pxv; Tue, 20 Jul 2021 22:33:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCLIGeoxq855wzqnD1tHhg+UBJKQNKVatlO45VkLKNgxhbLrCBgHQ3X1SqD74Gf537R7jT X-Received: by 2002:a05:6638:33a6:: with SMTP id h38mr29775612jav.130.1626845617309; Tue, 20 Jul 2021 22:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626845617; cv=none; d=google.com; s=arc-20160816; b=s6LGTST5MMWWK3KaZVtu6VzbGFjlXClofabqFXwgvy3Gq209rjZTP56gGQ5sF55km7 SYS9u8222y0pNaI0KHDaffiTgL84+7kiAx743TjAVV+OdClVEWADvRhjphTrXA7Y09gQ ENy9lre2EpPMgMmtC+fiCvJs7lxCXb/0QvJeCUZRSUMljqQEHEhXQaSOSYO1F+Wiw/wg rCEMWtHU+W9k/JwQPmfHUJJlSW+aeFhuakoQPkcU1nR1vhUtGQZqeAK6lns4X5jn8gFJ /v5ucJ8JACTio+u4/bePdgnuJOu/8F1SfFFQXnSVBgXWsSm9kZyXd3R9m6DQTHyYcw3O GUUg== 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=UIe3t7U9ttMqTuOm5HTkTK76a1TyJwwc0+hE6h3VkC4=; b=sZuSgQ9kyzMb9yD5pVJwJaunBUthOIIv9CwTrKbO5Jg0hXvBWMV7zXddzCijj9ewaY ELbrBVwdguUAa5tHxKlShoKXhDQoiuKmbcnkcSKB/LZaAvQ9CZb8Jg0niWZZPvFzBFuQ qBr32JJ98jvDq3i8KvJRc8q6QoQspgOLmWNw3VOz1BHFibgMM5jIzAavMyAXpVgAKCRi 0UkLqEKfqFm882mH7tSNjSc5VrScLkV2+4vUtqbO1+Oaw3IONdHiLtWFdwpfTNmloL4I 9xWhYk8lAj3M8r9mTtlfwKQ8WxqEUkL4oEVXzy6SvvOzGeMcZ1bfvM7u6gVsTvfuEQ0x pUWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=awd14+cL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si9301514ilj.137.2021.07.20.22.33.25; Tue, 20 Jul 2021 22:33:37 -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=casper.20170209 header.b=awd14+cL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232035AbhGUEwA (ORCPT + 99 others); Wed, 21 Jul 2021 00:52:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbhGUEvr (ORCPT ); Wed, 21 Jul 2021 00:51:47 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A9EBC061574; Tue, 20 Jul 2021 22:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=UIe3t7U9ttMqTuOm5HTkTK76a1TyJwwc0+hE6h3VkC4=; b=awd14+cLFPTgHWZF5axFBezG9F +D5ie/GWOlOI0peJ8ORqGb/YcqfuXmD6lHdkS1yIFubBw+Xs4PgUqAQnb4CW6qBqvWe0NcC3zQRTR Ruh6mTXE/7reHGLTMhoVERl6SBk8R1bo5nAATE8wMb8nkEh5kmTZ1KgGkqZU7UHfJIJSKhAkCCdih xy6NDh9Gs2K9aiE8lqnOU7cxXdGOUnqtycxm+yyZiXjlcmJqJ1C+b//G8Y3BToU8XZ7LI7hmi6izK DJq+i5c7KvCb7xzN0mIHIT70bINQw/5sAEX196faFlLokH/sCfLzNWdx9nonM0SiH5aTGGu4veuWi WqRSe+Sw==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m64pe-008pi3-Bh; Wed, 21 Jul 2021 05:31:49 +0000 Date: Wed, 21 Jul 2021 06:31:46 +0100 From: Christoph Hellwig To: Luis Chamberlain Cc: axboe@kernel.dk, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, hch@infradead.org, jack@suse.cz, osandov@fb.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, sagi@grimberg.me, kbusch@kernel.org Subject: Re: [PATCH 4/5] nvme: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED Message-ID: References: <20210720182048.1906526-1-mcgrof@kernel.org> <20210720182048.1906526-5-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210720182048.1906526-5-mcgrof@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 20, 2021 at 11:20:47AM -0700, Luis Chamberlain wrote: > The GENHD_FL_DISK_ADDED flag is what we really want, as the > flag GENHD_FL_UP could be set on a semi-initialized device. > > Signed-off-by: Luis Chamberlain > --- > drivers/nvme/host/core.c | 4 ++-- > drivers/nvme/host/multipath.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 11779be42186..7be78491c838 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -1819,7 +1819,7 @@ static void nvme_update_disk_info(struct gendisk *disk, > static inline bool nvme_first_scan(struct gendisk *disk) > { > /* nvme_alloc_ns() scans the disk prior to adding it */ > - return !(disk->flags & GENHD_FL_UP); > + return !(blk_disk_added(disk)); > } So this on is obviously right as it wants to check for the probe time scan. Although we don't need the braces. > > > static void nvme_set_chunk_sectors(struct nvme_ns *ns, struct nvme_id_ns *id) > @@ -3823,7 +3823,7 @@ static void nvme_ns_remove(struct nvme_ns *ns) > nvme_mpath_clear_current_path(ns); > synchronize_srcu(&ns->head->srcu); /* wait for concurrent submissions */ > > - if (ns->disk->flags & GENHD_FL_UP) { > + if (blk_disk_added(ns->disk)) { This is something that goes back to before the damn of time, but I do not think we actually need it. All the errors paths before alloc_disk and add_disk just directly free the ns and never end up here. > if (!nvme_ns_head_multipath(ns->head)) > nvme_cdev_del(&ns->cdev, &ns->cdev_device); > del_gendisk(ns->disk); > diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c > index 0ea5298469c3..f77bd2d5c1a9 100644 > --- a/drivers/nvme/host/multipath.c > +++ b/drivers/nvme/host/multipath.c > @@ -764,7 +764,7 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head) > { > if (!head->disk) > return; > - if (head->disk->flags & GENHD_FL_UP) { > + if (blk_disk_added(head->disk)) { > nvme_cdev_del(&head->cdev, &head->cdev_device); > del_gendisk(head->disk); > } This one is sort of correct due to the lazy disk addition. But we could and probably should check for NVME_NSHEAD_DISK_LIVE instead.