Commit 08b0fb25 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] kdev_t -> bdev cleanups [2/2]

 - move the contents of bdev_get_queue() into do_open() and
   check_partitions() and cache the result in new field of struct
   block_device

 - clean it at the same places that reset ->bd_op, etc.

 - make bdev_get_queue() return cached pointer.
parent f70ca426
......@@ -92,12 +92,7 @@ int blk_nohighio = 0;
**/
inline request_queue_t *bdev_get_queue(struct block_device *bdev)
{
kdev_t dev = to_kdev_t(bdev->bd_dev);
struct blk_dev_struct *p = blk_dev + major(dev);
if (p->queue)
return p->queue(dev);
else
return &blk_dev[major(dev)].request_queue;
return bdev->bd_queue;
}
/**
......
......@@ -322,6 +322,7 @@ struct block_device *bdget(dev_t dev)
atomic_set(&new_bdev->bd_count,1);
new_bdev->bd_dev = dev;
new_bdev->bd_op = NULL;
new_bdev->bd_queue = NULL;
new_bdev->bd_contains = NULL;
new_bdev->bd_inode = inode;
inode->i_mode = S_IFBLK;
......@@ -607,6 +608,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
}
bdev->bd_inode->i_size = blkdev_size(dev);
if (!bdev->bd_openers) {
struct blk_dev_struct *p = blk_dev + major(dev);
unsigned bsize = bdev_hardsect_size(bdev);
while (bsize < PAGE_CACHE_SIZE) {
if (bdev->bd_inode->i_size & bsize)
......@@ -615,6 +617,10 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
}
bdev->bd_block_size = bsize;
bdev->bd_inode->i_blkbits = blksize_bits(bsize);
if (p->queue)
bdev->bd_queue = p->queue(dev);
else
bdev->bd_queue = &p->request_queue;
}
bdev->bd_openers++;
unlock_kernel();
......@@ -624,6 +630,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
out2:
if (!bdev->bd_openers) {
bdev->bd_op = NULL;
bdev->bd_queue = NULL;
bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
if (bdev != bdev->bd_contains) {
blkdev_put(bdev->bd_contains, BDEV_RAW);
......@@ -698,6 +705,7 @@ int blkdev_put(struct block_device *bdev, int kind)
__MOD_DEC_USE_COUNT(bdev->bd_op->owner);
if (!bdev->bd_openers) {
bdev->bd_op = NULL;
bdev->bd_queue = NULL;
bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
if (bdev != bdev->bd_contains) {
blkdev_put(bdev->bd_contains, BDEV_RAW);
......
......@@ -255,12 +255,17 @@ static void check_partition(struct gendisk *hd, kdev_t dev, int first_part_minor
bdev->bd_contains = bdev;
bdev->bd_inode->i_size = (loff_t)hd->part[minor(dev)].nr_sects << 9;
if (!bdev->bd_openers) {
struct blk_dev_struct *p = blk_dev + major(dev);
unsigned bsize = bdev_hardsect_size(bdev);
while (bsize < PAGE_CACHE_SIZE) {
if (bdev->bd_inode->i_size & bsize)
break;
bsize <<= 1;
}
if (p->queue)
bdev->bd_queue = p->queue(dev);
else
bdev->bd_queue = &p->request_queue;
bdev->bd_block_size = bsize;
bdev->bd_inode->i_blkbits = blksize_bits(bsize);
}
......
......@@ -341,6 +341,7 @@ struct block_device {
dev_t bd_dev; /* not a kdev_t - it's a search key */
int bd_openers;
const struct block_device_operations *bd_op;
struct request_queue *bd_queue;
struct semaphore bd_sem; /* open/close mutex */
struct list_head bd_inodes;
void * bd_holder;
......
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