f2fs: add block address limit check to compressed file
Need to add block address range check to compressed file case and avoid calling get_data_block_bmap() for compressed file. Signed-off-by: Daeho Jeong <daehojeong@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
+9
-8
@@ -1803,10 +1803,6 @@ static int get_data_block_dio(struct inode *inode, sector_t iblock,
|
|||||||
static int get_data_block_bmap(struct inode *inode, sector_t iblock,
|
static int get_data_block_bmap(struct inode *inode, sector_t iblock,
|
||||||
struct buffer_head *bh_result, int create)
|
struct buffer_head *bh_result, int create)
|
||||||
{
|
{
|
||||||
/* Block number less than F2FS MAX BLOCKS */
|
|
||||||
if (unlikely(iblock >= F2FS_I_SB(inode)->max_file_blocks))
|
|
||||||
return -EFBIG;
|
|
||||||
|
|
||||||
return __get_data_block(inode, iblock, bh_result, create,
|
return __get_data_block(inode, iblock, bh_result, create,
|
||||||
F2FS_GET_BLOCK_BMAP, NULL,
|
F2FS_GET_BLOCK_BMAP, NULL,
|
||||||
NO_CHECK_TYPE, create);
|
NO_CHECK_TYPE, create);
|
||||||
@@ -3813,11 +3809,16 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
|
|||||||
if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
|
if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
|
||||||
filemap_write_and_wait(mapping);
|
filemap_write_and_wait(mapping);
|
||||||
|
|
||||||
if (f2fs_compressed_file(inode))
|
/* Block number less than F2FS MAX BLOCKS */
|
||||||
blknr = f2fs_bmap_compress(inode, block);
|
if (unlikely(block >= F2FS_I_SB(inode)->max_file_blocks))
|
||||||
|
goto out;
|
||||||
|
|
||||||
if (!get_data_block_bmap(inode, block, &tmp, 0))
|
if (f2fs_compressed_file(inode)) {
|
||||||
blknr = tmp.b_blocknr;
|
blknr = f2fs_bmap_compress(inode, block);
|
||||||
|
} else {
|
||||||
|
if (!get_data_block_bmap(inode, block, &tmp, 0))
|
||||||
|
blknr = tmp.b_blocknr;
|
||||||
|
}
|
||||||
out:
|
out:
|
||||||
trace_f2fs_bmap(inode, block, blknr);
|
trace_f2fs_bmap(inode, block, blknr);
|
||||||
return blknr;
|
return blknr;
|
||||||
|
|||||||
Reference in New Issue
Block a user