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