f2fs: avoid allocating failure in bio_alloc
Subsystems (2)
PATCH RESEND 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 UIO_MAXIOV.
---
fs/f2fs/segment.c | 4 +++- fs/f2fs/segment.h | 3 +++ 2 files changed, 6 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 +3 -0
@@ -9,6 +9,7 @@* published by the Free Software Foundation. */ #include <linux/blkdev.h> +#include <linux/uio.h> /* constant macro */ #define NULL_SEGNO ((unsigned int)(~0))
@@ -90,6 +91,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, UIO_MAXIOV))/* during checkpoint, bio_private is used to synchronize the last bio */ struct bio_private {
---
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
Hi Chao,
Quoted 4 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 thanUIO_MAXIOV.
As I know bio_alloc is based of *fs_bio_set* pool, without the limitation of UIO_MAXIOV, am I missing something?
Thanks,
Gu
Quoted 60 lines
Signed-off-by Yu Chao <[email protected]>---
fs/f2fs/segment.c | 4 +++- fs/f2fs/segment.h | 3 +++ 2 files changed, 6 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.h +3
-2@@ -9,6 +9,7 @@* published by the Free Software Foundation. */ #include <linux/blkdev.h> +#include <linux/uio.h> /* constant macro */ #define NULL_SEGNO ((unsigned int)(~0))@@ -90,6 +91,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, UIO_MAXIOV))/* during checkpoint, bio_private is used to synchronize the last bio */ struct bio_private { --- --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/
Hi Gu
Quoted 7 lines
-----Original Message-----
From: Gu Zheng [mailto:[email protected]]
Sent: Monday, September 16, 2013 10:09 AM
To: Chao Yu
Cc: Kim Jaegeuk; [email protected]; [email protected]; [email protected]; 谭姝
Subject: Re: [f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure in
bio_alloc
Quoted 10 lines
Hi Chao,
Quoted 3 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 thanUIO_MAXIOV.As I know
bio_allocis based of *fs_bio_set* pool, without the limitation
of
Quoted 1 line
UIO_MAXIOV, am I missing something?
Here is the code in bio.c, fs_bio_set is as the actual parameter pass to bs without being inited.
So it may have opportunity to return NULL in this function.
---Bio.c
struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
{
......
if (!bs) {
if (nr_iovecs > UIO_MAXIOV)
return NULL;---
I did the abnormal test: modify the max_sectors_kb in /sys/block/sdx/queue to 32767 for a disk with f2fs format,
and I got a segfualt in f2fs_bio_alloc after the img mounted. Is there anyting I missed?
Quoted 23 lines
Thanks,
GuQuoted 12 lines
Signed-off-by Yu Chao <[email protected]>---
fs/f2fs/segment.c | 4 +++- fs/f2fs/segment.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)fs/f2fs/segment.c index renamed from fs/f2fs/segment.c +0
-009af9c7..bd79bbe 100644
fs/f2fs/segment.c static void submit_write_page(struct f2fs_sb_info · line 658
Quoted 2 lines
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_typetype)
Quoted 4 lines
fs/f2fs/segment.c +1
-0{struct block_device *bdev = sbi->sb->s_bdev; +int bio_blocks;
Quoted 7 lines
fs/f2fs/segment.c retry: · line 679
Quoted 7 lines
fs/f2fs/segment.c +0
-1verify_block_addr (sbi, blk_addr);@@ -676,7 +677,8 @@ retry: goto retry; } - sbi->bio[type] = f2fs_bio_alloc(bdev,
max_hw_blocks(sbi));
Quoted 22 lines
Quoted 19 lines
fs/f2fs/segment.c +2
-0+ 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 index renamed from fs/f2fs/segment.h +0
-0bdd10ea..6352af1 100644
fs/f2fs/segment.h +1
-0@@ -9,6 +9,7 @@* published by the Free Software Foundation. */ #include <linux/blkdev.h> +#include <linux/uio.h> /* constant macro */ #define NULL_SEGNO ((unsigned int)(~0))fs/f2fs/segment.h line 92
Quoted 2 lines
fs/f2fs/segment.h +0
-0@@ -90,6 +91,8 @@ (blk_addr << ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE))#define SECTOR_TO_BLOCK (sbi, sectors)\
Quoted 15 lines
fs/f2fs/segment.h line 94
Quoted 2 lines
fs/f2fs/segment.h +1
-0(sectors >> ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE)) +#define MAX_BIO_BLOCKS (max_hw_blocks)\
Quoted 12 lines
fs/f2fs/segment.h +1
-2+ (min ((int )max_hw_blocks,UIO_MAXIOV ))/* during checkpoint, bio_private is used to synchronize the last bio */ struct bio_private { --- --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
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi Chao,
Quoted 19 lines · Chao Yu
Hi Gu
Quoted 7 lines
-----Original Message-----
From: Gu Zheng [mailto:[email protected]]
Sent: Monday, September 16, 2013 10:09 AM
To: Chao Yu
Cc: Kim Jaegeuk; [email protected]; [email protected]; [email protected]; 谭姝
Subject: Re: [f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure in
bio_allocQuoted 9 lines
Hi Chao,
Quoted 3 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 thanUIO_MAXIOV.
Quoted 6 lines
Quoted 1 line
As I know
bio_allocis based of *fs_bio_set* pool, without the limitationof
Quoted 1 line
UIO_MAXIOV, am I missing something?Here is the code in
bio.c,fs_bio_setis as the actual parameter pass to bs without being inited.
fs_bio_set was initiated early in the bio subsystem init.
Quoted 1 line
So it may have opportunity to return NULL in this function.
It may be, but may not be the thread you mentioned below.
Quoted 6 lines
---
Bio.c
struct bio *bio_alloc_bioset(gfp_tgfp_mask, intnr_iovecs, structbio_set*bs)
{
......
Quoted 8 lines
if (!bs) { if (nr_iovecs > UIO_MAXIOV) return NULL;---
I did the abnormal test: modify themax_sectors_kbin/sys/block/sdx/queueto 32767 for a disk with f2fs format,
and I got a segfualt inf2fs_bio_allocafter the img mounted. Is there anyting I missed?
Hmm, this change will also trigger bvec_alloc failed, did you add some traces to debug this?
Regards,
Gu
Quoted 71 lines
Quoted 24 lines
Thanks,
GuQuoted 12 lines
Signed-off-by Yu Chao <[email protected]>---
fs/f2fs/segment.c | 4 +++- fs/f2fs/segment.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)fs/f2fs/segment.c index renamed from fs/f2fs/segment.c +0
-009af9c7..bd79bbe 100644
fs/f2fs/segment.c static void submit_write_page(struct f2fs_sb_info · line 658
Quoted 2 lines
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_typetype)
Quoted 4 lines
fs/f2fs/segment.c +1
-0{struct block_device *bdev = sbi->sb->s_bdev; +int bio_blocks;Quoted 7 lines
fs/f2fs/segment.c retry: · line 679
Quoted 7 lines
fs/f2fs/segment.c +0
-1verify_block_addr (sbi, blk_addr);@@ -676,7 +677,8 @@ retry: goto retry; } - sbi->bio[type] = f2fs_bio_alloc(bdev,
max_hw_blocks(sbi));Quoted 22 lines
Quoted 19 lines
fs/f2fs/segment.c +2
-0+ 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 index renamed from fs/f2fs/segment.h +0
-0bdd10ea..6352af1 100644
fs/f2fs/segment.h +1
-0@@ -9,6 +9,7 @@* published by the Free Software Foundation. */ #include <linux/blkdev.h> +#include <linux/uio.h> /* constant macro */ #define NULL_SEGNO ((unsigned int)(~0))fs/f2fs/segment.h line 92
Quoted 2 lines
fs/f2fs/segment.h +0
-0@@ -90,6 +91,8 @@ (blk_addr << ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE))#define SECTOR_TO_BLOCK (sbi, sectors)\
Quoted 15 lines
fs/f2fs/segment.h line 94
Quoted 2 lines
fs/f2fs/segment.h +1
-0(sectors >> ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE)) +#define MAX_BIO_BLOCKS (max_hw_blocks)\
Quoted 12 lines
fs/f2fs/segment.h +1
-2+ (min ((int )max_hw_blocks,UIO_MAXIOV ))/* during checkpoint, bio_private is used to synchronize the last bio */ struct bio_private { --- --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/
Quoted 6 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/
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Gu
Quoted 7 lines
-----Original Message-----
From: Gu Zheng [mailto:[email protected]]
Sent: Monday, September 16, 2013 12:40 PM
To: Chao Yu
Cc: 'Kim Jaegeuk'; [email protected]; [email protected]; [email protected]; '谭姝'
Subject: Re: [f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure in
bio_alloc
Quoted 55 lines
Hi Chao,
Quoted 20 lines · Chao Yu
Hi Gu
Quoted 8 lines
-----Original Message-----
From: Gu Zheng [mailto:[email protected]]
Sent: Monday, September 16, 2013 10:09 AM
To: Chao Yu
Cc: Kim Jaegeuk; [email protected]; [email protected]; [email protected]; 谭姝
Subject: Re: [f2fs-dev][PATCH RESEND] f2fs: avoid allocating failure in
bio_allocQuoted 9 lines
Hi Chao,
Quoted 3 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 thanUIO_MAXIOV.Quoted 7 lines
Quoted 2 lines
As I know
bio_allocis based of *fs_bio_set* pool, without the limitationof
Quoted 1 line
UIO_MAXIOV, am I missing something?Here is the code in
bio.c,fs_bio_setis as the actual parameter pass to bs without being inited.
fs_bio_setwas initiated early in the bio subsystem init.Quoted 1 line
So it may have opportunity to return NULL in this function.
It may be, but may not be the thread you mentioned below.
Quoted 7 lines
---
Bio.c
struct bio *bio_alloc_bioset(gfp_tgfp_mask, intnr_iovecs, structbio_set
*bs)
{
......Quoted 8 lines
if (!bs) { if (nr_iovecs > UIO_MAXIOV) return NULL;---
I did the abnormal test: modify themax_sectors_kbin/sys/block/sdx/queueto 32767 for a disk with f2fs format, and I got a segfualt inf2fs_bio_allocafter the img mounted.
Is there anyting I missed?
Quoted 1 line
Hmm, this change will also trigger
bvec_allocfailed, did you add some
traces to
Quoted 1 line
debug this?
I reviewed the code in bio_alloc, and then trace the process of bio_alloc for verification.
It indicate that bvec_alloc() will fail on the condition that nr_iovecs is greater than BIO_MAX_PAGES.
The patch should be updated for that.
I am sorry about the mistake in this patch, and thanks for the reviewing and reminding.
Quoted 84 lines
Regards,
GuQuoted 24 lines
Quoted 24 lines
Thanks,
GuQuoted 12 lines
Signed-off-by Yu Chao <[email protected]>---
fs/f2fs/segment.c | 4 +++- fs/f2fs/segment.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)fs/f2fs/segment.c index renamed from fs/f2fs/segment.c +0
-009af9c7..bd79bbe 100644
fs/f2fs/segment.c static void submit_write_page(struct · line 658
Quoted 2 lines
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_typetype)
Quoted 4 lines
fs/f2fs/segment.c +1
-0{struct block_device *bdev = sbi->sb->s_bdev; +int bio_blocks;Quoted 11 lines
Quoted 7 lines
fs/f2fs/segment.c retry: · line 679
Quoted 7 lines
fs/f2fs/segment.c +0
-1verify_block_addr (sbi, blk_addr);@@ -676,7 +677,8 @@ retry: goto retry; } - sbi->bio[type] = f2fs_bio_alloc(bdev,
max_hw_blocks(sbi));Quoted 3 lines
Quoted 3 lines
fs/f2fs/segment.c +2
-0+ 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,
Quoted 36 lines
Quoted 19 lines
Quoted 16 lines
fs/f2fs/segment.c +0
-0blk_addr); sbi->bio[type]->bi_private = priv;/*fs/f2fs/segment.h index renamed from fs/f2fs/segment.h +0
-0bdd10ea..6352af1 100644
fs/f2fs/segment.h +1
-0@@ -9,6 +9,7 @@* published by the Free Software Foundation. */ #include <linux/blkdev.h> +#include <linux/uio.h> /* constant macro */ #define NULL_SEGNO ((unsigned int)(~0))fs/f2fs/segment.h line 92
Quoted 2 lines
fs/f2fs/segment.h +0
-0@@ -90,6 +91,8 @@ (blk_addr << ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE))#define SECTOR_TO_BLOCK (sbi, sectors)\
Quoted 15 lines
fs/f2fs/segment.h line 94
Quoted 2 lines
fs/f2fs/segment.h +1
-0(sectors >> ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE)) +#define MAX_BIO_BLOCKS (max_hw_blocks)\
Quoted 12 lines
fs/f2fs/segment.h +1
-2+ (min ((int )max_hw_blocks,UIO_MAXIOV ))/* during checkpoint, bio_private is used to synchronize the last bio */ struct bio_private { --- --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/Quoted 6 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/
Quoted 1 line
=
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html