All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug
@ 2025-05-12 11:54 ` Chao Yu
  0 siblings, 0 replies; 14+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-05-12 11:54 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

Add f2fs_bug_on() to check whether memory preallocation will fail or
not after radix_tree_preload(GFP_NOFS | __GFP_NOFAIL).

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fs/f2fs/checkpoint.c | 4 +++-
 fs/f2fs/node.c       | 7 +++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index e7907858eb70..3f223bade520 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -504,6 +504,7 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
 {
 	struct inode_management *im = &sbi->im[type];
 	struct ino_entry *e = NULL, *new = NULL;
+	int ret;
 
 	if (type == FLUSH_INO) {
 		rcu_read_lock();
@@ -516,7 +517,8 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
 		new = f2fs_kmem_cache_alloc(ino_entry_slab,
 						GFP_NOFS, true, NULL);
 
-	radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+	ret = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+	f2fs_bug_on(sbi, ret);
 
 	spin_lock(&im->ino_lock);
 	e = radix_tree_lookup(&im->ino_root, ino);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 3f6b8037d25f..88d3032236cb 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2309,7 +2309,7 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
 	struct f2fs_nm_info *nm_i = NM_I(sbi);
 	struct free_nid *i, *e;
 	struct nat_entry *ne;
-	int err = -EINVAL;
+	int err;
 	bool ret = false;
 
 	/* 0 nid should not be used */
@@ -2323,7 +2323,10 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
 	i->nid = nid;
 	i->state = FREE_NID;
 
-	radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+	err = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+	f2fs_bug_on(sbi, err);
+
+	err = -EINVAL;
 
 	spin_lock(&nm_i->nid_list_lock);
 
-- 
2.49.0



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2025-05-14 15:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12 11:54 [f2fs-dev] [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug Chao Yu via Linux-f2fs-devel
2025-05-12 11:54 ` Chao Yu
2025-05-12 11:54 ` [f2fs-dev] [PATCH 2/2] f2fs: add f2fs_bug_on() in f2fs_quota_read() Chao Yu via Linux-f2fs-devel
2025-05-12 11:54   ` Chao Yu
2025-05-12 15:27   ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-12 15:27     ` Jaegeuk Kim
2025-05-13  2:45     ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-13  2:45       ` Chao Yu
2025-05-12 15:26 ` [f2fs-dev] [PATCH 1/2] f2fs: add f2fs_bug_on() to detect potential bug Jaegeuk Kim via Linux-f2fs-devel
2025-05-12 15:26   ` Jaegeuk Kim
2025-05-13  2:44   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-13  2:44     ` Chao Yu
2025-05-14 15:40 ` [f2fs-dev] " patchwork-bot+f2fs--- via Linux-f2fs-devel
2025-05-14 15:40   ` patchwork-bot+f2fs

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.