Skip to contentSkip to conversation

f2fs: fix to unlock page correctly in error path of is_alive()

PATCH Superseded Chao Yu 2 participants 3 messages Feb 3, 2022 – Feb 4, 2022 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/1 f2fs: fix to unlock page correctly in error path of is_alive()

As Pavel Machek reported in below link [1]:

After commit 77900c45ee5c ("f2fs: fix to do sanity check in is_alive()"), node page should be unlock via calling f2fs_put_page() in the error path of is_alive(), otherwise, f2fs may hang when it tries to lock the node page, fix it.

[1] https://lore.kernel.org/stable/[email protected]/

Fixes 77900c45ee5c ("f2fs: fix to do sanity check in is_alive()")
---
 fs/f2fs/gc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/gc.c +3 -1
index 0a6b0a8ae97e..2d53ef121e76 100644
@@ -1038,8 +1038,10 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
 		set_sbi_flag(sbi, SBI_NEED_FSCK);
 	}
 
-	if (f2fs_check_nid_range(sbi, dni->ino))
+	if (f2fs_check_nid_range(sbi, dni->ino)) {
+		f2fs_put_page(node_page, 1);
 		return false;
+	}
 
 	*nofs = ofs_of_node(node_page);
 	source_blkaddr = data_blkaddr(NULL, node_page, ofs_in_node);
Signature · 8 lines
2.32.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#1 lore raw
Quoted 8 lines · Chao Yu

As Pavel Machek reported in below link [1]:

After commit 77900c45ee5c ("f2fs: fix to do sanity check in is_alive()"), node page should be unlock via calling f2fs_put_page() in the error path of is_alive(), otherwise, f2fs may hang when it tries to lock the node page, fix it.

[1] https://lore.kernel.org/stable/[email protected]/

Need -stable? It seems 4.19+?

Quoted 27 lines
Fixes 77900c45ee5c ("f2fs: fix to do sanity check in is_alive()")
---
 fs/f2fs/gc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/gc.c +3 -1
index 0a6b0a8ae97e..2d53ef121e76 100644
@@ -1038,8 +1038,10 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
 		set_sbi_flag(sbi, SBI_NEED_FSCK);
 	}
 
-	if (f2fs_check_nid_range(sbi, dni->ino))
+	if (f2fs_check_nid_range(sbi, dni->ino)) {
+		f2fs_put_page(node_page, 1);
 		return false;
+	}
 
 	*nofs = ofs_of_node(node_page);
 	source_blkaddr = data_blkaddr(NULL, node_page, ofs_in_node);
Signature · 1 line
2.32.0
author maintainer
#2 lore raw
Quoted 11 lines · Jaegeuk Kim
Quoted 8 lines · Chao Yu

As Pavel Machek reported in below link [1]:

After commit 77900c45ee5c ("f2fs: fix to do sanity check in is_alive()"), node page should be unlock via calling f2fs_put_page() in the error path of is_alive(), otherwise, f2fs may hang when it tries to lock the node page, fix it.

[1] https://lore.kernel.org/stable/[email protected]/

Need -stable? It seems 4.19+?

It depends on where commit 77900c45ee5c ("f2fs: fix to do sanity check in is_alive()") be backported to? Anyway, let me Cc stable-kernel mailing list.

Thanks,

Quoted 28 lines
Quoted 28 lines
Fixes 77900c45ee5c ("f2fs: fix to do sanity check in is_alive()")
---
  fs/f2fs/gc.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/gc.c +3 -1
index 0a6b0a8ae97e..2d53ef121e76 100644
@@ -1038,8 +1038,10 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
  		set_sbi_flag(sbi, SBI_NEED_FSCK);
  	}
 
-	if (f2fs_check_nid_range(sbi, dni->ino))
+	if (f2fs_check_nid_range(sbi, dni->ino)) {
+		f2fs_put_page(node_page, 1);
  		return false;
+	}
 
  	*nofs = ofs_of_node(node_page);
  	source_blkaddr = data_blkaddr(NULL, node_page, ofs_in_node);
Signature · 1 line
2.32.0