Skip to contentSkip to conversation

f2fs: remove unnecessary judgments in __insert_free_nid()

PATCH In review Liu Song via Linux-f2fs-devel 2 participants 3 messages Jun 26, 2020 – Jun 28, 2020 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: remove unnecessary judgments in __insert_free_nid()

From: Liu Song <[email protected]>

The value of state must be equal to FREE_NID, so the if condition judgment can be removed.

---
 fs/f2fs/node.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/node.c +1 -2
index 03e24df1c84f..0adeb20f19c9 100644
@@ -2118,8 +2118,7 @@ static int __insert_free_nid(struct f2fs_sb_info *sbi,
 
 	f2fs_bug_on(sbi, state != i->state);
 	nm_i->nid_cnt[state]++;
-	if (state == FREE_NID)
-		list_add_tail(&i->list, &nm_i->free_nid_list);
+	list_add_tail(&i->list, &nm_i->free_nid_list);
 	return 0;
 }
 
Signature · 8 lines
2.20.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 15 lines · On 2020/6/26 22:39, Liu Song via Linux-f2fs-devel wrote:

From: Liu Song <[email protected]>

The value of state must be equal to FREE_NID, so the if condition judgment can be removed.

---
 fs/f2fs/node.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/node.c +0 -0
index 03e24df1c84f..0adeb20f19c9 100644

fs/f2fs/node.c static int __insert_free_nid(struct f2fs_sb_info *sbi, · line 2121

Quoted 6 lines
fs/f2fs/node.c +1 -2
@@ -2118,8 +2118,7 @@ static int __insert_free_nid(struct f2fs_sb_info *sbi,
 
 	f2fs_bug_on(sbi, state != i->state);
 	nm_i->nid_cnt[state]++;
-	if (state == FREE_NID)
-		list_add_tail(&i->list, &nm_i->free_nid_list);
+	list_add_tail(&i->list, &nm_i->free_nid_list);

In previous design, @state allow accepting both FREE_NID and PREALLOC_NID, If you remove that condition, it's not correct to add free nid entry into free_nid_list when passing PREALLOC_NID in @state, now, we only pass @state with FREE_NID, so it's better to remove that parameter directly.

Thanks,

Quoted 4 lines
fs/f2fs/node.c +0 -0
 	return 0;
 }
 
#2 lore raw
Quoted 28 lines · On 2020/6/26 22:39, Liu Song via Linux-f2fs-devel wrote:
Quoted 15 lines

From: Liu Song <[email protected]>

The value of state must be equal to FREE_NID, so the if condition judgment can be removed.

---
 fs/f2fs/node.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/node.c +0 -0
index 03e24df1c84f..0adeb20f19c9 100644

fs/f2fs/node.c static int __insert_free_nid(struct f2fs_sb_info *sbi, · line 2121

Quoted 6 lines
fs/f2fs/node.c +1 -2
@@ -2118,8 +2118,7 @@ static int __insert_free_nid(struct f2fs_sb_info *sbi,
 
  f2fs_bug_on(sbi, state != i->state);
  nm_i->nid_cnt[state]++;
- if (state == FREE_NID)
-  list_add_tail(&i->list, &nm_i->free_nid_list);
+ list_add_tail(&i->list, &nm_i->free_nid_list);

In previous design, @state allow accepting both FREE_NID and PREALLOC_NID, If you remove that condition, it's not correct to add free nid entry into free_nid_list when passing PREALLOC_NID in @state, now, we only pass @state with FREE_NID, so it's better to remove that parameter directly.

Quoted 6 lines

Thanks,

Quoted 4 lines
fs/f2fs/node.c +0 -0
  return 0;
 }
 

Thanks for your suggestions, I will resubmit a patch as suggested.

Thanks

Liu Song

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel