提交 1b3e27a9 编写于 作者: C Chao Yu 提交者: Jaegeuk Kim

f2fs: limit b_size of mapped bh in f2fs_map_bh

Map bh over max size which caller defined is not needed, limit it in
f2fs_map_bh.
Signed-off-by: NChao Yu <chao2.yu@samsung.com>
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
上级 30c62fdb
...@@ -255,15 +255,13 @@ static void f2fs_map_bh(struct super_block *sb, pgoff_t pgofs, ...@@ -255,15 +255,13 @@ static void f2fs_map_bh(struct super_block *sb, pgoff_t pgofs,
struct extent_info *ei, struct buffer_head *bh_result) struct extent_info *ei, struct buffer_head *bh_result)
{ {
unsigned int blkbits = sb->s_blocksize_bits; unsigned int blkbits = sb->s_blocksize_bits;
size_t count; size_t max_size = bh_result->b_size;
size_t mapped_size;
clear_buffer_new(bh_result); clear_buffer_new(bh_result);
map_bh(bh_result, sb, ei->blk + pgofs - ei->fofs); map_bh(bh_result, sb, ei->blk + pgofs - ei->fofs);
count = ei->fofs + ei->len - pgofs; mapped_size = (ei->fofs + ei->len - pgofs) << blkbits;
if (count < (UINT_MAX >> blkbits)) bh_result->b_size = min(max_size, mapped_size);
bh_result->b_size = (count << blkbits);
else
bh_result->b_size = UINT_MAX;
} }
static bool lookup_extent_info(struct inode *inode, pgoff_t pgofs, static bool lookup_extent_info(struct inode *inode, pgoff_t pgofs,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册