f2fs: avoid allocating failure in bio_alloc
Subsystems (2)
PATCH 1/1 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.
--- fs/f2fs/segment.c | 4 +++- fs/f2fs/segment.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
@@ -657,6 +657,7 @@ static void submit_write_page(struct f2fs_sb_info *sbi,
struct page *page,
block_t blk_addr, enum page_type type)
{
struct block_device *bdev = sbi->sb->s_bdev;
+ int bio_blocks;
verify_block_addr(sbi, blk_addr);
@@ -676,7 +677,8 @@ retry:
goto retry;
}
- sbi->bio[type] = f2fs_bio_alloc(bdev, max_hw_blocks(sbi));
+ bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+ sbi->bio[type] = f2fs_bio_alloc(bdev, bio_blocks);
sbi->bio[type]->bi_sector = SECTOR_FROM_BLOCK(sbi,blk_addr);
sbi->bio[type]->bi_private = priv;
/*
fs/f2fs/segment.h +2 -0
@@ -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 {
---
------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/22/13.
http://pubads.g.doubleclick.net/gampad/clk?id=64545871&iu=/4140/ostg.clktrk
Quoted 5 lines · Chao Yu
This patch add macro
MAX_BIO_BLOCKSto limit value of npages inf2fs_bio_alloc, it can avoid allocating failure inbio_alloccaused by npages is larger thanBIO_MAX_PAGES.Signed-off-by Yu Chao <[email protected]>
Quoted 45 lines
--- fs/f2fs/segment.c | 4 +++- fs/f2fs/segment.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/f2fs/segment.c +3
-1@@ -657,6 +657,7 @@ static void submit_write_page(struct f2fs_sb_info *sbi,struct page *page, block_t blk_addr, enum page_type type) { struct block_device *bdev = sbi->sb->s_bdev; +int bio_blocks;verify_block_addr (sbi, blk_addr);@@ -676,7 +677,8 @@ retry: goto retry; } - sbi->bio[type] =f2fs_bio_alloc (bdev,max_hw_blocks (sbi)); + bio_blocks =MAX_BIO_BLOCKS (max_hw_blocks (sbi)); + sbi->bio[type] =f2fs_bio_alloc (bdev, bio_blocks); sbi->bio[type]->bi_sector =SECTOR_FROM_BLOCK (sbi, blk_addr); sbi->bio[type]->bi_private = priv;fs/f2fs/segment.c +0
-0/* fs/f2fs/segment.h +2
-2@@ -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 { --- --
Quoted 5 lines
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk