aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2013-09-22 03:50:50 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-09-24 04:45:48 -0400
commitcc7b1bb173676621b092b61d22d8d12b05efb5e8 (patch)
tree440612ad80fa325aa3a5b316b5f25d87ff6a0f81 /fs/f2fs
parenta57e564d14d9d123b2dd4ff1c933da0d900e0b1d (diff)
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 <chao2.yu@samsung.com> Reviewed-by: Gu Zheng <guz.fnst@cn.fujitsu.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/segment.c4
-rw-r--r--fs/f2fs/segment.h2
2 files changed, 5 insertions, 1 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 09af9c7b0f52..bd79bbeceb1d 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -657,6 +657,7 @@ static void submit_write_page(struct f2fs_sb_info *sbi, struct page *page,
657 block_t blk_addr, enum page_type type) 657 block_t blk_addr, enum page_type type)
658{ 658{
659 struct block_device *bdev = sbi->sb->s_bdev; 659 struct block_device *bdev = sbi->sb->s_bdev;
660 int bio_blocks;
660 661
661 verify_block_addr(sbi, blk_addr); 662 verify_block_addr(sbi, blk_addr);
662 663
@@ -676,7 +677,8 @@ retry:
676 goto retry; 677 goto retry;
677 } 678 }
678 679
679 sbi->bio[type] = f2fs_bio_alloc(bdev, max_hw_blocks(sbi)); 680 bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
681 sbi->bio[type] = f2fs_bio_alloc(bdev, bio_blocks);
680 sbi->bio[type]->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr); 682 sbi->bio[type]->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
681 sbi->bio[type]->bi_private = priv; 683 sbi->bio[type]->bi_private = priv;
682 /* 684 /*
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index bdd10eab8c40..7f94d78cda3d 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -90,6 +90,8 @@
90 (blk_addr << ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE)) 90 (blk_addr << ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE))
91#define SECTOR_TO_BLOCK(sbi, sectors) \ 91#define SECTOR_TO_BLOCK(sbi, sectors) \
92 (sectors >> ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE)) 92 (sectors >> ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE))
93#define MAX_BIO_BLOCKS(max_hw_blocks) \
94 (min((int)max_hw_blocks, BIO_MAX_PAGES))
93 95
94/* during checkpoint, bio_private is used to synchronize the last bio */ 96/* during checkpoint, bio_private is used to synchronize the last bio */
95struct bio_private { 97struct bio_private {