Skip to content

Commit 313b825

Browse files
Xianting Tianliu-song-6
authored andcommitted
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>
1 parent 0905053 commit 313b825

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎drivers/md/md-bitmap.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,12 @@ static int read_page(struct file *file, unsigned long index,
357357
struct inode *inode = file_inode(file);
358358
struct buffer_head *bh;
359359
sector_t block, blk_cur;
360+
unsigned long blocksize = i_blocksize(inode);
360361

361362
pr_debug("read bitmap file (%dB @ %llu)\n", (int)PAGE_SIZE,
362363
(unsigned long long)index << PAGE_SHIFT);
363364

364-
bh = alloc_page_buffers(page, 1<<inode->i_blkbits, false);
365+
bh = alloc_page_buffers(page, blocksize, false);
365366
if (!bh) {
366367
ret = -ENOMEM;
367368
goto out;
@@ -383,10 +384,10 @@ static int read_page(struct file *file, unsigned long index,
383384

384385
bh->b_blocknr = block;
385386
bh->b_bdev = inode->i_sb->s_bdev;
386-
if (count < (1<<inode->i_blkbits))
387+
if (count < blocksize)
387388
count = 0;
388389
else
389-
count -= (1<<inode->i_blkbits);
390+
count -= blocksize;
390391

391392
bh->b_end_io = end_bitmap_write;
392393
bh->b_private = bitmap;

0 commit comments

Comments
 (0)