linux-nilfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -mm] nilfs2: convert BUG_ON() in nilfs_finish_roll_forward() to WARN_ON()
@ 2024-05-08 22:14 Ryusuke Konishi
  0 siblings, 0 replies; only message in thread
From: Ryusuke Konishi @ 2024-05-08 22:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-nilfs, linux-kernel

The BUG_ON check performed on the return value of __getblk() in
nilfs_finish_roll_forward() assumes that a buffer that has been
successfully read once is retrieved with the same parameters and does
not fail (__getblk() does not return an error due to memory allocation
failure).  Also, nilfs_finish_roll_forward() is called at most once
during mount.

Taking these into consideration, rewrite the check to use WARN_ON() to
avoid using BUG_ON().

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
Andrew, please add this to the queue for the next cycle (if it's not late).

This is a change to reduce BUG_ONs in legacy usage.

 fs/nilfs2/recovery.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c
index e48372618ac4..020f304c600e 100644
--- a/fs/nilfs2/recovery.c
+++ b/fs/nilfs2/recovery.c
@@ -699,7 +699,9 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
 		return;
 
 	bh = __getblk(nilfs->ns_bdev, ri->ri_lsegs_start, nilfs->ns_blocksize);
-	BUG_ON(!bh);
+	if (WARN_ON(!bh))
+		return;  /* should never happen */
+
 	memset(bh->b_data, 0, bh->b_size);
 	set_buffer_dirty(bh);
 	err = sync_dirty_buffer(bh);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-08 22:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-08 22:14 [PATCH -mm] nilfs2: convert BUG_ON() in nilfs_finish_roll_forward() to WARN_ON() Ryusuke Konishi

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).