Skip to contentSkip to conversation

f2fs: remove unused check on nid

PATCH In review Wang Xiaojun 2 participants 2 messages Sep 21, 2020 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: remove unused check on nid

The case where nid is 0 will be checked in f2fs_check_nid_range. Remove the unused check.

---
 fs/f2fs/node.c | 8 --------
 1 file changed, 8 deletions(-)
fs/f2fs/node.c +0 -8
index cb1b5b61a1da..c61d5b52e29e 100644
@@ -1319,8 +1319,6 @@ void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
 	struct page *apage;
 	int err;
 
-	if (!nid)
-		return;
 	if (f2fs_check_nid_range(sbi, nid))
 		return;
 
@@ -1342,8 +1340,6 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 	struct page *page;
 	int err;
 
-	if (!nid)
-		return ERR_PTR(-ENOENT);
 	if (f2fs_check_nid_range(sbi, nid))
 		return ERR_PTR(-EINVAL);
 repeat:
@@ -2193,10 +2189,6 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
 	int err = -EINVAL;
 	bool ret = false;
 
-	/* 0 nid should not be used */
-	if (unlikely(nid == 0))
-		return false;
-
 	if (unlikely(f2fs_check_nid_range(sbi, nid)))
 		return false;
 
Signature · 8 lines
2.25.1



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

Hi Xiaojun,

Quoted 13 lines · Wang Xiaojun

The case where nid is 0 will be checked in f2fs_check_nid_range. Remove the unused check.

---
  fs/f2fs/node.c | 8 --------
  1 file changed, 8 deletions(-)
fs/f2fs/node.c +0 -0
index cb1b5b61a1da..c61d5b52e29e 100644

fs/f2fs/node.c void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid) · line 1323

Quoted 7 lines
fs/f2fs/node.c +0 -2
@@ -1319,8 +1319,6 @@ void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
  	struct page *apage;
  	int err;
 
-	if (!nid)
-		return;
  	if (f2fs_check_nid_range(sbi, nid))
  		return;

They have different usage, first condition is used to bypass @nid = 0 case which is legal case; second condition is used to check sanity of nid value, in where warn log would be printed once nid is a illegal value and in addition, SBI_NEED_FSCK will be set for later fsck.

So let's keep it as it is. :)

Thanks,

Quoted 12 lines
fs/f2fs/node.c +0 -2
@@ -1342,8 +1340,6 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
  	struct page *page;
  	int err;
 
-	if (!nid)
-		return ERR_PTR(-ENOENT);
  	if (f2fs_check_nid_range(sbi, nid))
  		return ERR_PTR(-EINVAL);
  repeat:

fs/f2fs/node.c static bool add_free_nid(struct f2fs_sb_info *sbi, · line 2194

Quoted 10 lines
fs/f2fs/node.c +0 -4
@@ -2193,10 +2189,6 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
  	int err = -EINVAL;
  	bool ret = false;
 
-	/* 0 nid should not be used */
-	if (unlikely(nid == 0))
-		return false;
-
  	if (unlikely(f2fs_check_nid_range(sbi, nid)))
  		return false;
 

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