Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp351212pxk; Thu, 3 Sep 2020 01:03:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUSoXi7w7ZX+9CZ1ZgfYTkatRRoIOV1SlkXtbXvvBsbZW+KXTgZIPClomSCrIK6vVV0+8+ X-Received: by 2002:a17:906:80d3:: with SMTP id a19mr924401ejx.217.1599120183821; Thu, 03 Sep 2020 01:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599120183; cv=none; d=google.com; s=arc-20160816; b=mSwXF8842IQt3jvII3ouoAHGQpn0dYNCgfUGUyCWjjWC/rz1GxHJvjqHZsRyz+rwGc 5hdz0RPJdUcCDN5Wem8Ti+rsvdFVOifA7QmSApjeEe7fsdtxBfWUnbOdnnTMcTng6xI/ aua0BUukR0k3RsIMN2WajxSFgewVnipWK+QFdXEaBa0AizKNVddLwSHlX7i8pgXb2hZa +a+NDcXZ5mvc/lY4xnDW7IGCx2CDD8QmAUqUfpq7VKb5YwaiyuCs1W/ARHHkqGBrZ5Do SspqODWP9AsnDiqfmWy+Yho/cICCjNY1VWnzmeJmhbNXwbrPbKtRHCB3e+fQqvs8PkWr LjlQ== 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=fJTVHoNxUlMuJzi3OYs8sn2ItKAjUAcSzacbWJG6mPI=; b=iduM02/Ree8Uxn3wd/KGXPvBBmGcqbX8axI/nzw0zjYpkcZ4jxzb5ySikdkOlfPhNE nAH3Ih4wR8HURDhi7d7UBmuICrb9iZvn0eIZg0Wzr/L46H3+SuAnI0/u2D5MdyKhk7JA ns3+qTQkC/ini162Ra5Akmp+pjcO3JBWlUQMJGOgygzdab0dOtpbSyhpgD6ry926L3ZS upyKfaAeHvaSj/pou7Ue+uyBtyZPnywANKefRCZimddHUmnuqUmwyjuzj3c4chVWtOtR Jn8/w8IBRIcimpK9pvo23WiISKKV4+abHAWw9ERvqocmd7JiImSsPI+5TQ+n4xPafqWc 0jHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=oACVtckc; 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 y22si1460809ejc.453.2020.09.03.01.02.40; Thu, 03 Sep 2020 01:03:03 -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=oACVtckc; 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 S1728350AbgICICA (ORCPT + 99 others); Thu, 3 Sep 2020 04:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727986AbgICIBg (ORCPT ); Thu, 3 Sep 2020 04:01:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EF44C061244; Thu, 3 Sep 2020 01:01:36 -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=fJTVHoNxUlMuJzi3OYs8sn2ItKAjUAcSzacbWJG6mPI=; b=oACVtckcVomEmZngDx80pXXX85 LIxpxKzzb7pKwraYWxZaPxWPmJHeFVVdtfSkH2KkJ74nJQTnrdyQReb+n9SYeN9//R5FBF1TxRlne kcKB6ZwVBIyJSz67tZfQoWbvda9uIBV9tYVWItvldVmNPMJw09EZ3jbz6FVhj0iLVf1w90ITbDMHC tX8WCq0BEZMWG+mip95o0Y5RjKAgNXzmNwt7Nlv/2VwJ9zD9fsXF6rKH7Vm/VdMVYK5ynWaEUXl8H 9dcS4nsA/31+j6yuuIezhXj0w67+UMHgIIO/GqMENhopKOuUSJ8LTV2iHiPxVG5Z+KWBV1FodMiWc WzhK6Q2w==; Received: from [2001:4bb8:184:af1:c70:4a89:bc61:2] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDkBU-0006aj-D3; Thu, 03 Sep 2020 08:01:28 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Denis Efremov , "David S. Miller" , Song Liu , Al Viro , Finn Thain , Michael Schmitz , 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 05/19] block: rework requesting modules for unclaimed devices Date: Thu, 3 Sep 2020 10:01:05 +0200 Message-Id: <20200903080119.441674-6-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200903080119.441674-1-hch@lst.de> References: <20200903080119.441674-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 Instead of reusing the ranges in bdev_map, add a new helper that is called if no ranges was found. This is a first step to unpeel and eventually remove the complex ranges structure. Signed-off-by: Christoph Hellwig --- block/genhd.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 034e9089965a82..d9ecc751fc956c 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1033,6 +1033,13 @@ static ssize_t disk_badblocks_store(struct device *dev, return badblocks_store(disk->bb, page, len, 0); } +static void request_gendisk_module(dev_t devt) +{ + if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0) + /* Make old-style 2.4 aliases work */ + request_module("block-major-%d", MAJOR(devt)); +} + static struct gendisk *lookup_gendisk(dev_t dev, int *partno) { struct kobject *kobj; @@ -1057,6 +1064,14 @@ static struct gendisk *lookup_gendisk(dev_t dev, int *partno) probe = p->probe; best = p->range - 1; *partno = dev - p->dev; + + if (!probe) { + mutex_unlock(&bdev_map_lock); + module_put(owner); + request_gendisk_module(dev); + goto retry; + } + if (p->lock && p->lock(dev, data) < 0) { module_put(owner); continue; @@ -1295,15 +1310,6 @@ static const struct seq_operations partitions_op = { }; #endif - -static struct kobject *base_probe(dev_t devt, int *partno, void *data) -{ - if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0) - /* Make old-style 2.4 aliases work */ - request_module("block-major-%d", MAJOR(devt)); - return NULL; -} - static void bdev_map_init(void) { struct bdev_map *base; @@ -1315,7 +1321,6 @@ static void bdev_map_init(void) base->dev = 1; base->range = ~0 ; - base->probe = base_probe; for (i = 0; i < 255; i++) bdev_map[i] = base; } -- 2.28.0