diff options
author | Xianting Tian <tian.xianting@h3c.com> | 2020-08-18 08:42:06 +0300 |
---|---|---|
committer | Song Liu <songliubraving@fb.com> | 2020-09-25 02:44:44 +0300 |
commit | 313b825fa218bef78419d7b4092c1f4af222335d (patch) | |
tree | b7de3d05d4a9a14a9e779667beb79d4cf8911c60 /drivers | |
parent | 0905053bdb5b7ba77ad0c2e5cfc4787c1db3d4f1 (diff) | |
download | linux-313b825fa218bef78419d7b4092c1f4af222335d.tar.xz |
md: only calculate blocksize once and use i_blocksize()
We alreday has the interface i_blocksize(), which can be used
to get blocksize, so use it.
Only calculate blocksize once and use it within read_page().
Signed-off-by: Xianting Tian <tian.xianting@h3c.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/md-bitmap.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index b10c51988c8e..55b757a223a4 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -357,11 +357,12 @@ static int read_page(struct file *file, unsigned long index, struct inode *inode = file_inode(file); struct buffer_head *bh; sector_t block, blk_cur; + unsigned long blocksize = i_blocksize(inode); pr_debug("read bitmap file (%dB @ %llu)\n", (int)PAGE_SIZE, (unsigned long long)index << PAGE_SHIFT); - bh = alloc_page_buffers(page, 1<<inode->i_blkbits, false); + bh = alloc_page_buffers(page, blocksize, false); if (!bh) { ret = -ENOMEM; goto out; @@ -383,10 +384,10 @@ static int read_page(struct file *file, unsigned long index, bh->b_blocknr = block; bh->b_bdev = inode->i_sb->s_bdev; - if (count < (1<<inode->i_blkbits)) + if (count < blocksize) count = 0; else - count -= (1<<inode->i_blkbits); + count -= blocksize; bh->b_end_io = end_bitmap_write; bh->b_private = bitmap; |