Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3439427pxa; Tue, 25 Aug 2020 23:39:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYueGXKBgm0wV+EfFHwTpf01JA3dywCmXucqEw4/X76Xroq82YjIsy8vyCIx9j6HIZw1mC X-Received: by 2002:a17:906:25c1:: with SMTP id n1mr14606574ejb.463.1598423986555; Tue, 25 Aug 2020 23:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598423986; cv=none; d=google.com; s=arc-20160816; b=CyXY7LmKlvycXpPqMdbGxc9eg2BC1FQofiLvx9djjNsx4xpLUGze/GiiQfVjGZKbHC sFByw4bmx7wkMAa/ZSudtoAAAQXrjM6HpLa38u6Ck7Q8IUNhtafnB2R5WViRuC9K0gmc jJ/zZQSwMAWV4ojcQN2jy5EpiwJtzkt6fdUZHZVENFD7P+PKh9oUpvau3AgH9WhhsHqw U7f7qK7bQaDxhD1nPbsy96avzEN7FC2sp+Nj+3p7m1lvOPX77shVCZ6U/ghsD9zhq69u 6TQvmGGrL/OSH1hbVwP+1R48ov/itvcYiDmNsx94DIPETTSjiPgJO52K8osTVIyUBQLQ k5GQ== 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=YM1SPyKS6FTgRnphdLuuProv8AP/xrdO+TruNwolZXE=; b=jils+/e8EfWP5clBBxf+PukTzDSpgg6zEjxl1D0lkkdzST3Lzk19uLcY84syHwrRE7 /C9Vh6jVZd7x5b/kNGS+lRS/ou+gMKEIGEp4tFLMUILekqtMcsJPjpy+j7UU4WDcMDxw xJ0tjwNlygV221MEtLa9gUM0demsT6twwZdDydOLoJCcGGS6aVcG3NWpZ2qZs8xIzum3 ojSGvjcAXbFQxXSiOyCNGHaeXnbmicj3jZP8KZ+g9cFn6pnwP66NNLWM+pqtCHwn3y/n omFDClu9KHNz8+ULn7crNiZKvpodqGPsFPF9r6jUQKaedmMc0VqPZhnPWsUMbkg0odzV noGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=ok73YApw; 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 z22si966193ejl.181.2020.08.25.23.39.23; Tue, 25 Aug 2020 23:39:46 -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=ok73YApw; 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 S1727881AbgHZGiC (ORCPT + 99 others); Wed, 26 Aug 2020 02:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726803AbgHZGh6 (ORCPT ); Wed, 26 Aug 2020 02:37:58 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B7AEC061574; Tue, 25 Aug 2020 23:37:58 -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=YM1SPyKS6FTgRnphdLuuProv8AP/xrdO+TruNwolZXE=; b=ok73YApw3T5uoRJ3BGq5K6RNxv Z2iHareQaiyAmDdHP7LeGBzk2eyg5CxYao1PWfWAxYYM36qrQVaJsQbe+A4HXkP51eU7EI7BCBK6u FR8MpG73s0zCgoC7wJgM4gNFSCuBaUUoVNnXjz45qxaMH/M7hyPbI7LxtmrJq/vzTyt6/X3FEg9TH 6ICsW4rgPgzLy1zh8SNUG2bVtrbktJ815HbTpJsS+9aPSp9kMCz9BKm4ivRafGHiSVIU3AONl8Yx5 PPulRVlzXdEbYGV3rle2h2S+C98o3TOpNDuTg9l/20lXpggd3fWrd0515NRqCyE5a704FQVMIiCNe CfXFhMHg==; 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 1kAp4C-0001oY-Tj; Wed, 26 Aug 2020 06:37:53 +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 05/19] block: rework requesting modules for unclaimed devices Date: Wed, 26 Aug 2020 08:24:32 +0200 Message-Id: <20200826062446.31860-6-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 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 0ae6210e141ee5..00164304317cfa 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1035,6 +1035,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; @@ -1059,6 +1066,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; @@ -1297,15 +1312,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; @@ -1317,7 +1323,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