Commit 3b57ec8d authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (5/15) big struct block_device * push (first series)

 - switch blk_{get,set}_readahead() to struct block_device *
parent 7290bad4
......@@ -240,13 +240,13 @@ int blk_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long arg)
case BLKFRASET:
if(!capable(CAP_SYS_ADMIN))
return -EACCES;
return blk_set_readahead(dev, arg);
return blk_set_readahead(bdev, arg);
case BLKRAGET:
case BLKFRAGET:
if (!arg)
return -EINVAL;
return put_user(blk_get_readahead(dev), (long *)arg);
return put_user(blk_get_readahead(bdev), (long *)arg);
case BLKSECTGET:
if ((q = blk_get_queue(dev)) == NULL)
......
......@@ -115,13 +115,14 @@ inline request_queue_t *blk_get_queue(kdev_t dev)
*
* Returns zero on success, else negative errno
*/
int blk_set_readahead(kdev_t dev, unsigned sectors)
int blk_set_readahead(struct block_device *bdev, unsigned sectors)
{
int ret = -EINVAL;
request_queue_t *q = blk_get_queue(dev);
request_queue_t *q = blk_get_queue(to_kdev_t(bdev->bd_dev));
if (q) {
q->ra_sectors = sectors;
blk_put_queue(q);
ret = 0;
}
return ret;
......@@ -139,13 +140,15 @@ int blk_set_readahead(kdev_t dev, unsigned sectors)
* Will return zero if the queue has never had its readahead
* setting altered.
*/
unsigned blk_get_readahead(kdev_t dev)
unsigned blk_get_readahead(struct block_device *bdev)
{
unsigned ret = 0;
request_queue_t *q = blk_get_queue(dev);
request_queue_t *q = blk_get_queue(to_kdev_t(bdev->bd_dev));
if (q)
if (q) {
ret = q->ra_sectors;
blk_put_queue(q);
}
return ret;
}
......
......@@ -1577,7 +1577,7 @@ static int device_size_calculation(mddev_t * mddev)
if (!md_size[mdidx(mddev)])
md_size[mdidx(mddev)] = sb->size * data_disks;
readahead = (blk_get_readahead(rdev->dev) * 512) / PAGE_SIZE;
readahead = (blk_get_readahead(rdev->bdev) * 512) / PAGE_SIZE;
if (!sb->level || (sb->level == 4) || (sb->level == 5)) {
readahead = (mddev->sb->chunk_size>>PAGE_SHIFT) * 4 * data_disks;
if (readahead < data_disks * (MAX_SECTORS>>(PAGE_SHIFT-9))*2)
......
......@@ -314,8 +314,8 @@ extern void blk_queue_hardsect_size(request_queue_t *q, unsigned short);
extern void blk_queue_segment_boundary(request_queue_t *q, unsigned long);
extern void blk_queue_assign_lock(request_queue_t *q, spinlock_t *);
extern void blk_queue_prep_rq(request_queue_t *q, prep_rq_fn *pfn);
extern int blk_set_readahead(kdev_t dev, unsigned sectors);
extern unsigned blk_get_readahead(kdev_t dev);
extern int blk_set_readahead(struct block_device *bdev, unsigned sectors);
extern unsigned blk_get_readahead(struct block_device *bdev);
extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *);
extern void blk_dump_rq_flags(struct request *, char *);
......
......@@ -35,10 +35,11 @@ static int get_max_readahead(struct inode *inode)
{
unsigned blk_ra_kbytes = 0;
blk_ra_kbytes = blk_get_readahead(inode->i_dev) / 2;
if (inode->i_sb->s_bdev) {
blk_ra_kbytes = blk_get_readahead(inode->i_sb->s_bdev) / 2;
if (blk_ra_kbytes < VM_MIN_READAHEAD)
blk_ra_kbytes = VM_MAX_READAHEAD;
}
return blk_ra_kbytes >> (PAGE_CACHE_SHIFT - 10);
}
......
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