Commit 10ed1666 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: add a bdget_part helper

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 155bd9d1
...@@ -1048,7 +1048,7 @@ struct block_device *bdget_disk(struct gendisk *disk, int partno) ...@@ -1048,7 +1048,7 @@ struct block_device *bdget_disk(struct gendisk *disk, int partno)
part = disk_get_part(disk, partno); part = disk_get_part(disk, partno);
if (part) if (part)
bdev = bdget(part_devt(part)); bdev = bdget_part(part);
disk_put_part(part); disk_put_part(part);
return bdev; return bdev;
......
...@@ -580,7 +580,7 @@ int bdev_resize_partition(struct block_device *bdev, int partno, ...@@ -580,7 +580,7 @@ int bdev_resize_partition(struct block_device *bdev, int partno,
return -ENXIO; return -ENXIO;
ret = -ENOMEM; ret = -ENOMEM;
bdevp = bdget(part_devt(part)); bdevp = bdget_part(part);
if (!bdevp) if (!bdevp)
goto out_put_part; goto out_put_part;
......
...@@ -891,7 +891,7 @@ static int bdev_set(struct inode *inode, void *data) ...@@ -891,7 +891,7 @@ static int bdev_set(struct inode *inode, void *data)
return 0; return 0;
} }
struct block_device *bdget(dev_t dev) static struct block_device *bdget(dev_t dev)
{ {
struct block_device *bdev; struct block_device *bdev;
struct inode *inode; struct inode *inode;
...@@ -920,8 +920,6 @@ struct block_device *bdget(dev_t dev) ...@@ -920,8 +920,6 @@ struct block_device *bdget(dev_t dev)
return bdev; return bdev;
} }
EXPORT_SYMBOL(bdget);
/** /**
* bdgrab -- Grab a reference to an already referenced block device * bdgrab -- Grab a reference to an already referenced block device
* @bdev: Block device to grab a reference to. * @bdev: Block device to grab a reference to.
...@@ -933,6 +931,11 @@ struct block_device *bdgrab(struct block_device *bdev) ...@@ -933,6 +931,11 @@ struct block_device *bdgrab(struct block_device *bdev)
} }
EXPORT_SYMBOL(bdgrab); EXPORT_SYMBOL(bdgrab);
struct block_device *bdget_part(struct hd_struct *part)
{
return bdget(part_devt(part));
}
long nr_blockdev_pages(void) long nr_blockdev_pages(void)
{ {
struct inode *inode; struct inode *inode;
......
...@@ -2003,7 +2003,7 @@ void bd_abort_claiming(struct block_device *bdev, struct block_device *whole, ...@@ -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); void blkdev_put(struct block_device *bdev, fmode_t mode);
struct block_device *I_BDEV(struct inode *inode); 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); struct block_device *bdgrab(struct block_device *bdev);
void bdput(struct block_device *); void bdput(struct block_device *);
......
...@@ -1827,13 +1827,11 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev, ...@@ -1827,13 +1827,11 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) 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 request_queue *q;
struct block_device *bdev;
struct blk_trace *bt; struct blk_trace *bt;
ssize_t ret = -ENXIO; ssize_t ret = -ENXIO;
bdev = bdget(part_devt(p));
if (bdev == NULL) if (bdev == NULL)
goto out; goto out;
...@@ -1875,7 +1873,6 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, ...@@ -1875,7 +1873,6 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
{ {
struct block_device *bdev; struct block_device *bdev;
struct request_queue *q; struct request_queue *q;
struct hd_struct *p;
struct blk_trace *bt; struct blk_trace *bt;
u64 value; u64 value;
ssize_t ret = -EINVAL; ssize_t ret = -EINVAL;
...@@ -1895,9 +1892,7 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, ...@@ -1895,9 +1892,7 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
goto out; goto out;
ret = -ENXIO; ret = -ENXIO;
bdev = bdget_part(dev_to_part(dev));
p = dev_to_part(dev);
bdev = bdget(part_devt(p));
if (bdev == NULL) if (bdev == NULL)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment