Commit 13b52b0b authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

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

 - new helpers: queue_hardsect_size() and bdev_hardsect_size().  Analogous
   to get_hardsect_size() for queue and struct block_device * respectively
   Most of get_hardsect_size() callers converted to these.
parent c4354130
......@@ -266,7 +266,7 @@ int blk_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long arg)
case BLKSSZGET:
/* get block device hardware sector size */
intval = get_hardsect_size(dev);
intval = bdev_hardsect_size(bdev);
return put_user(intval, (int *) arg);
case BLKGETSIZE:
......
......@@ -363,7 +363,7 @@ void blk_dump_rq_flags(struct request *rq, char *msg)
*/
int ll_10byte_cmd_build(request_queue_t *q, struct request *rq)
{
int hard_sect = get_hardsect_size(rq->rq_dev);
int hard_sect = queue_hardsect_size(q);
sector_t block = rq->hard_sector / (hard_sect >> 9);
unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9);
......@@ -1501,7 +1501,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head * bhs[])
major = major(bhs[0]->b_dev);
/* Determine correct block size for this device. */
correct_size = get_hardsect_size(bhs[0]->b_dev);
correct_size = bdev_hardsect_size(bhs[0]->b_bdev);
/* Verify requested block sizes. */
for (i = 0; i < nr; i++) {
......
......@@ -69,7 +69,6 @@ int raw_open(struct inode *inode, struct file *filp)
{
int minor;
struct block_device * bdev;
kdev_t rdev; /* it should eventually go away */
int err;
int sector_size;
int sector_bits;
......@@ -104,7 +103,6 @@ int raw_open(struct inode *inode, struct file *filp)
goto out;
atomic_inc(&bdev->bd_count);
rdev = to_kdev_t(bdev->bd_dev);
err = blkdev_get(bdev, filp->f_mode, 0, BDEV_RAW);
if (err)
goto out;
......@@ -117,7 +115,7 @@ int raw_open(struct inode *inode, struct file *filp)
if (raw_devices[minor].inuse++)
goto out;
sector_size = get_hardsect_size(rdev);
sector_size = bdev_hardsect_size(bdev);
raw_devices[minor].sector_size = sector_size;
for (sector_bits = 0; !(sector_size & 1); )
sector_size>>=1, sector_bits++;
......
......@@ -857,7 +857,7 @@ static int lvm_blk_ioctl(struct inode *inode, struct file *file,
switch (command) {
case BLKSSZGET:
/* get block device sector size as needed e.g. by fdisk */
return put_user(get_hardsect_size(inode->i_rdev), (int *) arg);
return put_user(bdev_hardsect_size(inode->i_bdev), (int *) arg);
case BLKGETSIZE:
/* return device size */
......
......@@ -1711,8 +1711,8 @@ static int do_md_run(mddev_t * mddev)
continue;
invalidate_device(rdev->dev, 1);
md_blocksizes[mdidx(mddev)] = 1024;
if (get_hardsect_size(rdev->dev) > md_blocksizes[mdidx(mddev)])
md_blocksizes[mdidx(mddev)] = get_hardsect_size(rdev->dev);
if (bdev_hardsect_size(rdev->bdev) > md_blocksizes[mdidx(mddev)])
md_blocksizes[mdidx(mddev)] = bdev_hardsect_size(rdev->bdev);
}
mddev->pers = pers[pnum];
......
......@@ -1345,7 +1345,7 @@ ccw_req_t * tape34xx_bread (struct request *req,tape_info_t* ti,int tapeblock_ma
__u8 *data;
kdev_t dev = mk_kdev(tapeblock_major, ti->blk_minor);
unsigned bsize = block_size(dev);
int s2b = bsize/get_hardsect_size(dev);
int s2b = bsize/queue_hardsect_size(&ti->request_queue);
int realcount;
int size,bhct = 0;
struct buffer_head* bh;
......
......@@ -106,7 +106,7 @@ int sb_set_blocksize(struct super_block *sb, int size)
int sb_min_blocksize(struct super_block *sb, int size)
{
int minsize = get_hardsect_size(sb->s_dev);
int minsize = bdev_hardsect_size(sb->s_bdev);
if (size < minsize)
size = minsize;
return sb_set_blocksize(sb, size);
......
......@@ -2351,7 +2351,7 @@ static int grow_buffers(struct block_device *bdev, unsigned long block, int size
int sizebits;
/* Size must be multiple of hard sectorsize */
if (size & (get_hardsect_size(to_kdev_t(bdev->bd_dev))-1))
if (size & (bdev_hardsect_size(bdev)-1))
BUG();
/* Size must be within 512 bytes and PAGE_SIZE */
if (size < 512 || size > PAGE_SIZE)
......
......@@ -943,7 +943,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
unsigned long logic_sb_block = 1;
unsigned long offset = 0;
unsigned long journal_inum = 0;
kdev_t dev = sb->s_dev;
int blocksize;
int hblock;
int db_count;
......@@ -1033,7 +1032,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
sb->s_maxbytes = ext3_max_size(sb->s_blocksize_bits);
hblock = get_hardsect_size(dev);
hblock = bdev_hardsect_size(sb->s_bdev);
if (sb->s_blocksize != blocksize) {
/*
* Make sure the blocksize for the filesystem is larger
......@@ -1322,7 +1321,7 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
return NULL;
blocksize = sb->s_blocksize;
hblock = get_hardsect_size(j_dev);
hblock = bdev_hardsect_size(bdev);
if (blocksize < hblock) {
printk(KERN_ERR
"EXT3-fs: blocksize too small for journal device.\n");
......
......@@ -225,7 +225,7 @@ read_lba(struct gendisk *hd, struct block_device *bdev, u64 lba,
if (!hd || !bdev || !buffer || !count)
return 0;
blocksize = get_hardsect_size(to_kdev_t(bdev->bd_dev));
blocksize = bdev_hardsect_size(bdev);
if (!blocksize)
blocksize = 512;
......@@ -714,14 +714,11 @@ efi_partition(struct gendisk *hd, struct block_device *bdev,
{
kdev_t dev = to_kdev_t(bdev->bd_dev);
int hardblocksize = get_hardsect_size(dev);
int orig_blksize_size = BLOCK_SIZE;
int hardblocksize = bdev_hardsect_size(bdev);
int orig_blksize_size = block_size(dev);
int rc = 0;
/* Need to change the block size that the block layer uses */
if (blksize_size[major(dev)]) {
orig_blksize_size = blksize_size[major(dev)][minor(dev)];
}
if (orig_blksize_size != hardblocksize)
set_blocksize(dev, hardblocksize);
......
......@@ -125,7 +125,7 @@ ibm_partition(struct gendisk *hd, struct block_device *bdev,
return 0;
if (ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo);
return 0;
blocksize = get_hardsect_size(dev) >> 9;
blocksize = bdev_hardsect_size(bdev) >> 9;
data = read_dev_sector(bdev, inode->label_block*blocksize, &sect);
if (!data)
......
......@@ -117,7 +117,7 @@ static void extended_partition(struct gendisk *hd, struct block_device *bdev,
unsigned char *data;
unsigned long first_sector, this_sector, this_size;
int mask = (1 << hd->minor_shift) - 1;
int sector_size = get_hardsect_size(to_kdev_t(bdev->bd_dev)) / 512;
int sector_size = bdev_hardsect_size(bdev) / 512;
int loopct = 0; /* number of links followed
without finding a data partition */
int i;
......@@ -522,7 +522,7 @@ int msdos_partition(struct gendisk *hd, struct block_device *bdev,
struct partition *p;
unsigned char *data;
int mask = (1 << hd->minor_shift) - 1;
int sector_size = get_hardsect_size(to_kdev_t(bdev->bd_dev)) / 512;
int sector_size = bdev_hardsect_size(bdev) / 512;
int current_minor = first_part_minor;
int err;
......
......@@ -343,9 +343,8 @@ extern inline void blk_clear(int major)
blksize_size[major] = NULL;
}
extern inline int get_hardsect_size(kdev_t dev)
extern inline int queue_hardsect_size(request_queue_t *q)
{
request_queue_t *q = blk_get_queue(dev);
int retval = 512;
if (q && q->hardsect_size)
......@@ -354,6 +353,16 @@ extern inline int get_hardsect_size(kdev_t dev)
return retval;
}
extern inline int get_hardsect_size(kdev_t dev)
{
return queue_hardsect_size(blk_get_queue(dev));
}
extern inline int bdev_hardsect_size(struct block_device *bdev)
{
return queue_hardsect_size(blk_get_queue(to_kdev_t(bdev->bd_dev)));
}
#define blk_finished_io(nsects) do { } while (0)
#define blk_started_io(nsects) do { } while (0)
......
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