Commit 313b825f authored by Xianting Tian's avatar Xianting Tian Committed by Song Liu

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: default avatarXianting Tian <tian.xianting@h3c.com>
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
parent 0905053b
...@@ -357,11 +357,12 @@ static int read_page(struct file *file, unsigned long index, ...@@ -357,11 +357,12 @@ static int read_page(struct file *file, unsigned long index,
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
struct buffer_head *bh; struct buffer_head *bh;
sector_t block, blk_cur; sector_t block, blk_cur;
unsigned long blocksize = i_blocksize(inode);
pr_debug("read bitmap file (%dB @ %llu)\n", (int)PAGE_SIZE, pr_debug("read bitmap file (%dB @ %llu)\n", (int)PAGE_SIZE,
(unsigned long long)index << PAGE_SHIFT); (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) { if (!bh) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
...@@ -383,10 +384,10 @@ static int read_page(struct file *file, unsigned long index, ...@@ -383,10 +384,10 @@ static int read_page(struct file *file, unsigned long index,
bh->b_blocknr = block; bh->b_blocknr = block;
bh->b_bdev = inode->i_sb->s_bdev; bh->b_bdev = inode->i_sb->s_bdev;
if (count < (1<<inode->i_blkbits)) if (count < blocksize)
count = 0; count = 0;
else else
count -= (1<<inode->i_blkbits); count -= blocksize;
bh->b_end_io = end_bitmap_write; bh->b_end_io = end_bitmap_write;
bh->b_private = bitmap; bh->b_private = bitmap;
......
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