linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev][PATCH] f2fs: limit nr_iovecs in bio_alloc
@ 2013-09-13 10:07 Chao Yu
  2013-09-13 11:49 ` Jin Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2013-09-13 10:07 UTC (permalink / raw)
  To: ???, linux-f2fs-devel, linux-fsdevel, linux-kernel; +Cc: 谭姝

This patch add macro MAX_BIO_BLOCKS to limit value of npages in
f2fs_bio_alloc,
it can avoid to return NULL in bio_alloc caused by npages is larger than
UIO_MAXIOV.

Signed-off-by: Yu Chao <chao2.yu@samsung.com>
 ---
 fs/f2fs/segment.c |    4 +++-
 fs/f2fs/segment.h |    3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 09af9c7..bd79bbe 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,
                                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;
                /*
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index bdd10ea..9cc95eb 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -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_BLOCK(max_hw_blocks)                                   \
+       (min((int)max_hw_blocks, UIO_MAXIOV))
 
 /* during checkpoint, bio_private is used to synchronize the last bio */
 struct bio_private {
---

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev][PATCH] f2fs: limit nr_iovecs in bio_alloc
  2013-09-13 10:07 [f2fs-dev][PATCH] f2fs: limit nr_iovecs in bio_alloc Chao Yu
@ 2013-09-13 11:49 ` Jin Xu
  2013-09-13 12:10   ` [PATCH] " Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Jin Xu @ 2013-09-13 11:49 UTC (permalink / raw)
  To: Chao Yu
  Cc: ???, linux-f2fs-devel, linux-fsdevel, linux-kernel,
	谭姝

Did this patch pass the basic build? There seems have a typo
regarding MAX_BIO_BLOCK.

--
Jin

On 13/09/2013 18:07, Chao Yu wrote:
> This patch add macro MAX_BIO_BLOCKS to limit value of npages in
> f2fs_bio_alloc,
> it can avoid to return NULL in bio_alloc caused by npages is larger than
> UIO_MAXIOV.
>
> Signed-off-by: Yu Chao <chao2.yu@samsung.com>
>  ---
>  fs/f2fs/segment.c |    4 +++-
>  fs/f2fs/segment.h |    3 +++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 09af9c7..bd79bbe 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,
>                                 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;
>                 /*
> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> index bdd10ea..9cc95eb 100644
> --- a/fs/f2fs/segment.h
> +++ b/fs/f2fs/segment.h
> @@ -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_BLOCK(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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] f2fs: limit nr_iovecs in bio_alloc
  2013-09-13 11:49 ` Jin Xu
@ 2013-09-13 12:10   ` Chao Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2013-09-13 12:10 UTC (permalink / raw)
  To: 'Jin Xu'
  Cc: linux-fsdevel, '谭姝', linux-kernel,
	linux-f2fs-devel

> -----Original Message-----
> From: Jin Xu [mailto:linuxclimber@gmail.com]
> Sent: Friday, September 13, 2013 7:49 PM
> To: Chao Yu
> Cc: ???; linux-f2fs-devel@lists.sourceforge.net;
linux-fsdevel@vger.kernel.org;
> linux-kernel@vger.kernel.org; 谭姝
> Subject: Re: [f2fs-dev][PATCH] f2fs: limit nr_iovecs in bio_alloc
> 
> Did this patch pass the basic build? There seems have a typo regarding
> MAX_BIO_BLOCK.
> 

I am so sorry about that.I miss the 'S' when merging the code by handwriting
from build path to git branch path.
I will check the patch carefully and resubmit it.

Thanks for reminding!

> --
> Jin
> 
> On 13/09/2013 18:07, Chao Yu wrote:
> > This patch add macro MAX_BIO_BLOCKS to limit value of npages in
> > f2fs_bio_alloc, it can avoid to return NULL in bio_alloc caused by
> > npages is larger than UIO_MAXIOV.
> >
> > Signed-off-by: Yu Chao <chao2.yu@samsung.com>
> >  ---
> >  fs/f2fs/segment.c |    4 +++-
> >  fs/f2fs/segment.h |    3 +++
> >  2 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index
> > 09af9c7..bd79bbe 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,
> >                                 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;
> >                 /*
> > diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index
> > bdd10ea..9cc95eb 100644
> > --- a/fs/f2fs/segment.h
> > +++ b/fs/f2fs/segment.h
> > @@ -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_BLOCK(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 majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/


------------------------------------------------------------------------------
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
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-13 12:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-13 10:07 [f2fs-dev][PATCH] f2fs: limit nr_iovecs in bio_alloc Chao Yu
2013-09-13 11:49 ` Jin Xu
2013-09-13 12:10   ` [PATCH] " Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).