Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3444800pxa; Tue, 25 Aug 2020 23:54:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxGtiYA92SSkkQIbqSRSEvDLiB39kfOroP5QV4oYIvK8BkJBVk4VYrkpCY/fD3QrP5mbiv X-Received: by 2002:a17:907:20c8:: with SMTP id qq8mr15072387ejb.253.1598424859487; Tue, 25 Aug 2020 23:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598424859; cv=none; d=google.com; s=arc-20160816; b=XLMFoAODIg6e+WLD8zK1igdYhZEJjpJp1Ps3K1LZyD19mbmii2SAsJpv30bB/+ynG1 85fJkmqEkfqRdEIcxRscGN8i1ZGvuwvBF2piNNTZ6NXQ4NhlEE5+rAxAdyZx4pssuo68 llES9Vwz171P+njuTuTsVcB6RXzFOy7nByK5SShw8KPP4ONPsVeDuLYuWTP9LEgMp2x8 Meh3nl8HKLKrFMRXlv9a1W529iKKQeABAc4cvcUhGa9dbBfhAeE63+BpVo33Ru4Us1Z3 M/IiK+u/3JoAr9bkoYe0oPYrqHqWpL/8XHockIXNzeeoS/bErHuukKZCGa4wVFujTBq9 l0+A== 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=SGTWnq2AQ38kIvWB9VYuxXbeJQGBBC+aSlZ9ZuRIk/o=; b=uU1QlZTOibmB+XI45NqstG9P97a/Q175m247Up7NYYcmFjC8ATZxDAGXXIOic67TVx fyJyYVQ8G5HctzT7jNwWg9cVC/UyuESzkqCVzZtuWtSHZjOwvZhFCMDr4YIvhF1hHHxA 2ZJlzwTFbnIQVEzaMPJdORCx8beyC11L1VEsEw4FGyHlOQpAtx8H+DRUbKArJCj0gMdM Xmy353O4gOaWJiF2Ng5P+JiSV2zkeFcEtxZkgEpGJ7yDIKMz57yp2cA8pZFHjjlFvU9j b2wiUMtAyka5WAg12NyNq3M1K21RFdWrzyHv/KTbb/8WEWELzIldCkIKfYHn+ETjbc3y YdBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=URLT5+Gr; 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 x2si888212edj.273.2020.08.25.23.53.56; Tue, 25 Aug 2020 23:54:19 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=URLT5+Gr; 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 S1726880AbgHZGxT (ORCPT + 99 others); Wed, 26 Aug 2020 02:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726777AbgHZGxR (ORCPT ); Wed, 26 Aug 2020 02:53:17 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8830C061574; Tue, 25 Aug 2020 23:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=SGTWnq2AQ38kIvWB9VYuxXbeJQGBBC+aSlZ9ZuRIk/o=; b=URLT5+GrMtH6TU2ggQIB9e3cS1 NReyEbguY4kT689u1FD6QTnTjjHtB3ICFWoXEGYD1P9Al01FBX3cHl2LzBPjJb3a4HrR5IXUNQTWL N/TF5wdk4b4ChbWXZzp92xHKW5A7btN5q2tDpbyfWzsga6/DVXyHZ2+pwYJCXzvtlY1kOZ++cB57N PilGLY0N++OTu0+mZOpIfUVeMIwqiyPI6H0E8R2kW6yWAFpe+1QcLyf7qixn6KtWXlfLVPwYlW3Tu hHyIC6EAKtOANuhPWu4pLgO7qpdsnjvnFOsaAv30IirDcv1d4PT8kNX7W+/y89qe0KuRVYwItRTT1 kD/KsRhg==; Received: from 213-225-6-196.nat.highway.a1.net ([213.225.6.196] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kApJ2-0003Lc-Dy; Wed, 26 Aug 2020 06:53:12 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Denis Efremov , "David S. Miller" , Song Liu , Al Viro , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, linux-raid@vger.kernel.org, linux-scsi@vger.kernel.org, linux-m68k@lists.linux-m68k.org Subject: [PATCH 12/19] md: use __register_blkdev to allocate devices on demand Date: Wed, 26 Aug 2020 08:24:39 +0200 Message-Id: <20200826062446.31860-13-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200826062446.31860-1-hch@lst.de> References: <20200826062446.31860-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the simpler mechanism attached to major_name to allocate a brd device when a currently unregistered minor is accessed. Signed-off-by: Christoph Hellwig --- drivers/md/md.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 60727820702300..3c4ef862ac5fb0 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5766,11 +5766,12 @@ static int md_alloc(dev_t dev, char *name) return error; } -static struct kobject *md_probe(dev_t dev, int *part, void *data) +static void md_probe(dev_t dev) { + if (MAJOR(dev) == MD_MAJOR && MINOR(dev) >= 512) + return; if (create_on_open) md_alloc(dev, NULL); - return NULL; } static int add_named_array(const char *val, const struct kernel_param *kp) @@ -6536,7 +6537,7 @@ static void autorun_devices(int part) break; } - md_probe(dev, NULL, NULL); + md_probe(dev); mddev = mddev_find(dev); if (!mddev || !mddev->gendisk) { if (mddev) @@ -9548,18 +9549,15 @@ static int __init md_init(void) if (!md_misc_wq) goto err_rdev_misc_wq; - if ((ret = register_blkdev(MD_MAJOR, "md")) < 0) + ret = __register_blkdev(MD_MAJOR, "md", md_probe); + if (ret < 0) goto err_md; - if ((ret = register_blkdev(0, "mdp")) < 0) + ret = __register_blkdev(0, "mdp", md_probe); + if (ret < 0) goto err_mdp; mdp_major = ret; - blk_register_region(MKDEV(MD_MAJOR, 0), 512, THIS_MODULE, - md_probe, NULL, NULL); - blk_register_region(MKDEV(mdp_major, 0), 1UL<