Version upgrade from 0.24: unwritten_extents to 1.7: mi_btree_bitmap incomplete
Doing incompatible version upgrade from 0.24: unwritten_extents to 1.25: extent_flags
  running recovery passes: check_allocations,check_alloc_info,check_lrus,check_btree_backpointers,check_backpointers_to_extents,check_extents_to_backpointers,check_alloc_to_lru_refs,bucket_gens_init,check_snapshot_trees,check_snapshots,check_subvols,check_subvol_children,delete_dead_snapshots,check_inodes,check_extents,check_indirect_extents,check_dirents,check_xattrs,check_root,check_unreachable_inodes,check_subvolume_structure,check_directory_structure,check_nlinks,set_fs_needs_rebalance
bcachefs (loop0): bcachefs (loop0): error validating btree node at btree inodes level 0/0
  u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 7589ab5e0c11cc7a written 24 min_key POS_MIN durability: 1 ptr: 0:38:0 gen 0
  node offset 16/24 bset u64s 110 bset byte offset 536: bad k->u64s 0 (min 3 max 253), fixing
bcachefs (loop0): bcachefs (loop0): error validating btree node at btree inodes level 0/0
  u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 7589ab5e0c11cc7a written 24 min_key POS_MIN durability: 1 ptr: 0:38:0 gen 0
  node offset 16/24 bset u64s 99 bset byte offset 696: key extends past end of bset, fixing
bcachefs (loop0): btree_node_read_work: rewriting btree node at due to error
  btree=inodes level=0 u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 7589ab5e0c11cc7a written 24 min_key POS_MIN durability: 1 ptr: 0:38:0 gen 0
bcachefs (loop0): bcachefs (loop0): error validating btree node on loop0 at btree dirents level 0/0
  u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 9aa2895aefce4bdf written 24 min_key POS_MIN durability: 1 ptr: 0:41:0 gen 0
  node offset 0/24 bset u64s 0: unsupported bset version 0.0
bcachefs (loop0): flagging btree dirents lost data
bcachefs (loop0): running explicit recovery pass check_topology (2), currently at recovery_pass_empty (0)
bcachefs (loop0): running explicit recovery pass scan_for_btree_nodes (1), currently at recovery_pass_empty (0)
bcachefs (loop0): error reading btree root btree=dirents level=0: btree_node_read_error, fixing
bcachefs (loop0): bcachefs (loop0): error validating btree node at btree alloc level 0/0
  u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq ac62141f8dc7e261 written 24 min_key POS_MIN durability: 1 ptr: 0:26:0 gen 0
  node offset 8/24 bset u64s 375 bset byte offset 184: keys out of order: u64s 11 type alloc_v4 0:32:0 len 0 ver 0 > u64s 11 type alloc_v4 0:2:0 len 0 ver 0, fixing
bcachefs (loop0): btree_node_read_work: rewriting btree node at due to error
  btree=alloc level=0 u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq ac62141f8dc7e261 written 24 min_key POS_MIN durability: 1 ptr: 0:26:0 gen 0
bcachefs (loop0): bcachefs (loop0): error validating btree node on loop0 at btree snapshots level 0/0
  u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq ebb8d5a9e3463bdb written 16 min_key POS_MIN durability: 1 ptr: 0:32:0 gen 0
  node offset 0/16 bset u64s 0: invalid bkey format: field 1 too large: 18446744073709551615 + 3 > 18446744073709551615
  u64s 3 fields 64:0, 64:3, 32:0, 0:0, 0:0, 0:0, btree topology error: 
bcachefs (loop0): flagging btree snapshots lost data
bcachefs (loop0): error reading btree root btree=snapshots level=0: btree_node_read_error, fixing
bcachefs (loop0): scan_for_btree_nodes...
bcachefs (loop0): btree node scan found 5 nodes after overwrites
 done
bcachefs (loop0): check_topology...
bcachefs (loop0): btree root dirents unreadable, must recover from scan
bcachefs (loop0): no nodes found for btree dirents, continuing
bcachefs (loop0): btree root snapshots unreadable, must recover from scan
bcachefs (loop0): no nodes found for btree snapshots, continuing
 done
bcachefs (loop0): accounting_read... done
bcachefs (loop0): alloc_read... done
bcachefs (loop0): snapshots_read...
bcachefs (loop0): running explicit recovery pass reconstruct_snapshots (21), currently at snapshots_read (7)
 done
bcachefs (loop0): check_allocations...
bcachefs (loop0): bucket 0:26 data type btree ptr gen 0 missing in alloc btree
  while marking u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq ac62141f8dc7e261 written 24 min_key POS_MIN durability: 1 ptr: 0:26:0 gen 0, fixing
bcachefs (loop0): pointer to nonexistent device 237
  
bcachefs (loop0): pointer to missing device 237
  while marking u64s 7 type extent 536870913:100663320:U32_MAX len 24 ver 0: durability: 0 crc: c_size 8 size 24 offset 0 nonce 0 csum none 0:0  compress lz4 ptr: 237:893353206280 gen 0, fixing
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000004: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
CPU: 0 UID: 0 PID: 5330 Comm: syz.0.0 Not tainted 6.15.0-rc1-syzkaller-00065-g3b07108ada81 #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:bch2_snapshot_tree_oldest_subvol+0x1d3/0x6a0 fs/bcachefs/snapshot.c:400
Code: e6 e8 f1 ba 36 fd 4c 39 e5 0f 86 c9 03 00 00 e8 83 b8 36 fd 49 6b c4 38 49 01 c6 49 83 c6 18 49 83 c6 20 4c 89 f0 48 c1 e8 03 <42> 0f b6 04 28 84 c0 0f 85 c6 03 00 00 41 8b 2e 31 ff 89 ee e8 94
RSP: 0018:ffffc9000d366040 EFLAGS: 00010202
RAX: 0000000000000004 RBX: 0000000000000001 RCX: 0000000000100000
RDX: ffffc9000e552000 RSI: 00000000000853af RDI: 00000000000853b0
RBP: ffffffff848cab5b R08: ffffffff848cac89 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 00000000ffeb487f
R13: dffffc0000000000 R14: 0000000000000020 R15: 000000000014b780
FS:  00007f2c710c06c0(0000) GS:ffff88808c596000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055b654e280a8 CR3: 0000000035994000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 bch2_inum_snap_offset_err_msg_trans+0x374/0x680 fs/bcachefs/error.c:694
 bch2_indirect_extent_missing_error+0x411/0x1290 fs/bcachefs/reflink.c:192
 gc_trigger_reflink_p_segment fs/bcachefs/reflink.c:392 [inline]
 __trigger_reflink_p+0x1960/0x1cb0 fs/bcachefs/reflink.c:432
 bch2_trigger_reflink_p+0x299/0x380 fs/bcachefs/reflink.c:451
 bch2_key_trigger fs/bcachefs/bkey_methods.h:88 [inline]
 bch2_gc_mark_key+0x6b9/0x1170 fs/bcachefs/btree_gc.c:639
 bch2_gc_btree fs/bcachefs/btree_gc.c:677 [inline]
 bch2_gc_btrees fs/bcachefs/btree_gc.c:740 [inline]
 bch2_check_allocations+0x1439/0x6930 fs/bcachefs/btree_gc.c:1042
 bch2_run_recovery_pass+0xf0/0x1e0 fs/bcachefs/recovery_passes.c:226
 bch2_run_recovery_passes+0x2ad/0xa90 fs/bcachefs/recovery_passes.c:285
 bch2_fs_recovery+0x292a/0x3e20 fs/bcachefs/recovery.c:936
 bch2_fs_start+0x310/0x620 fs/bcachefs/super.c:1069
 bch2_fs_get_tree+0x113e/0x18f0 fs/bcachefs/fs.c:2253
 vfs_get_tree+0x90/0x2b0 fs/super.c:1759
 do_new_mount+0x2cf/0xb70 fs/namespace.c:3879
 do_mount fs/namespace.c:4219 [inline]
 __do_sys_mount fs/namespace.c:4430 [inline]
 __se_sys_mount+0x38c/0x400 fs/namespace.c:4407
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f2c7018e90a
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2c710bfe68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f2c710bfef0 RCX: 00007f2c7018e90a
RDX: 0000200000000480 RSI: 0000200000000000 RDI: 00007f2c710bfeb0
RBP: 0000200000000480 R08: 00007f2c710bfef0 R09: 0000000000000006
R10: 0000000000000006 R11: 0000000000000246 R12: 0000200000000000
R13: 00007f2c710bfeb0 R14: 000000000000599e R15: 0000200000000640
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:bch2_snapshot_tree_oldest_subvol+0x1d3/0x6a0 fs/bcachefs/snapshot.c:400
Code: e6 e8 f1 ba 36 fd 4c 39 e5 0f 86 c9 03 00 00 e8 83 b8 36 fd 49 6b c4 38 49 01 c6 49 83 c6 18 49 83 c6 20 4c 89 f0 48 c1 e8 03 <42> 0f b6 04 28 84 c0 0f 85 c6 03 00 00 41 8b 2e 31 ff 89 ee e8 94
RSP: 0018:ffffc9000d366040 EFLAGS: 00010202
RAX: 0000000000000004 RBX: 0000000000000001 RCX: 0000000000100000
RDX: ffffc9000e552000 RSI: 00000000000853af RDI: 00000000000853b0
RBP: ffffffff848cab5b R08: ffffffff848cac89 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 00000000ffeb487f
R13: dffffc0000000000 R14: 0000000000000020 R15: 000000000014b780
FS:  00007f2c710c06c0(0000) GS:ffff88808c596000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055b654e280a8 CR3: 0000000035994000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess), 1 bytes skipped:
   0:	e8 f1 ba 36 fd       	call   0xfd36baf6
   5:	4c 39 e5             	cmp    %r12,%rbp
   8:	0f 86 c9 03 00 00    	jbe    0x3d7
   e:	e8 83 b8 36 fd       	call   0xfd36b896
  13:	49 6b c4 38          	imul   $0x38,%r12,%rax
  17:	49 01 c6             	add    %rax,%r14
  1a:	49 83 c6 18          	add    $0x18,%r14
  1e:	49 83 c6 20          	add    $0x20,%r14
  22:	4c 89 f0             	mov    %r14,%rax
  25:	48 c1 e8 03          	shr    $0x3,%rax
* 29:	42 0f b6 04 28       	movzbl (%rax,%r13,1),%eax <-- trapping instruction
  2e:	84 c0                	test   %al,%al
  30:	0f 85 c6 03 00 00    	jne    0x3fc
  36:	41 8b 2e             	mov    (%r14),%ebp
  39:	31 ff                	xor    %edi,%edi
  3b:	89 ee                	mov    %ebp,%esi
  3d:	e8                   	.byte 0xe8
  3e:	94                   	xchg   %eax,%esp