Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1221968pxk; Fri, 25 Sep 2020 09:08:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTYxaJJgMycNDdbr3z8ekqrX8voaAX13x0no3epfxeJBY/I6/spAYn1jUWazgm8eR5t7l8 X-Received: by 2002:a50:8e52:: with SMTP id 18mr2134116edx.28.1601050131781; Fri, 25 Sep 2020 09:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601050131; cv=none; d=google.com; s=arc-20160816; b=IxsZW8rOPG3SWq60bQpLINcN7zWVcLPiUd7Vn75diHytGkleyHWtQILWoYw56uEkUB lyFivSjetXahsj4NZDfHjaRWRvdsoL4Vjjo9g8KbtNv6qKZ7jkxkxs9SjInWjN3lZ/tc S+cWfCyOK5CamdWgRucTwVPvWYxVEUw8BNXO2jd7ebCuJf+/XW1lX0wHB0qOD2lt4Kxq bYUBBrxvdvrnL+A+cAD1lIOy/dJaHpNX50XpHjiZk9eS9TucOuu+VmJdWEwQSOBFen8n Avm9ubpP8HQgA11MrQt3kWNQODeNEgFQDx2Cqoe7Nv+TxIOhxFDa6GFGxt8X7qhdFOSa AcJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uQJgydSUoDayMaZ249oqW7zlbGRJdSVTgqWhb7/rJ3k=; b=ray4nNYFZYmDt2yubgP4Khpchb4I2/BK2qe2Nboy0CHe07pH/rg/shgeEe6UHKJVTA yol1SxosTzVIOwtSDrDOIAR40tR10hCeeKLyRXK90+fnH3cXRU9pKPd+cMj3tCGbkovR XhVedwqzH4wi8RcWDRXimqV0uaO5FCltXXMKCARLtfUH0nKXIIHa+LqiDbbYUV3bg6c6 7pbQqeB/hBUPt9BvzD970KL7W40i9RxFKL/21vf3nT4Wljl2C8+y9B1vD9dHbEF5oid7 kRZ/xqvUcjEd8Iq1ETP0XEYdXv9D01ypNNO/kKH4ukFGWbID92iNmjkrtL5mB5f8pzS2 drzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="cj/4AY1i"; 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 s19si2644608eja.288.2020.09.25.09.08.27; Fri, 25 Sep 2020 09:08:51 -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=pass header.i=@infradead.org header.s=casper.20170209 header.b="cj/4AY1i"; 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 S1728966AbgIYQGm (ORCPT + 99 others); Fri, 25 Sep 2020 12:06:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728858AbgIYQGm (ORCPT ); Fri, 25 Sep 2020 12:06:42 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3CD1C0613CE; Fri, 25 Sep 2020 09:06: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=uQJgydSUoDayMaZ249oqW7zlbGRJdSVTgqWhb7/rJ3k=; b=cj/4AY1inDNhDrclJrrVdCdYE+ PJvR/111DO97fIjVnQ14y2n3dlupQHcIJ/DkkbbQS3rpDbWSt50bn+xQWsabkwUb7YyV8SKlH1cO7 Hoe90eDO+/f1nOSbc1ugnU90h8Cz052p4U1tI1KWFWw+M+1zqleVC0aheX0+YbvjySe753X/V4N/+ Ewd6DbHsExdbRARUIHO1ZJmryZu6V3TdVKllEEEXXI+EGNk40D8tMlScIUB7ZgyLSOhYTpPnf2JYF AAof47/pFcDFKKKLi2aP44Xf+u7N2grImrufgZ/1wr528ymlA2LbAY/oZg+2FtW4YsVvKPvtGtDvI M0d/+vSA==; Received: from [213.208.157.35] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLqF5-0003Ow-HI; Fri, 25 Sep 2020 16:06:39 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Philipp Reisner , Lars Ellenberg , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, drbd-dev@lists.linbit.com Subject: [PATCH 2/2] block: add a bdget_part helper Date: Fri, 25 Sep 2020 18:06:18 +0200 Message-Id: <20200925160618.1481450-3-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200925160618.1481450-1-hch@lst.de> References: <20200925160618.1481450-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All remaining callers of bdget() outside of fs/block_dev.c want to get a reference to the struct block_device for a given struct hd_struct. Add a helper just for that and then mark bdget static. Signed-off-by: Christoph Hellwig --- block/genhd.c | 2 +- block/partitions/core.c | 2 +- fs/block_dev.c | 9 ++++++--- include/linux/blkdev.h | 2 +- kernel/trace/blktrace.c | 9 ++------- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index e5f17f022ec700..0a273211fec283 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1048,7 +1048,7 @@ struct block_device *bdget_disk(struct gendisk *disk, int partno) part = disk_get_part(disk, partno); if (part) - bdev = bdget(part_devt(part)); + bdev = bdget_part(part); disk_put_part(part); return bdev; diff --git a/block/partitions/core.c b/block/partitions/core.c index dd6811422a87af..5309e0f44ba352 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -580,7 +580,7 @@ int bdev_resize_partition(struct block_device *bdev, int partno, return -ENXIO; ret = -ENOMEM; - bdevp = bdget(part_devt(part)); + bdevp = bdget_part(part); if (!bdevp) goto out_put_part; diff --git a/fs/block_dev.c b/fs/block_dev.c index 6b9d19ffa5af7b..9e84b1928b9401 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -891,7 +891,7 @@ static int bdev_set(struct inode *inode, void *data) return 0; } -struct block_device *bdget(dev_t dev) +static struct block_device *bdget(dev_t dev) { struct block_device *bdev; struct inode *inode; @@ -920,8 +920,6 @@ struct block_device *bdget(dev_t dev) return bdev; } -EXPORT_SYMBOL(bdget); - /** * bdgrab -- Grab a reference to an already referenced block device * @bdev: Block device to grab a reference to. @@ -933,6 +931,11 @@ struct block_device *bdgrab(struct block_device *bdev) } EXPORT_SYMBOL(bdgrab); +struct block_device *bdget_part(struct hd_struct *part) +{ + return bdget(part_devt(part)); +} + long nr_blockdev_pages(void) { struct inode *inode; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d5a3e1a4c2f79b..cf80e61b4c5e1a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -2003,7 +2003,7 @@ void bd_abort_claiming(struct block_device *bdev, struct block_device *whole, void blkdev_put(struct block_device *bdev, fmode_t mode); struct block_device *I_BDEV(struct inode *inode); -struct block_device *bdget(dev_t); +struct block_device *bdget_part(struct hd_struct *part); struct block_device *bdgrab(struct block_device *bdev); void bdput(struct block_device *); diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index ec874ea040922a..f1022945e3460b 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -1827,13 +1827,11 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct hd_struct *p = dev_to_part(dev); + struct block_device *bdev = bdget_part(dev_to_part(dev)); struct request_queue *q; - struct block_device *bdev; struct blk_trace *bt; ssize_t ret = -ENXIO; - bdev = bdget(part_devt(p)); if (bdev == NULL) goto out; @@ -1875,7 +1873,6 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, { struct block_device *bdev; struct request_queue *q; - struct hd_struct *p; struct blk_trace *bt; u64 value; ssize_t ret = -EINVAL; @@ -1895,9 +1892,7 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, goto out; ret = -ENXIO; - - p = dev_to_part(dev); - bdev = bdget(part_devt(p)); + bdev = bdget_part(dev_to_part(dev)); if (bdev == NULL) goto out; -- 2.28.0