From cc7b1bb173676621b092b61d22d8d12b05efb5e8 Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Sun, 22 Sep 2013 15:50:50 +0800 Subject: f2fs: avoid allocating failure in bio_alloc This patch add macro MAX_BIO_BLOCKS to limit value of npages in f2fs_bio_alloc, it can avoid allocating failure in bio_alloc caused by npages is larger than BIO_MAX_PAGES. Signed-off-by: Yu Chao Reviewed-by: Gu Zheng Signed-off-by: Jaegeuk Kim --- fs/f2fs/segment.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fs/f2fs/segment.h') diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index bdd10ea..7f94d78 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -90,6 +90,8 @@ (blk_addr << ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE)) #define SECTOR_TO_BLOCK(sbi, sectors) \ (sectors >> ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE)) +#define MAX_BIO_BLOCKS(max_hw_blocks) \ + (min((int)max_hw_blocks, BIO_MAX_PAGES)) /* during checkpoint, bio_private is used to synchronize the last bio */ struct bio_private { -- cgit v1.1