linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: add bug on back during flush nat entries
@ 2018-02-12  3:42 Yunlei He
  2018-02-13 10:04 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Yunlei He @ 2018-02-12  3:42 UTC (permalink / raw)
  To: jaegeuk, yuchao0, linux-f2fs-devel; +Cc: heyunlei

This patch add two bug on check back during flush nat entries,
nat_tree_lock will prevent race from node block allocation
in write_begin.

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

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 833b46b..ced986d 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2519,10 +2519,9 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
 	}
 
 	/* Allow dirty nats by node block allocation in write_begin */
-	if (!set->entry_cnt) {
-		radix_tree_delete(&NM_I(sbi)->nat_set_root, set->set);
-		kmem_cache_free(nat_entry_set_slab, set);
-	}
+	f2fs_bug_on(sbi, set->entry_cnt);
+	radix_tree_delete(&NM_I(sbi)->nat_set_root, set->set);
+	kmem_cache_free(nat_entry_set_slab, set);
 }
 
 /*
@@ -2566,8 +2565,8 @@ void flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	list_for_each_entry_safe(set, tmp, &sets, set_list)
 		__flush_nat_entry_set(sbi, set, cpc);
 
+	f2fs_bug_on(sbi, nm_i->dirty_nat_cnt);
 	up_write(&nm_i->nat_tree_lock);
-	/* Allow dirty nats by node block allocation in write_begin */
 }
 
 static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
-- 
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] 2+ messages in thread

* Re: [PATCH] f2fs: add bug on back during flush nat entries
  2018-02-12  3:42 [PATCH] f2fs: add bug on back during flush nat entries Yunlei He
@ 2018-02-13 10:04 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2018-02-13 10:04 UTC (permalink / raw)
  To: Yunlei He, jaegeuk, linux-f2fs-devel

On 2018/2/12 11:42, Yunlei He wrote:
> This patch add two bug on check back during flush nat entries,
> nat_tree_lock will prevent race from node block allocation
> in write_begin.
> 
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
>  fs/f2fs/node.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 833b46b..ced986d 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -2519,10 +2519,9 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
>  	}
>  
>  	/* Allow dirty nats by node block allocation in write_begin */
> -	if (!set->entry_cnt) {
> -		radix_tree_delete(&NM_I(sbi)->nat_set_root, set->set);
> -		kmem_cache_free(nat_entry_set_slab, set);

During checkpoint, We allow buffered write which needs nid allocation, if we
rollback the codes here, we may encounter the BUG_ON?

Thanks,

> -	}
> +	f2fs_bug_on(sbi, set->entry_cnt);
> +	radix_tree_delete(&NM_I(sbi)->nat_set_root, set->set);
> +	kmem_cache_free(nat_entry_set_slab, set);
>  }
>  
>  /*
> @@ -2566,8 +2565,8 @@ void flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
>  	list_for_each_entry_safe(set, tmp, &sets, set_list)
>  		__flush_nat_entry_set(sbi, set, cpc);
>  
> +	f2fs_bug_on(sbi, nm_i->dirty_nat_cnt);
>  	up_write(&nm_i->nat_tree_lock);
> -	/* Allow dirty nats by node block allocation in write_begin */
>  }
>  
>  static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
> 


------------------------------------------------------------------------------
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] 2+ messages in thread

end of thread, other threads:[~2018-02-13 10:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-12  3:42 [PATCH] f2fs: add bug on back during flush nat entries Yunlei He
2018-02-13 10:04 ` 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).