* [PATCH] md: only calculate blocksize once and use i_blocksize()
@ 2020-08-18 5:42 Xianting Tian
2020-08-20 0:33 ` Song Liu
0 siblings, 1 reply; 3+ messages in thread
From: Xianting Tian @ 2020-08-18 5:42 UTC (permalink / raw)
To: song; +Cc: linux-raid, linux-kernel, Xianting Tian
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>
---
drivers/md/md-bitmap.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 95a5f3757..0d5544868 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;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] md: only calculate blocksize once and use i_blocksize()
2020-08-18 5:42 [PATCH] md: only calculate blocksize once and use i_blocksize() Xianting Tian
@ 2020-08-20 0:33 ` Song Liu
0 siblings, 0 replies; 3+ messages in thread
From: Song Liu @ 2020-08-20 0:33 UTC (permalink / raw)
To: Xianting Tian; +Cc: linux-raid, open list
On Mon, Aug 17, 2020 at 10:49 PM Xianting Tian <tian.xianting@h3c.com> wrote:
>
> 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>
Thanks for the patch. Applied to md-next.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] md: only calculate blocksize once and use i_blocksize()
@ 2020-08-18 3:02 Xianting Tian
0 siblings, 0 replies; 3+ messages in thread
From: Xianting Tian @ 2020-08-18 3:02 UTC (permalink / raw)
To: song; +Cc: linux-raid, inux-kernel, Xianting Tian
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>
---
drivers/md/md-bitmap.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 95a5f3757..0d5544868 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;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-20 0:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 5:42 [PATCH] md: only calculate blocksize once and use i_blocksize() Xianting Tian
2020-08-20 0:33 ` Song Liu
-- strict thread matches above, loose matches on Subject: below --
2020-08-18 3:02 Xianting Tian
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.