From patchwork Wed Jul 21 15:35:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12391347 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 CE252C12002 for ; Wed, 21 Jul 2021 15:36:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAF8861208 for ; Wed, 21 Jul 2021 15:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239961AbhGUOz3 (ORCPT ); Wed, 21 Jul 2021 10:55:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239960AbhGUOz2 (ORCPT ); Wed, 21 Jul 2021 10:55:28 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE5BEC061575; Wed, 21 Jul 2021 08:36:04 -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=VLmrZ1nMakXrSQEwVKNiY15GTxcxuXeEsHd7IbCE5PY=; b=hcDnSX6aFOzCX0c9Xv3CT31FPt 4QALR56bFqigBvrNjAVTaeOaYBxXPqoHX4tAYjgBzP8SpVynMUvs/RL5caIB+WawIFQ3L+en9B1Gm C+ySicjsz0iFPqPh36UAcLd9RwY6gD7X4Lvs2qLFctP8eVRXC7i2nr21ljcfz8yuldBt2Erz00kTl 4LMcFmiJ8lqTqjkjyGB4i2YR8n8CRPIe1V6G41gioIfNhgFIecoPqwVMyGQbUK+R0dS9Bp3opHyE2 QpcnucxBZLP0+wTbuEkINtt5KsB7UC2HlcoHWOCk7Icp8xZjHagNZep9p1qdU85wkRNVw2AXxriS9 i1vH20PQ==; Received: from [2001:4bb8:193:7660:d6d5:72f4:23f7:1898] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EG3-009L8K-RU; Wed, 21 Jul 2021 15:35:42 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Josef Bacik , David Sterba , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 1/8] block: delay freeing the gendisk Date: Wed, 21 Jul 2021 17:35:16 +0200 Message-Id: <20210721153523.103818-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210721153523.103818-1-hch@lst.de> References: <20210721153523.103818-1-hch@lst.de> MIME-Version: 1.0 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-btrfs@vger.kernel.org blkdev_get_no_open acquires a reference to the block_device through the block device inode and then tries to acquire a device model reference to the gendisk. But at this point the disk migh already be freed (although the race is free). Fix this by only freeing the gendisk from the whole device bdevs ->free_inode callback as well. Fixes: 22ae8ce8b892 ("block: simplify bdev/disk lookup in blkdev_get") Signed-off-by: Christoph Hellwig Reviewed-by: Ming Lei --- block/genhd.c | 3 +-- fs/block_dev.c | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index af4d2ab4a633..e6d782714ad3 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1079,10 +1079,9 @@ static void disk_release(struct device *dev) disk_release_events(disk); kfree(disk->random); xa_destroy(&disk->part_tbl); - bdput(disk->part0); if (test_bit(GD_QUEUE_REF, &disk->state) && disk->queue) blk_put_queue(disk->queue); - kfree(disk); + bdput(disk->part0); } struct class block_class = { .name = "block", diff --git a/fs/block_dev.c b/fs/block_dev.c index 0c424a0cadaa..9ef4f1fc2cb0 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -812,6 +812,8 @@ static void bdev_free_inode(struct inode *inode) free_percpu(bdev->bd_stats); kfree(bdev->bd_meta_info); + if (!bdev_is_partition(bdev)) + kfree(bdev->bd_disk); kmem_cache_free(bdev_cachep, BDEV_I(inode)); } From patchwork Wed Jul 21 15:35:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12391349 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 E8A28C12002 for ; Wed, 21 Jul 2021 15:36:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C131661003 for ; Wed, 21 Jul 2021 15:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239990AbhGUOz5 (ORCPT ); Wed, 21 Jul 2021 10:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239989AbhGUOz4 (ORCPT ); Wed, 21 Jul 2021 10:55:56 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E13C0613C1; Wed, 21 Jul 2021 08:36:33 -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=VTPi1llWkhazjxtTAh8MC9pXMlokhMWd9PIJFYGaZ0c=; b=GHhxVNx+EMv/uR8uUiEKw2tfeu uhiZgS5J/xGji9jZGRFMoikU3TWRcuOhZSp0LM7fFIukzStST8cTNaVIwiI8JLa3+BnN5G3wmQFiq dlJu3xFNm8Zqh0lxFMUHCqMZFXSqRMj5Cn3wptFXD3pGxp4BdbfWrjPHSTCJTntov+o5HCUQbM6dg F5gD0rqDmnSo0zvTNicL66quz+BRtoiRqXkaVs7spbvhsxaeFuUPgU44SXPBWyEJF2N6DLswG8Tsa WZ863oZ0rHSqF7hYGtAOdG6QvmFO1jQ/NXANG778mu+Z5Vb70rcIJZVJmBEyCCL9KtvlNk+/anQoY FKAQNoxA==; Received: from [2001:4bb8:193:7660:d6d5:72f4:23f7:1898] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EGN-009L9o-HA; Wed, 21 Jul 2021 15:36:03 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Josef Bacik , David Sterba , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 2/8] block: assert the locking state in delete_partition Date: Wed, 21 Jul 2021 17:35:17 +0200 Message-Id: <20210721153523.103818-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210721153523.103818-1-hch@lst.de> References: <20210721153523.103818-1-hch@lst.de> MIME-Version: 1.0 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-btrfs@vger.kernel.org Add a lockdep assert instead of the outdated locking comment. Signed-off-by: Christoph Hellwig Reviewed-by: Ming Lei --- block/partitions/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/block/partitions/core.c b/block/partitions/core.c index 4230d4f71879..9902b1635b7d 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -281,12 +281,10 @@ struct device_type part_type = { .uevent = part_uevent, }; -/* - * Must be called either with open_mutex held, before a disk can be opened or - * after all disk users are gone. - */ static void delete_partition(struct block_device *part) { + lockdep_assert_held(&part->bd_disk->open_mutex); + fsync_bdev(part); __invalidate_device(part, true); From patchwork Wed Jul 21 15:35:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12391351 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 BDDACC12002 for ; Wed, 21 Jul 2021 15:36:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A55C161241 for ; Wed, 21 Jul 2021 15:36:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240000AbhGUO4R (ORCPT ); Wed, 21 Jul 2021 10:56:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239989AbhGUO4Q (ORCPT ); Wed, 21 Jul 2021 10:56:16 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19D95C061575; Wed, 21 Jul 2021 08:36:53 -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=DRl1bulNVhhJ/5L26dix7DT24Us5pkiiQGPRudilNhs=; b=rToEBv1z7Mg2mPNCvC/NNgK4U0 AsP6kuSFFEGkHuz/1MzEevB2eELnqoR4u+MlR/mIgqLDyysWWXDE91XaSNWh9OU0/Yku4WjIL54SA 3uGwZOZl92EZcxp55K5iJ6eGtGeWhAcG6+TfyjL2B4fLUceUFeh2rQ3UOZPrN5Dyow5wUci222p2V ArKASUyjQ7k+dhH8xlPUakASsHZ3HBGIz+A9xhppwO14d/33LMcThOU3gdG9kMaoyyJgHiC/nSOv9 di8utWoiBv+W0Js3rAT0weCMY/PJqPfmgzktuWSm+A+cCGhKSLbiGJHqPrBJ5hMdxuGw0tHv7KH/W eTq9AhNA==; Received: from [2001:4bb8:193:7660:d6d5:72f4:23f7:1898] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EGo-009LCj-BI; Wed, 21 Jul 2021 15:36:32 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Josef Bacik , David Sterba , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 3/8] block: grab a device model reference in blkdev_get_no_open Date: Wed, 21 Jul 2021 17:35:18 +0200 Message-Id: <20210721153523.103818-4-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210721153523.103818-1-hch@lst.de> References: <20210721153523.103818-1-hch@lst.de> MIME-Version: 1.0 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-btrfs@vger.kernel.org Opening a block device needs to ensure it is fully present instead of just the allocated memory. Switch from an inode reference as obtained by bdget to a full device model reference. In fact we should not use inode references for anything in the block layer. There are three users left, two can be trivially removed and the third (xen-blkfront) is a complete mess that needs more attention. Signed-off-by: Christoph Hellwig --- fs/block_dev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 9ef4f1fc2cb0..24a6970f3623 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1342,9 +1342,16 @@ struct block_device *blkdev_get_no_open(dev_t dev) goto bdput; if ((disk->flags & (GENHD_FL_UP | GENHD_FL_HIDDEN)) != GENHD_FL_UP) goto put_disk; - if (!try_module_get(bdev->bd_disk->fops->owner)) + if (!try_module_get(disk->fops->owner)) goto put_disk; + + /* switch to a device model reference instead of the inode one: */ + if (!kobject_get_unless_zero(&bdev->bd_device.kobj)) + goto put_module; + bdput(bdev); return bdev; +put_module: + module_put(disk->fops->owner); put_disk: put_disk(disk); bdput: @@ -1356,7 +1363,7 @@ void blkdev_put_no_open(struct block_device *bdev) { module_put(bdev->bd_disk->fops->owner); put_disk(bdev->bd_disk); - bdput(bdev); + put_device(&bdev->bd_device); } /** From patchwork Wed Jul 21 15:35:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12391353 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 038AAC12002 for ; Wed, 21 Jul 2021 15:37:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFBDF61003 for ; Wed, 21 Jul 2021 15:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239963AbhGUO4p (ORCPT ); Wed, 21 Jul 2021 10:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239918AbhGUO4p (ORCPT ); Wed, 21 Jul 2021 10:56:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D708CC061575; Wed, 21 Jul 2021 08:37:21 -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=+w6Rr29gIDk1wNuKf/xpu4+rFnUzeOZNDDXP8f8bW9U=; b=Rw5l3PlGp4XxSakzIu+g5R5gmt U5qpVXZXnQftGMGjO4ZLs0lumQp4Zq0sdp6+zbmn2Jj0VSyzx4MZIbLQe7WKhN4in2cpvoPTDQl8E Qjh3CDyuazQ7Ce6Tbv9pguNgbx7N5fRMPBPHoxgqKPOShWIJpzwnwC5B8o7P9bk2tQ/rhVhuF8ZOy My5wEZam4Bw95XaEaWJ8Nvz1irIDbm2Xs5y7gwNbn64LO8gMO8swfduPwJ5K4iGq3LJ5e8aYaW8MZ XGF9GoUJvu0nRQyHqEighZMEIxwuMeRR3Oqdlyr135jtgoHQyr13zh2+yItJLmRIcfJjBz6QJzyxZ NiIqLiPw==; Received: from [2001:4bb8:193:7660:d6d5:72f4:23f7:1898] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EHB-009LEm-OC; Wed, 21 Jul 2021 15:36:53 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Josef Bacik , David Sterba , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 4/8] block: don't grab a reference to the whole device in blkdev_get_part Date: Wed, 21 Jul 2021 17:35:19 +0200 Message-Id: <20210721153523.103818-5-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210721153523.103818-1-hch@lst.de> References: <20210721153523.103818-1-hch@lst.de> MIME-Version: 1.0 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-btrfs@vger.kernel.org blkdev_get_no_open already acquires a reference to the disk, which has the same effect as the disk keeps a reference on the whole device bdev. Signed-off-by: Christoph Hellwig --- fs/block_dev.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 24a6970f3623..7de519dcfdff 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1282,16 +1282,14 @@ static void blkdev_put_whole(struct block_device *bdev, fmode_t mode) static int blkdev_get_part(struct block_device *part, fmode_t mode) { struct gendisk *disk = part->bd_disk; - struct block_device *whole; int ret; if (part->bd_openers) goto done; - whole = bdgrab(disk->part0); - ret = blkdev_get_whole(whole, mode); + ret = blkdev_get_whole(bdev_whole(part), mode); if (ret) - goto out_put_whole; + return ret; ret = -ENXIO; if (!bdev_nr_sectors(part)) @@ -1306,9 +1304,7 @@ static int blkdev_get_part(struct block_device *part, fmode_t mode) return 0; out_blkdev_put: - blkdev_put_whole(whole, mode); -out_put_whole: - bdput(whole); + blkdev_put_whole(bdev_whole(part), mode); return ret; } @@ -1321,7 +1317,6 @@ static void blkdev_put_part(struct block_device *part, fmode_t mode) blkdev_flush_mapping(part); whole->bd_disk->open_partitions--; blkdev_put_whole(whole, mode); - bdput(whole); } struct block_device *blkdev_get_no_open(dev_t dev) From patchwork Wed Jul 21 15:35:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12391355 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 69930C12002 for ; Wed, 21 Jul 2021 15:37:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53F1061241 for ; Wed, 21 Jul 2021 15:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239982AbhGUO5H (ORCPT ); Wed, 21 Jul 2021 10:57:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239819AbhGUO5G (ORCPT ); Wed, 21 Jul 2021 10:57:06 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C9D0C061575; Wed, 21 Jul 2021 08:37:43 -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=d9VixLyLBmOaAtol1dnFl7Rez9u9mSdLSZuAkTnkVjE=; b=VbTbMxG0OEJq6PQIo3QERb1el0 B+GlVRuezgMm7LZCAXTGcFBoBY7v6IbriZxy+b9VyBV/LBjoKlQel8bewW4wxpSd1/7A6mRH+VPV9 OTF5xzZiHBLOx+fkcjj6NFQdMr+9buXyGgtvCdqvrCN9ByfEsZXJRuU2Yi6am40kB9rCeMaCYJGDP 8QGH/thJq/w+d2AjgnWFcMuspHuYc1+Lfw+oYvjshzr0/+PxIRkHoIsaa+X7tL75H9/z5KiJsGFKA hw1mSD6qP4MtYzgR1uFDfqUnVP6MwHsfMzE9I1U8k0oYUOQ/2JwxwVXamI3TAOnbK9S5gJH7VfqJS TDHGoBJQ==; Received: from [2001:4bb8:193:7660:d6d5:72f4:23f7:1898] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EHW-009LJf-JG; Wed, 21 Jul 2021 15:37:20 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Josef Bacik , David Sterba , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 5/8] btrfs: no need to grab a reference to disk->part0 Date: Wed, 21 Jul 2021 17:35:20 +0200 Message-Id: <20210721153523.103818-6-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210721153523.103818-1-hch@lst.de> References: <20210721153523.103818-1-hch@lst.de> MIME-Version: 1.0 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-btrfs@vger.kernel.org The struct block_device for the whole disk will not be freed while the disk in use, so don't bother to grab a reference to it. Signed-off-by: Christoph Hellwig Acked-by: David Sterba --- fs/btrfs/zoned.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 297c0b1c0634..21c5654967b0 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1362,20 +1362,16 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered) struct extent_map_tree *em_tree; struct extent_map *em; struct btrfs_ordered_sum *sum; - struct block_device *bdev; u64 orig_logical = ordered->disk_bytenr; u64 *logical = NULL; int nr, stripe_len; /* Zoned devices should not have partitions. So, we can assume it is 0 */ ASSERT(ordered->partno == 0); - bdev = bdgrab(ordered->disk->part0); - if (WARN_ON(!bdev)) - return; - if (WARN_ON(btrfs_rmap_block(fs_info, orig_logical, bdev, - ordered->physical, &logical, &nr, - &stripe_len))) + if (WARN_ON(btrfs_rmap_block(fs_info, orig_logical, + ordered->disk->part0, ordered->physical, &logical, + &nr, &stripe_len))) goto out; WARN_ON(nr != 1); @@ -1402,7 +1398,6 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered) out: kfree(logical); - bdput(bdev); } bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, From patchwork Wed Jul 21 15:35:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12391357 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=-11.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 B64EDC636CA for ; Wed, 21 Jul 2021 15:38:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3AFD61208 for ; Wed, 21 Jul 2021 15:38:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239991AbhGUO5W (ORCPT ); Wed, 21 Jul 2021 10:57:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239984AbhGUO5V (ORCPT ); Wed, 21 Jul 2021 10:57:21 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D19BC061575; Wed, 21 Jul 2021 08: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=JTQg97LfXhxEgJekbyUthk6njZqT/SjBp9PCGRorI7M=; b=fxkhrVaAFHh/AQwNj5JMO3k1Uq Z3U+FgpJGnjPGO/uHD7115X5hbREHDsDXsjZbnzKaeRj2sy2pPHdplyeIlcpC78ENsw1N4oJbCG0C oxtg25ymSjEXJ2SRXaC3diCIxecmYA/2w/N0BszhHBLJpWv/LLmgNsuWsK8/kjCrm5QdaXsIHw4uY QZNkw/lWprzJNqbVMJcPxnncZwbTTvHgOnIH4MDxWoq+Of419h7W/juuXrjdeX6M/jRYqYZduzp3a Ep3Cue9GvwwUMYmgO/zlRKsGGcdOTMWUJCxDQeh1L1X3vlRUweq1+9NYJv1MJ2Osb0172XdQCzek1 bF2qM0GA==; Received: from [2001:4bb8:193:7660:d6d5:72f4:23f7:1898] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EHx-009LM2-Dv; Wed, 21 Jul 2021 15:37:41 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Josef Bacik , David Sterba , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 6/8] loop: don't grab a reference to the block device Date: Wed, 21 Jul 2021 17:35:21 +0200 Message-Id: <20210721153523.103818-7-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210721153523.103818-1-hch@lst.de> References: <20210721153523.103818-1-hch@lst.de> MIME-Version: 1.0 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-btrfs@vger.kernel.org The whole device block device won't be removed while the disk is still alive, so don't bother to grab a reference to it. --- drivers/block/loop.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index f37b9e3d833c..62c5120cf744 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1249,10 +1249,6 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, if (partscan) lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN; - /* Grab the block_device to prevent its destruction after we - * put /dev/loopXX inode. Later in __loop_clr_fd() we bdput(bdev). - */ - bdgrab(bdev); mutex_unlock(&lo->lo_mutex); if (partscan) loop_reread_partitions(lo); @@ -1332,7 +1328,6 @@ static int __loop_clr_fd(struct loop_device *lo, bool release) blk_queue_physical_block_size(lo->lo_queue, 512); blk_queue_io_min(lo->lo_queue, 512); if (bdev) { - bdput(bdev); invalidate_bdev(bdev); bdev->bd_inode->i_mapping->wb_err = 0; } From patchwork Wed Jul 21 15:35:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12391377 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 465AAC6377A for ; Wed, 21 Jul 2021 15:38:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BF0561003 for ; Wed, 21 Jul 2021 15:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240046AbhGUO5r (ORCPT ); Wed, 21 Jul 2021 10:57:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239912AbhGUO5q (ORCPT ); Wed, 21 Jul 2021 10:57:46 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3873AC06179A; Wed, 21 Jul 2021 08:38:18 -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=mq3s3MlPrrHCTu21Vhkw6lau0FtaRZ+ohY6DRxCoHfc=; b=abAwAOxjorfNgU9ZxzP6Evn1nC o+cSQBC/rxum54/Kd82exUKgNKs41aD6P7L119fJ4P6VOQkS4w585xC89dG7VaFajAlecfnNByY8Z vcqRRxKOxV/dQilPgo2q8P10vf/7EBY5xAB+jjLzblxUiCEPVoJSuQmnaQTCJrr7bYeSNcNa62mOM bAvR24QC75/XRzxkqPbxauh70OpQQr97Qj9u74PAIZNxZ8Rla+Uh9qx6mwRHsGdpze+7egNtOD4k5 JQgy1htNMaKPclmfC3DqMdptZLQmxSLd3oWkLXFg4ezUNQXksG5dZtpW821cDfTvDpSWkO2xPfyLW zbGu9Vjw==; Received: from [2001:4bb8:193:7660:d6d5:72f4:23f7:1898] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EI9-009LNh-So; Wed, 21 Jul 2021 15:37:56 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Josef Bacik , David Sterba , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 7/8] block: remove bdgrab Date: Wed, 21 Jul 2021 17:35:22 +0200 Message-Id: <20210721153523.103818-8-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210721153523.103818-1-hch@lst.de> References: <20210721153523.103818-1-hch@lst.de> MIME-Version: 1.0 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-btrfs@vger.kernel.org All callers are gone, and no one should grab a pure inode reference to a block device anymore. Signed-off-by: Christoph Hellwig --- fs/block_dev.c | 15 --------------- include/linux/blkdev.h | 1 - 2 files changed, 16 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 7de519dcfdff..5c56d88fd838 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -931,21 +931,6 @@ static struct block_device *bdget(dev_t dev) return &BDEV_I(inode)->bdev; } -/** - * bdgrab -- Grab a reference to an already referenced block device - * @bdev: Block device to grab a reference to. - * - * Returns the block_device with an additional reference when successful, - * or NULL if the inode is already beeing freed. - */ -struct block_device *bdgrab(struct block_device *bdev) -{ - if (!igrab(bdev->bd_inode)) - return NULL; - return bdev; -} -EXPORT_SYMBOL(bdgrab); - long nr_blockdev_pages(void) { struct inode *inode; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 3177181c4326..98772da38bb1 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1984,7 +1984,6 @@ void blkdev_put_no_open(struct block_device *bdev); struct block_device *bdev_alloc(struct gendisk *disk, u8 partno); void bdev_add(struct block_device *bdev, dev_t dev); struct block_device *I_BDEV(struct inode *inode); -struct block_device *bdgrab(struct block_device *bdev); void bdput(struct block_device *); int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart, loff_t lend); From patchwork Wed Jul 21 15:35:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12391379 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 E40ABC12002 for ; Wed, 21 Jul 2021 15:38:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6BC561241 for ; Wed, 21 Jul 2021 15:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240063AbhGUO6F (ORCPT ); Wed, 21 Jul 2021 10:58:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240062AbhGUO6E (ORCPT ); Wed, 21 Jul 2021 10:58:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61C70C061575; Wed, 21 Jul 2021 08:38:41 -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=uM2IDLBT3+Rvi8KOFX4nLAoMywh5C8Lsp0Ru5hR1yyI=; b=N2245fOK7YHQXal86uocL9+T50 xUzCM1/mPMRryZPcPrEoc9FXPsBAvXJqBez8cyamSko/cLDW2CH06Xwf1krjv/MgLlIYXg6Lb3QE3 6ldQ3NbeOfL+cRWnuyOaMItcyKOGi0KS1KSyVq+T+IUZuEPU9G0kGfGzIAZ5NQoarYtnkGntmmfmA iadaGyRGqoUPyaAYEhcsN6L1+9+LYEOC2Hs3zs7CRm82i56B8gdX14/7pSwyyK3bBMpu7qzfoG/kW lyeyZF1834UsbkXUVAUk309pHSOSfVys9wmYebaNfzXvRy5AGRJYvKu3pE7fsBrAsEc3TRHk4inv8 v4jPzJMQ==; Received: from [2001:4bb8:193:7660:d6d5:72f4:23f7:1898] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EIT-009LOq-4a; Wed, 21 Jul 2021 15:38:16 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Josef Bacik , David Sterba , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 8/8] block: remove bdget/bdput Date: Wed, 21 Jul 2021 17:35:23 +0200 Message-Id: <20210721153523.103818-9-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210721153523.103818-1-hch@lst.de> References: <20210721153523.103818-1-hch@lst.de> MIME-Version: 1.0 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-btrfs@vger.kernel.org Now that we've stopped using inode references for anything meaninful in the block layer get rid of the helpers for it and just open code the places that look up a block device by dev_t and drop the main inode reference held by the device model. Signed-off-by: Christoph Hellwig --- block/genhd.c | 4 ++-- block/partitions/core.c | 8 ++++---- fs/block_dev.c | 34 ++++++++++------------------------ include/linux/blkdev.h | 1 - 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index e6d782714ad3..3ea27bee0615 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1081,7 +1081,7 @@ static void disk_release(struct device *dev) xa_destroy(&disk->part_tbl); if (test_bit(GD_QUEUE_REF, &disk->state) && disk->queue) blk_put_queue(disk->queue); - bdput(disk->part0); + iput(disk->part0->bd_inode); /* actually frees the disk */ } struct class block_class = { .name = "block", @@ -1266,7 +1266,7 @@ struct gendisk *__alloc_disk_node(int minors, int node_id) out_destroy_part_tbl: xa_destroy(&disk->part_tbl); - bdput(disk->part0); + iput(disk->part0->bd_inode); out_free_disk: kfree(disk); return NULL; diff --git a/block/partitions/core.c b/block/partitions/core.c index 9902b1635b7d..4397ac9f905e 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -261,7 +261,7 @@ static void part_release(struct device *dev) { if (MAJOR(dev->devt) == BLOCK_EXT_MAJOR) blk_free_ext_minor(MINOR(dev->devt)); - bdput(dev_to_bdev(dev)); + iput(dev_to_bdev(dev)->bd_inode); } static int part_uevent(struct device *dev, struct kobj_uevent_env *env) @@ -360,7 +360,7 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, err = -ENOMEM; bdev->bd_meta_info = kmemdup(info, sizeof(*info), GFP_KERNEL); if (!bdev->bd_meta_info) - goto out_bdput; + goto out_iput; } pdev = &bdev->bd_device; @@ -415,8 +415,8 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, kobject_uevent(&pdev->kobj, KOBJ_ADD); return bdev; -out_bdput: - bdput(bdev); +out_iput: + iput(bdev->bd_inode); return ERR_PTR(err); out_del: kobject_put(bdev->bd_holder_dir); diff --git a/fs/block_dev.c b/fs/block_dev.c index 5c56d88fd838..8747c264e64c 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -921,16 +921,6 @@ void bdev_add(struct block_device *bdev, dev_t dev) insert_inode_hash(bdev->bd_inode); } -static struct block_device *bdget(dev_t dev) -{ - struct inode *inode; - - inode = ilookup(blockdev_superblock, dev); - if (!inode) - return NULL; - return &BDEV_I(inode)->bdev; -} - long nr_blockdev_pages(void) { struct inode *inode; @@ -944,12 +934,6 @@ long nr_blockdev_pages(void) return ret; } -void bdput(struct block_device *bdev) -{ - iput(bdev->bd_inode); -} -EXPORT_SYMBOL(bdput); - /** * bd_may_claim - test whether a block device can be claimed * @bdev: block device of interest @@ -1308,18 +1292,20 @@ struct block_device *blkdev_get_no_open(dev_t dev) { struct block_device *bdev; struct gendisk *disk; + struct inode *inode; - bdev = bdget(dev); - if (!bdev) { + inode = ilookup(blockdev_superblock, dev); + if (!inode) { blk_request_module(dev); - bdev = bdget(dev); - if (!bdev) + inode = ilookup(blockdev_superblock, dev); + if (!inode) return NULL; } + bdev = &BDEV_I(inode)->bdev; disk = bdev->bd_disk; if (!kobject_get_unless_zero(&disk_to_dev(disk)->kobj)) - goto bdput; + goto iput; if ((disk->flags & (GENHD_FL_UP | GENHD_FL_HIDDEN)) != GENHD_FL_UP) goto put_disk; if (!try_module_get(disk->fops->owner)) @@ -1328,14 +1314,14 @@ struct block_device *blkdev_get_no_open(dev_t dev) /* switch to a device model reference instead of the inode one: */ if (!kobject_get_unless_zero(&bdev->bd_device.kobj)) goto put_module; - bdput(bdev); + iput(bdev->bd_inode); return bdev; put_module: module_put(disk->fops->owner); put_disk: put_disk(disk); -bdput: - bdput(bdev); +iput: + iput(bdev->bd_inode); return NULL; } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 98772da38bb1..b94de1d194b8 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1984,7 +1984,6 @@ void blkdev_put_no_open(struct block_device *bdev); struct block_device *bdev_alloc(struct gendisk *disk, u8 partno); void bdev_add(struct block_device *bdev, dev_t dev); struct block_device *I_BDEV(struct inode *inode); -void bdput(struct block_device *); int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart, loff_t lend);