Bug 210139

Summary: WARNING: CPU: 0 PID: 813 at include/linux/seqlock.h:279 btrfs_device_set_bytes_used+0x25/0x54
Product: File System Reporter: Erhard F. (erhard_f)
Component: btrfsAssignee: BTRFS virtual assignee (fs_btrfs)
Status: RESOLVED CODE_FIX    
Severity: normal CC: dsterba
Priority: P1    
Hardware: i386   
OS: Linux   
Kernel Version: 5.10-rc3 Subsystem:
Regression: No Bisected commit-id:
Attachments: kernel dmesg (5.10-rc3, Shuttle XPC FS51, Pentium 4 HT)
kernel .config (5.10-rc3, Shuttle XPC FS51, Pentium 4 HT)

Description Erhard F. 2020-11-10 21:36:47 UTC
Created attachment 293621 [details]
kernel dmesg (5.10-rc3, Shuttle XPC FS51, Pentium 4 HT)

I get this reliably on my Pentium 4 box when running ./cli-tests.sh (btrfs progs v5.9):

[...]
BTRFS info (device loop0): balance: start -d -m -s
------------[ cut here ]------------
WARNING: CPU: 0 PID: 813 at include/linux/seqlock.h:279 btrfs_device_set_bytes_used+0x25/0x54
Modules linked in: loop auth_rpcgss nfsv4 dns_resolver nfs lockd grace sunrpc nfs_ssc fuse input_leds rt2500pci eeprom_93cx6 rt2x00pci hid_generic rt2x00mmio rt2x00lib usbhid hid led_class mac80211 radeon evdev hwmon i2c_algo_bit drm_kms_helper cfg80211 cfbfillrect syscopyarea snd_intel8x0 cfbimgblt sysfillrect snd_ac97_codec ohci_pci sysimgblt fan fb_sys_fops ac97_bus thermal ehci_pci cfbcopyarea ohci_hcd snd_pcm ehci_hcd fb usbcore font snd_timer fbdev rfkill 8250 snd 8250_base ttm sr_mod button firewire_ohci serial_core libarc4 firewire_core i2c_sis96x cdrom usb_common 8139too mii soundcore crc_itu_t drm drm_panel_orientation_quirks backlight
CPU: 0 PID: 813 Comm: btrfs Not tainted 5.10.0-rc3-Pentium4 #7
Hardware name:  /FS51, BIOS 6.00 PG 12/02/2003
EIP: btrfs_device_set_bytes_used+0x25/0x54
Code: 5b 5e 5f 5d c3 55 89 e5 57 56 53 53 89 c3 89 d6 89 cf 83 3d f0 a0 2b cd 00 74 11 8b 40 54 83 c0 38 e8 2a f5 ff ff 85 c0 75 02 <0f> 0b 64 ff 05 cc a7 33 cd 8d 43 3c 89 45 f0 e8 00 ff ff ff 89 73
EAX: 00000000 EBX: cf9c6600 ECX: cfae1774 EDX: 00000000
ESI: 1b4c0000 EDI: 00000000 EBP: cfb2776c ESP: cfb2775c
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00010246
CR0: 80050033 CR2: 0156f1a4 CR3: 0faff000 CR4: 000006d0
Call Trace:
 btrfs_alloc_chunk+0x7c3/0x885
 btrfs_chunk_alloc+0x1a2/0x269
 ? find_free_extent+0xac6/0xd68
 find_free_extent+0xc13/0xd68
 ? hlock_class+0x18/0x58
 btrfs_reserve_extent+0xab/0x192
 btrfs_alloc_tree_block+0x10a/0x311
 ? check_path.constprop.0+0x18/0x2e
 alloc_tree_block_no_bg_flush+0x52/0x5b
 __btrfs_cow_block+0x109/0x496
 btrfs_cow_block+0x104/0x1ad
 btrfs_search_slot+0x227/0x5ae
 btrfs_truncate_inode_items+0x26c/0xd68
 ? check_chain_key+0xea/0x142
 ? unmap_mapping_range+0x4e/0x57
 ? truncate_pagecache+0x61/0x6c
 btrfs_truncate_free_space_cache+0x153/0x1d6
 ? delete_block_group_cache+0x6a/0x8c
 delete_block_group_cache+0x6a/0x8c
 btrfs_relocate_block_group+0xbf/0x255
 btrfs_relocate_chunk+0x41/0xe7
 btrfs_balance+0xbee/0xe21
 btrfs_ioctl_balance+0x211/0x29f
 ? btrfs_ioctl_get_supported_features+0x1e/0x1e
 btrfs_ioctl+0x1538/0x2a83
 ? rcu_read_lock_sched_held+0x23/0x4a
 ? __alloc_pages_nodemask+0xa64/0xa6e
 ? check_chain_key+0xea/0x142
 ? check_chain_key+0xea/0x142
 ? handle_mm_fault+0x4cd/0x935
 ? btrfs_ioctl_get_supported_features+0x1e/0x1e
 vfs_ioctl+0x1a/0x24
 ? __fget_light+0x24/0x49
 ? vfs_ioctl+0x1a/0x24
 __ia32_sys_ioctl+0x618/0x632
 __do_fast_syscall_32+0x66/0x76
 do_fast_syscall_32+0x29/0x5b
 do_SYSENTER_32+0x15/0x17
 entry_SYSENTER_32+0x9f/0xf2
EIP: 0xb7f9c545
Code: c4 01 10 03 03 74 c0 01 10 05 03 74 b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76
EAX: ffffffda EBX: 00000003 ECX: c4009420 EDX: bfd5307c
ESI: 00000001 EDI: 00000003 EBP: bfd551b7 ESP: bfd52fd8
DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS: 00000292
CPU: 0 PID: 813 Comm: btrfs Not tainted 5.10.0-rc3-Pentium4 #7
Hardware name:  /FS51, BIOS 6.00 PG 12/02/2003
Call Trace:
 dump_stack+0x6b/0x89
 ? btrfs_device_set_bytes_used+0x25/0x54
 __warn+0xaa/0xcc
 report_bug+0x8f/0xcd
 ? btrfs_device_set_bytes_used+0x25/0x54
 ? exc_overflow+0x37/0x37
 handle_bug+0x2b/0x47
 exc_invalid_op+0x1a/0x51
 handle_exception+0x10e/0x10e
EIP: btrfs_device_set_bytes_used+0x25/0x54
Code: 5b 5e 5f 5d c3 55 89 e5 57 56 53 53 89 c3 89 d6 89 cf 83 3d f0 a0 2b cd 00 74 11 8b 40 54 83 c0 38 e8 2a f5 ff ff 85 c0 75 02 <0f> 0b 64 ff 05 cc a7 33 cd 8d 43 3c 89 45 f0 e8 00 ff ff ff 89 73
EAX: 00000000 EBX: cf9c6600 ECX: cfae1774 EDX: 00000000
ESI: 1b4c0000 EDI: 00000000 EBP: cfb2776c ESP: cfb2775c
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00010246
 ? check_leaf+0xd71/0x1510
 ? exc_overflow+0x37/0x37
 ? btrfs_device_set_bytes_used+0x25/0x54
 btrfs_alloc_chunk+0x7c3/0x885
 btrfs_chunk_alloc+0x1a2/0x269
 ? find_free_extent+0xac6/0xd68
 find_free_extent+0xc13/0xd68
 ? hlock_class+0x18/0x58
 btrfs_reserve_extent+0xab/0x192
 btrfs_alloc_tree_block+0x10a/0x311
 ? check_path.constprop.0+0x18/0x2e
 alloc_tree_block_no_bg_flush+0x52/0x5b
 __btrfs_cow_block+0x109/0x496
 btrfs_cow_block+0x104/0x1ad
 btrfs_search_slot+0x227/0x5ae
 btrfs_truncate_inode_items+0x26c/0xd68
 ? check_chain_key+0xea/0x142
 ? unmap_mapping_range+0x4e/0x57
 ? truncate_pagecache+0x61/0x6c
 btrfs_truncate_free_space_cache+0x153/0x1d6
 ? delete_block_group_cache+0x6a/0x8c
 delete_block_group_cache+0x6a/0x8c
 btrfs_relocate_block_group+0xbf/0x255
 btrfs_relocate_chunk+0x41/0xe7
 btrfs_balance+0xbee/0xe21
 btrfs_ioctl_balance+0x211/0x29f
 ? btrfs_ioctl_get_supported_features+0x1e/0x1e
 btrfs_ioctl+0x1538/0x2a83
 ? rcu_read_lock_sched_held+0x23/0x4a
 ? __alloc_pages_nodemask+0xa64/0xa6e
 ? check_chain_key+0xea/0x142
 ? check_chain_key+0xea/0x142
 ? handle_mm_fault+0x4cd/0x935
 ? btrfs_ioctl_get_supported_features+0x1e/0x1e
 vfs_ioctl+0x1a/0x24
 ? __fget_light+0x24/0x49
 ? vfs_ioctl+0x1a/0x24
 __ia32_sys_ioctl+0x618/0x632
 __do_fast_syscall_32+0x66/0x76
 do_fast_syscall_32+0x29/0x5b
 do_SYSENTER_32+0x15/0x17
 entry_SYSENTER_32+0x9f/0xf2
EIP: 0xb7f9c545
Code: c4 01 10 03 03 74 c0 01 10 05 03 74 b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76
EAX: ffffffda EBX: 00000003 ECX: c4009420 EDX: bfd5307c
ESI: 00000001 EDI: 00000003 EBP: bfd551b7 ESP: bfd52fd8
DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS: 00000292
irq event stamp: 6447
hardirqs last  enabled at (6455): [<cca7a33a>] console_unlock+0x423/0x454
hardirqs last disabled at (6462): [<cca7a02c>] console_unlock+0x115/0x454
softirqs last  enabled at (4558): [<ccf81c1f>] __do_softirq+0x2d7/0x307
softirqs last disabled at (4509): [<cca0f831>] call_on_stack+0x40/0x46
---[ end trace 7b9bda816bb81e56 ]---
[...]
Comment 1 Erhard F. 2020-11-10 22:13:06 UTC
Created attachment 293623 [details]
kernel .config (5.10-rc3, Shuttle XPC FS51, Pentium 4 HT)
Comment 2 Erhard F. 2020-12-29 02:19:42 UTC
From kernel 5.10.3 on the same machine:

[...]
------------[ cut here ]------------
WARNING: CPU: 0 PID: 72 at include/linux/seqlock.h:279 btrfs_device_set_bytes_used+0x25/0x54
Modules linked in: auth_rpcgss nfsv4 dns_resolver nfs lockd grace sunrpc nfs_ssc fuse rt2500pci eeprom_93cx6 input_leds rt2x00pci rt2x00mmio hid_generic rt2x00lib led_class usbhid hid mac80211 radeon evdev hwmon i2c_algo_bit cfg80211 drm_kms_helper ohci_pci cfbfillrect syscopyarea cfbimgblt ohci_hcd sysfillrect ehci_pci sysimgblt ehci_hcd fb_sys_fops snd_intel8x0 cfbcopyarea snd_ac97_codec fb thermal usbcore ac97_bus 8250 snd_pcm font firewire_ohci 8250_base fbdev serial_core snd_timer sr_mod ttm firewire_core rfkill snd 8139too button libarc4 cdrom mii usb_common crc_itu_t i2c_sis96x soundcore fan drm drm_panel_orientation_quirks backlight
CPU: 0 PID: 72 Comm: btrfs-cleaner Not tainted 5.10.3-gentoo-Pentium4 #2
Hardware name:  /FS51, BIOS 6.00 PG 12/02/2003
EIP: btrfs_device_set_bytes_used+0x25/0x54
Code: 5b 5e 5f 5d c3 55 89 e5 57 56 53 53 89 c3 89 d6 89 cf 83 3d 70 04 6b d8 00 74 11 8b 40 54 83 c0 38 e8 2a f5 ff ff 85 c0 75 02 <0f> 0b 64 ff 05 cc 07 73 d8 8d 43 3c 89 45 f0 e8 00 ff ff ff 89 73
EAX: 00000000 EBX: c181b800 ECX: c19b385c EDX: 00000000
ESI: 01800000 EDI: 00000003 EBP: c19abea0 ESP: c19abe90
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00010246
CR0: 80050033 CR2: 01556fe8 CR3: 1ed5d000 CR4: 000006d0
Call Trace:
 btrfs_remove_chunk+0x2c0/0x654
 ? _raw_spin_unlock+0x18/0x22
 btrfs_delete_unused_bgs+0x3f7/0x4aa
 cleaner_kthread+0x97/0xf1
 kthread+0xe5/0xe7
 ? btrfs_need_cleaner_sleep+0x21/0x21
 ? kthread_unpark+0x48/0x48
 ret_from_fork+0x1c/0x28
irq event stamp: 5447
hardirqs last  enabled at (5455): [<d7e7a625>] console_unlock+0x423/0x454
hardirqs last disabled at (5462): [<d7e7a317>] console_unlock+0x115/0x454
softirqs last  enabled at (4848): [<d837bb9f>] __do_softirq+0x2d7/0x307
softirqs last disabled at (4839): [<d7e0fa9e>] call_on_stack+0x40/0x46
---[ end trace 386ed7b64f6ef22f ]---
[...]
Comment 3 David Sterba 2021-01-25 17:11:08 UTC
Thanks for the report. Will be fixed by https://lore.kernel.org/linux-btrfs/20210121113910.14681-1-l@damenly.su/ once it gets to stable.