From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2E2FC04FF3 for ; Mon, 24 May 2021 07:20:47 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 31C17610CE for ; Mon, 24 May 2021 07:20:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31C17610CE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4FpTC145Xyz3bsH for ; Mon, 24 May 2021 17:20:45 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lst.de (client-ip=213.95.11.211; helo=verein.lst.de; envelope-from=hch@lst.de; receiver=) Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4FpTBb1sBXz2xYg for ; Mon, 24 May 2021 17:20:22 +1000 (AEST) Received: by verein.lst.de (Postfix, from userid 2407) id A686B67373; Mon, 24 May 2021 09:20:13 +0200 (CEST) Date: Mon, 24 May 2021 09:20:13 +0200 From: Christoph Hellwig To: Luis Chamberlain Subject: Re: [dm-devel] [PATCH 01/26] block: refactor device number setup in __device_add_disk Message-ID: <20210524072013.GA23890@lst.de> References: <20210521055116.1053587-1-hch@lst.de> <20210521055116.1053587-2-hch@lst.de> <20210521171646.GA25017@42.do-not-panic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210521171646.GA25017@42.do-not-panic.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nvdimm@lists.linux.dev, Ulf Hansson , Mike Snitzer , linux-m68k@vger.kernel.org, linux-nvme@lists.infradead.org, Song Liu , dm-devel@redhat.com, Joshua Morris , linux-s390@vger.kernel.org, Dave Jiang , Maxim Levitsky , Vishal Verma , Christoph Hellwig , Christian Borntraeger , Geert Uytterhoeven , Matias Bjorling , Nitin Gupta , Vasily Gorbik , linux-xtensa@linux-xtensa.org, Alex Dubov , Heiko Carstens , Coly Li , linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, drbd-dev@tron.linbit.com, Philip Kelleher , Dan Williams , Jens Axboe , Chris Zankel , Max Filippov , linux-mmc@vger.kernel.org, Philipp Reisner , Jim Paris , Minchan Kim , Lars Ellenberg , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, May 21, 2021 at 05:16:46PM +0000, Luis Chamberlain wrote: > > - /* in consecutive minor range? */ > > - if (bdev->bd_partno < disk->minors) { > > - *devt = MKDEV(disk->major, disk->first_minor + bdev->bd_partno); > > - return 0; > > - } > > - > > It is not obviously clear to me, why this was part of add_disk() > path, and ... > > > diff --git a/block/partitions/core.c b/block/partitions/core.c > > index dc60ecf46fe6..504297bdc8bf 100644 > > --- a/block/partitions/core.c > > +++ b/block/partitions/core.c > > @@ -379,9 +380,15 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, > > pdev->type = &part_type; > > pdev->parent = ddev; > > > > - err = blk_alloc_devt(bdev, &devt); > > - if (err) > > - goto out_put; > > + /* in consecutive minor range? */ > > + if (bdev->bd_partno < disk->minors) { > > + devt = MKDEV(disk->major, disk->first_minor + bdev->bd_partno); > > + } else { > > + err = blk_alloc_ext_minor(); > > + if (err < 0) > > + goto out_put; > > + devt = MKDEV(BLOCK_EXT_MAJOR, err); > > + } > > pdev->devt = devt; > > > > /* delay uevent until 'holders' subdir is created */ > > ... and why we only add this here now. For the genhd minors == 0 (aka GENHD_FL_EXT_DEVT) implies having to allocate a dynamic dev_t, so it can be folded into another conditional.