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