[2/7] block: Convert to bdev_logical_block_mask()
Commit Message
Use bdev_logical_block_mask() to simplify code.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
block/bio.c | 2 +-
block/fops.c | 4 ++--
block/ioctl.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
@@ -1281,7 +1281,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
nr_pages = DIV_ROUND_UP(offset + size, PAGE_SIZE);
- trim = size & (bdev_logical_block_size(bio->bi_bdev) - 1);
+ trim = size & bdev_logical_block_mask(bio->bi_bdev);
iov_iter_revert(iter, trim);
size -= trim;
@@ -45,7 +45,7 @@ static blk_opf_t dio_bio_write_op(struct kiocb *iocb)
static bool blkdev_dio_unaligned(struct block_device *bdev, loff_t pos,
struct iov_iter *iter)
{
- return pos & (bdev_logical_block_size(bdev) - 1) ||
+ return pos & bdev_logical_block_mask(bdev) ||
!bdev_iter_is_aligned(bdev, iter);
}
@@ -653,7 +653,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
/*
* Don't allow IO that isn't aligned to logical block size.
*/
- if ((start | len) & (bdev_logical_block_size(bdev) - 1))
+ if ((start | len) & bdev_logical_block_mask(bdev))
return -EINVAL;
filemap_invalidate_lock(inode->i_mapping);
@@ -39,7 +39,7 @@ static int blkpg_do_ioctl(struct block_device *bdev,
switch (op) {
case BLKPG_ADD_PARTITION:
/* check if partition is aligned to blocksize */
- if (p.start & (bdev_logical_block_size(bdev) - 1))
+ if (p.start & bdev_logical_block_mask(bdev))
return -EINVAL;
return bdev_add_partition(disk, p.pno, start, length);
case BLKPG_RESIZE_PARTITION: