linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: no need to read nat block if nat_block_bitmap is set
@ 2017-11-17  8:13 Yunlei He
  2017-11-17  9:30 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Yunlei He @ 2017-11-17  8:13 UTC (permalink / raw)
  To: jaegeuk, yuchao0, linux-f2fs-devel; +Cc: ning.jia, heyunlei

No need to read nat block if nat_block_bitmap is set.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
 fs/f2fs/node.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index fe1fc66..104b44c 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1949,9 +1949,6 @@ static void scan_nat_page(struct f2fs_sb_info *sbi,
 	unsigned int nat_ofs = NAT_BLOCK_OFFSET(start_nid);
 	int i;
 
-	if (test_bit_le(nat_ofs, nm_i->nat_block_bitmap))
-		return;
-
 	__set_bit_le(nat_ofs, nm_i->nat_block_bitmap);
 
 	i = start_nid % NAT_ENTRY_PER_BLOCK;
@@ -2056,11 +2053,16 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
 	down_read(&nm_i->nat_tree_lock);
 
 	while (1) {
-		struct page *page = get_current_nat_page(sbi, nid);
+		struct page *page;
 
+		if (test_bit_le(NAT_BLOCK_OFFSET(nid),
+					nm_i->nat_block_bitmap)) {
+			goto skip;
+		}
+		page = get_current_nat_page(sbi, nid);
 		scan_nat_page(sbi, page, nid);
 		f2fs_put_page(page, 1);
-
+skip:
 		nid += (NAT_ENTRY_PER_BLOCK - (nid % NAT_ENTRY_PER_BLOCK));
 		if (unlikely(nid >= nm_i->max_nid))
 			nid = 0;
-- 
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH] f2fs: no need to read nat block if nat_block_bitmap is set
  2017-11-17  8:13 [PATCH] f2fs: no need to read nat block if nat_block_bitmap is set Yunlei He
@ 2017-11-17  9:30 ` Chao Yu
  2017-11-27  4:27   ` Jaegeuk Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2017-11-17  9:30 UTC (permalink / raw)
  To: Yunlei He, jaegeuk, linux-f2fs-devel; +Cc: ning.jia

On 2017/11/17 16:13, Yunlei He wrote:
> No need to read nat block if nat_block_bitmap is set.
> 
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
>  fs/f2fs/node.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index fe1fc66..104b44c 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1949,9 +1949,6 @@ static void scan_nat_page(struct f2fs_sb_info *sbi,
>  	unsigned int nat_ofs = NAT_BLOCK_OFFSET(start_nid);
>  	int i;
>  
> -	if (test_bit_le(nat_ofs, nm_i->nat_block_bitmap))
> -		return;
> -
>  	__set_bit_le(nat_ofs, nm_i->nat_block_bitmap);
>  
>  	i = start_nid % NAT_ENTRY_PER_BLOCK;
> @@ -2056,11 +2053,16 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
>  	down_read(&nm_i->nat_tree_lock);
>  
>  	while (1) {
> -		struct page *page = get_current_nat_page(sbi, nid);
> +		struct page *page;
>  
> +		if (test_bit_le(NAT_BLOCK_OFFSET(nid),
> +					nm_i->nat_block_bitmap)) {
> +			goto skip;
> +		}

Coding style, we don't need brace for a single line, other party looks good
to me:

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> +		page = get_current_nat_page(sbi, nid);
>  		scan_nat_page(sbi, page, nid);
>  		f2fs_put_page(page, 1);
> -
> +skip:
>  		nid += (NAT_ENTRY_PER_BLOCK - (nid % NAT_ENTRY_PER_BLOCK));
>  		if (unlikely(nid >= nm_i->max_nid))
>  			nid = 0;
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH] f2fs: no need to read nat block if nat_block_bitmap is set
  2017-11-17  9:30 ` Chao Yu
@ 2017-11-27  4:27   ` Jaegeuk Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2017-11-27  4:27 UTC (permalink / raw)
  To: Chao Yu; +Cc: ning.jia, Yunlei He, linux-f2fs-devel

On 11/17, Chao Yu wrote:
> On 2017/11/17 16:13, Yunlei He wrote:
> > No need to read nat block if nat_block_bitmap is set.
> > 
> > Signed-off-by: Yunlei He <heyunlei@huawei.com>
> > ---
> >  fs/f2fs/node.c | 12 +++++++-----
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> > 
> > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > index fe1fc66..104b44c 100644
> > --- a/fs/f2fs/node.c
> > +++ b/fs/f2fs/node.c
> > @@ -1949,9 +1949,6 @@ static void scan_nat_page(struct f2fs_sb_info *sbi,
> >  	unsigned int nat_ofs = NAT_BLOCK_OFFSET(start_nid);
> >  	int i;
> >  
> > -	if (test_bit_le(nat_ofs, nm_i->nat_block_bitmap))
> > -		return;
> > -
> >  	__set_bit_le(nat_ofs, nm_i->nat_block_bitmap);
> >  
> >  	i = start_nid % NAT_ENTRY_PER_BLOCK;
> > @@ -2056,11 +2053,16 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
> >  	down_read(&nm_i->nat_tree_lock);
> >  
> >  	while (1) {
> > -		struct page *page = get_current_nat_page(sbi, nid);
> > +		struct page *page;
> >  
> > +		if (test_bit_le(NAT_BLOCK_OFFSET(nid),
> > +					nm_i->nat_block_bitmap)) {
> > +			goto skip;
> > +		}

I modified this to avoid goto statement like:
		if (!test_bit_le()) {
			/* do something */
		}

Thanks,

> Coding style, we don't need brace for a single line, other party looks good
> to me:
> 
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> 
> Thanks,
> 
> > +		page = get_current_nat_page(sbi, nid);
> >  		scan_nat_page(sbi, page, nid);
> >  		f2fs_put_page(page, 1);
> > -
> > +skip:
> >  		nid += (NAT_ENTRY_PER_BLOCK - (nid % NAT_ENTRY_PER_BLOCK));
> >  		if (unlikely(nid >= nm_i->max_nid))
> >  			nid = 0;
> > 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

end of thread, other threads:[~2017-11-27  4:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-17  8:13 [PATCH] f2fs: no need to read nat block if nat_block_bitmap is set Yunlei He
2017-11-17  9:30 ` Chao Yu
2017-11-27  4:27   ` Jaegeuk Kim

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).