Re: [syzbot] [bcachefs?] WARNING in bch2_dev_free (2)

Kent Overstreet <[email protected]>
Newsgroups org.kernel.vger.linux-bcachefs,org.kernel.vger.linux-kernel
Message-ID <njvsgnfvwy3jwoy3zu23jp4365sp7aedqyllnf2efvqk44wr53@nuzknq3f7cem>
On Thu, Jul 17, 2025 at 12:13:33PM -0700, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    e8352908bdcd Add linux-next specific files for 20250716
> git tree:       linux-next
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=156f67d4580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=2594af20939db736
> dashboard link: https://syzkaller.appspot.com/bug?extid=6d52ee9afea131b36348
> compiler:       Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11a2158c580000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=138bc58c580000

regression from

bcachefs: Fix __bch2_fs_read_write() error path

fixed by

(mark dirty before we start the write refcounts)

commit 212c9b90f9915058b4d98210660daa10860b124b
Author: Kent Overstreet <[email protected]>
Date:   Thu Jul 17 16:11:38 2025 -0400

    fixup! bcachefs: Fix __bch2_fs_read_write() error path

diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 4e038f655f83..0fc0b2221036 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -514,6 +514,10 @@ static int __bch2_fs_read_write(struct bch_fs *c, bool early)
 	if (ret)
 		return ret;
 
+	ret = bch2_fs_mark_dirty(c);
+	if (ret)
+		return ret;
+
 	clear_bit(BCH_FS_clean_shutdown, &c->flags);
 
 	scoped_guard(rcu)
@@ -537,10 +541,6 @@ static int __bch2_fs_read_write(struct bch_fs *c, bool early)
 		bch2_journal_space_available(&c->journal);
 	}
 
-	ret = bch2_fs_mark_dirty(c);
-	if (ret)
-		return ret;
-
 	/*
 	 * Don't jump to our error path, and call bch2_fs_read_only(), unless we
 	 * successfully marked the filesystem dirty
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.