koverstreet / bcachefs

Other
633 stars 69 forks source link

WARNING: at fs/inode.c:1084 discard_new_inode+0x6e/0x80 #690

Closed g2p closed 2 weeks ago

g2p commented 3 weeks ago

Kernel is bcachefs/master as of b37c1b07570da3a481dc913b44f53a06d259595e (rebased on slightly newer linus/master), and I get these warnings periodically from multithreaded programs like dua, fclones, nfsd.

Apparently discard_new_inode is called on an inode that isn't really new. Caller was updated in d93ff5fa40b9db5f505d508336bc171f54db862e "bcachefs: Fix race path in bch2_inode_insert()".

void discard_new_inode(struct inode *inode)
{
    lockdep_annotate_inode_mutex_key(inode);
    spin_lock(&inode->i_lock);
    WARN_ON(!(inode->i_state & I_NEW));
    inode->i_state &= ~I_NEW;
    smp_mb();
    wake_up_bit(&inode->i_state, __I_NEW);
    spin_unlock(&inode->i_lock);
    iput(inode);
}
dmesg ``` ------------[ cut here ]------------ WARNING: CPU: 1 PID: 26531 at fs/inode.c:1084 discard_new_inode+0x6e/0x80 Modules linked in: essiv(E) authenc(E) snd_seq_dummy(E) snd_hrtimer(E) xfs(E) dm_crypt(E) kyber_iosched(E) cmac(E) ccm(E) nls_utf8(E) wireguard(E) curve25519_x86_64(E) libcurve25519_generic(E) libchacha20poly1305(E) chacha_x86_64(E) poly1305_x86_64(E) ip6_udp_tunnel(E) udp_tunnel(E) ip6t_REJECT(E) nf_reject_ipv6(E) xt_hl(E) ip6t_rt(E) ipt_REJECT(E) nf_reject_ipv4(E) xt_multiport(E) xt_recent(E) nft_limit(E) xt_limit(E) xt_addrtype(E) xt_tcpudp(E) xt_conntrack(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) nft_compat(E) nf_tables(E) binfmt_misc(E) btrfs(E) blake2b_generic(E) nls_iso8859_1(E) iwlmvm(E) mac80211(E) snd_hda_codec_realtek(E) snd_hda_codec_generic(E) snd_hda_scodec_component(E) snd_hda_codec_hdmi(E) snd_hda_intel(E) snd_intel_dspcfg(E) libarc4(E) snd_hda_codec(E) snd_hwdep(E) snd_hda_core(E) nouveau(E) snd_pcm(E) iwlwifi(E) drm_ttm_helper(E) ttm(E) video(E) gpu_sched(E) drm_gpuvm(E) drm_exec(E) snd_seq(E) mxm_wmi(E) snd_seq_device(E) snd_timer(E) drm_display_helper(E) cfg80211(E) drm_kms_helper(E) snd(E) k10temp(E) intel_rapl_msr(E) soundcore(E) intel_rapl_common(E) wmi_bmof(E) kvm_amd(E) i2c_piix4(E) kvm(E) mac_hid(E) rapl(E) wmi(E) nfsd(E) drm(E) lockd(E) auth_rpcgss(E) grace(E) sunrpc(E) efi_pstore(E) nfnetlink(E) dmi_sysfs(E) ip_tables(E) x_tables(E) bcache(E) bridge(E) crct10dif_pclmul(E) stp(E) pata_acpi(E) crc32_pclmul(E) llc(E) polyval_clmulni(E) polyval_generic(E) nvme(E) ghash_clmulni_intel(E) sha512_ssse3(E) igb(E) sha256_ssse3(E) pata_jmicron(E) i2c_algo_bit(E) ahci(E) sha1_ssse3(E) dca(E) nvme_core(E) libahci(E) nvme_auth(E) ccp(E) xhci_pci(E) xhci_pci_renesas(E) dm_mirror(E) dm_region_hash(E) dm_log(E) msr(E) autofs4(E) aesni_intel(E) crypto_simd(E) cryptd(E) CPU: 1 PID: 26531 Comm: dua-fs-walk-5 Tainted: G W E 6.10.0-rc3-g2p #84 Hardware name: To Be Filled By O.E.M. X570 Phantom Gaming 4/X570 Phantom Gaming 4, BIOS P5.61 02/22/2024 RIP: 0010:discard_new_inode+0x6e/0x80 Code: 8d bb 98 00 00 00 e8 e1 dc ca ff 4c 89 e7 e8 79 70 cf 00 48 89 df e8 41 fd ff ff 5b 41 5c 5d 31 c0 31 f6 31 ff e9 a2 7e cf 00 <0f> 0b eb bb 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa RSP: 0018:ffffaba4223935f0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff97b8973cce18 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffaba422393600 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff97b8973ccea0 R13: ffff97b6ab017ab8 R14: ffffaba422393740 R15: ffff97b684548000 FS: 00007f7d895ff6c0(0000) GS:ffff97b9aec80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fbd02754000 CR3: 0000000154746000 CR4: 0000000000350ef0 Call Trace: ? show_regs+0x70/0x90 ? __warn+0x8c/0x150 ? discard_new_inode+0x6e/0x80 ? report_bug+0x186/0x1b0 ? handle_bug+0x48/0x90 ? exc_invalid_op+0x1c/0x80 ? asm_exc_invalid_op+0x1f/0x30 ? discard_new_inode+0x6e/0x80 bch2_inode_insert+0x13c/0x150 bch2_lookup_trans+0x5d6/0x5f0 bch2_lookup+0xad/0x180 ? srso_return_thunk+0x5/0x5f ? bch2_lookup+0xad/0x180 __lookup_slow+0x85/0x130 ? srso_return_thunk+0x5/0x5f walk_component+0x117/0x190 path_lookupat+0x6a/0x1b0 filename_lookup+0xde/0x1f0 vfs_statx+0x95/0x1d0 do_statx+0x68/0xc0 __x64_sys_statx+0x6b/0xa0 x64_sys_call+0x340/0x25e0 do_syscall_64+0x68/0x120 ? __fput+0x1b1/0x2e0 ? srso_return_thunk+0x5/0x5f ? kmem_cache_free+0x3fc/0x420 ? srso_return_thunk+0x5/0x5f ? __fput+0x1b1/0x2e0 ? srso_return_thunk+0x5/0x5f ? __fput_sync+0x20/0x30 ? srso_return_thunk+0x5/0x5f ? srso_return_thunk+0x5/0x5f ? syscall_exit_to_user_mode+0x7c/0x180 ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x74/0x120 ? srso_return_thunk+0x5/0x5f ? atime_needs_update+0x69/0x130 ? srso_return_thunk+0x5/0x5f ? touch_atime+0x23/0x130 ? srso_return_thunk+0x5/0x5f ? iterate_dir+0x1b6/0x230 ? srso_return_thunk+0x5/0x5f ? __f_unlock_pos+0x16/0x20 ? srso_return_thunk+0x5/0x5f ? __x64_sys_getdents64+0x112/0x140 ? __x64_sys_getdents64+0x140/0x140 ? srso_return_thunk+0x5/0x5f ? syscall_exit_to_user_mode+0x7c/0x180 ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x74/0x120 ? srso_return_thunk+0x5/0x5f ? syscall_exit_to_user_mode+0x7c/0x180 ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x74/0x120 ? do_syscall_64+0x74/0x120 ? __x64_sys_statx+0x75/0xa0 ? srso_return_thunk+0x5/0x5f ? syscall_exit_to_user_mode+0x7c/0x180 ? srso_return_thunk+0x5/0x5f ? do_syscall_64+0x74/0x120 ? do_syscall_64+0x74/0x120 entry_SYSCALL_64_after_hwframe+0x55/0x5d RIP: 0033:0x7f7d8971bf1e Code: 6f 0e 00 ba ff ff ff ff 64 c7 00 16 00 00 00 e9 b9 fd ff ff e8 83 bf 01 00 0f 1f 00 f3 0f 1e fa 41 89 ca b8 4c 01 00 00 0f 05 <48> 3d 00 f0 ff ff 77 2a 89 c1 85 c0 74 0f 48 8b 05 c5 6e 0e 00 64 RSP: 002b:00007f7d895fc1f8 EFLAGS: 00000202 ORIG_RAX: 000000000000014c RAX: ffffffffffffffda RBX: 00007f7d895fc320 RCX: 00007f7d8971bf1e RDX: 0000000000000100 RSI: 00007f7d895fc460 RDI: 00000000ffffff9c RBP: 0000000000000001 R08: 00007f7d895fc200 R09: 0000000000000007 R10: 0000000000000fff R11: 0000000000000202 R12: 00007f7d895fcb80 R13: 00007f7d402fc5c0 R14: 00000000000000a0 R15: 00007f7d895fc460 ---[ end trace 0000000000000000 ]--- ```
koverstreet commented 2 weeks ago

Fixed by 1f06731fa910 bcachefs: Fix I_NEW warning in race path in bch2_inode_insert() which is now in my bcachefs-for-upstream branch