This is the warning trigger line: int bch_cached_dev_writeback_start(struct cached_dev *dc) ... WARN_ON(test_and_set_bit(BCACHE_DEV_WB_RUNNING, &dc->disk.flags)); ...
This commit fixes this problem: commit 1f0ffa67349c56ea54c03ccfd1e073c990e7411e Author: Coly Li <col...@suse.de> Date: Mon Jun 10 06:13:35 2019 +0800 bcache: only set BCACHE_DEV_WB_RUNNING when cached device attached It is included in linux 5.2, so for now only Ubuntu Eoan has the fix; I could reproduce the problem with Ubuntu Disco (5.0-based) kernel. The problem can Oops the kernel (worse error) if the cache is not attached soon (reproduced below). I'll provide a test kernel with the fix soon. Steps to reproduce: ------------------ With attach (last line in script): $ sudo ./setup-bcache-wb_percent-before-attach.sh ... [ 36.130659] WARNING: CPU: 2 PID: 1288 at drivers/md/bcache/writeback.c:837 bch_cached_dev_writeback_start+0x156/0x164 [bcache] ... [ 36.155742] RIP: 0010:bch_cached_dev_writeback_start+0x156/0x164 [bcache] ... [ 36.182455] Call Trace: [ 36.183387] bch_cached_dev_attach+0x356/0x480 [bcache] [ 36.185104] ? bch_keybuf_init+0x70/0x70 [bcache] [ 36.186653] __cached_dev_store+0x59f/0x8b0 [bcache] [ 36.188274] bch_cached_dev_store+0x39/0xc0 [bcache] [ 36.189887] sysfs_kf_write+0x3b/0x40 [ 36.191142] kernfs_fop_write+0x12e/0x1b0 [ 36.192502] __vfs_write+0x1b/0x40 [ 36.193686] vfs_write+0xab/0x1b0 [ 36.194842] ksys_write+0x5c/0xd0 [ 36.196026] __x64_sys_write+0x1a/0x20 [ 36.197296] do_syscall_64+0x5a/0x110 [ 36.198532] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 36.200158] RIP: 0033:0x7f69a1d09154 ... [ 36.222967] ---[ end trace ec65e906cd03afa6 ]--- [ 36.225017] bcache: bch_cached_dev_attach() Caching loop0 as bcache0 on set 57322d7a-1421-4dfc-a8cb-9c7b4e60c50a Without attach (last line in script): in a few seconds: $ sudo ./setup-bcache-wb_percent-before-attach.sh ... [ 30.623677] BUG: unable to handle kernel NULL pointer dereference at 0000000000000340 [ 30.627527] #PF error: [normal kernel read fault] [ 30.629825] PGD 0 P4D 0 [ 30.631194] Oops: 0000 [#1] SMP PTI ... [ 30.638818] Workqueue: events update_writeback_rate [bcache] [ 30.640543] RIP: 0010:update_writeback_rate+0x36/0x330 [bcache] ... [ 30.668496] Call Trace: [ 30.670003] ? __schedule+0x2d8/0x840 [ 30.671998] process_one_work+0x20f/0x410 [ 30.674163] worker_thread+0x34/0x400 [ 30.676160] kthread+0x120/0x140 [ 30.678014] ? process_one_work+0x410/0x410 [ 30.680238] ? __kthread_parkme+0x70/0x70 [ 30.682411] ret_from_fork+0x35/0x40 ... [ 30.704646] ---[ end trace 1bbc1b34c704f1c5 ]--- [ 30.707086] RIP: 0010:update_writeback_rate+0x36/0x330 [bcache] Test script: $ cat setup-bcache-wb_percent-before-attach.sh #!/bin/sh #set -ex dmesg -C echo 9 > /proc/sys/kernel/printk FILE_BACKING=/backing.img FILE_CACHING=/caching.img dd if=/dev/zero of=$FILE_BACKING bs=1G seek=1 count=0 dd if=/dev/zero of=$FILE_CACHING bs=1G seek=1 count=0 dd if=/dev/zero of=$FILE_BACKING bs=1M count=1 conv=notrunc dd if=/dev/zero of=$FILE_CACHING bs=1M count=1 conv=notrunc LOOP_BACKING=$(losetup -f --show $FILE_BACKING) LOOP_CACHING=$(losetup -f --show $FILE_CACHING) make-bcache -B $LOOP_BACKING make-bcache -C $LOOP_CACHING sleep 3 CSET_UUID=$(bcache-super-show $LOOP_CACHING | awk '/cset\.uuid/ { print $2 }') # Change writeback_percent before attaching echo 11 > /sys/block/$(basename $LOOP_BACKING)/bcache/writeback_percent sleep 1 # Comment this line to Oops in a few seconds echo $CSET_UUID > /sys/block/$(basename $LOOP_BACKING)/bcache/attach -- You received this bug notification because you are a member of Kernel Packages, which is subscribed to linux in Ubuntu. https://bugs.launchpad.net/bugs/1837788 Title: bcache kernel warning when attaching device Status in linux package in Ubuntu: Confirmed Bug description: See attached dmesg, each time this server is rebooted it emits a concerning bcache warning. ProblemType: Bug DistroRelease: Ubuntu 18.04 Package: linux-image-4.15.0-54-generic 4.15.0-54.58 ProcVersionSignature: Ubuntu 4.15.0-54.58-generic 4.15.18 Uname: Linux 4.15.0-54-generic x86_64 AlsaVersion: Advanced Linux Sound Architecture Driver Version k4.15.0-54-generic. AplayDevices: Error: [Errno 2] No such file or directory: 'aplay': 'aplay' ApportVersion: 2.20.9-0ubuntu7.7 Architecture: amd64 ArecordDevices: Error: [Errno 2] No such file or directory: 'arecord': 'arecord' AudioDevicesInUse: Error: command ['fuser', '-v', '/dev/snd/by-path', '/dev/snd/hwC0D2', '/dev/snd/pcmC0D2c', '/dev/snd/pcmC0D3c', '/dev/snd/pcmC0D3p', '/dev/snd/pcmC0D0c', '/dev/snd/pcmC0D0p', '/dev/snd/controlC0', '/dev/snd/hwC1D0', '/dev/snd/pcmC1D3p', '/dev/snd/controlC1', '/dev/snd/seq', '/dev/snd/timer'] failed with exit code 1: Card0.Amixer.info: Error: [Errno 2] No such file or directory: 'amixer': 'amixer' Card0.Amixer.values: Error: [Errno 2] No such file or directory: 'amixer': 'amixer' Card1.Amixer.info: Error: [Errno 2] No such file or directory: 'amixer': 'amixer' Card1.Amixer.values: Error: [Errno 2] No such file or directory: 'amixer': 'amixer' Date: Wed Jul 24 12:28:06 2019 InstallationDate: Installed on 2013-10-04 (2119 days ago) InstallationMedia: Ubuntu-Server 13.10 "Saucy Salamander" - Beta amd64 (20130925.1) MachineType: Supermicro X9DAi ProcEnviron: TERM=xterm-256color PATH=(custom, no user) XDG_RUNTIME_DIR=<set> LANG=en_US.UTF-8 SHELL=/bin/bash ProcFB: 0 EFI VGA ProcKernelCmdLine: BOOT_IMAGE=/vmlinuz-4.15.0-54-generic root=UUID=8577302d-1f37-40a6-afcd-385beb26059f ro nomodeset elevator=deadline nvme_core.default_ps_max_latency_us=0 nopti noibrs noibpb RelatedPackageVersions: linux-restricted-modules-4.15.0-54-generic N/A linux-backports-modules-4.15.0-54-generic N/A linux-firmware 1.173.9 RfKill: Error: [Errno 2] No such file or directory: 'rfkill': 'rfkill' SourcePackage: linux UpgradeStatus: Upgraded to bionic on 2018-06-09 (409 days ago) dmi.bios.date: 05/09/2015 dmi.bios.vendor: American Megatrends Inc. dmi.bios.version: 3.2 dmi.board.asset.tag: To be filled by O.E.M. dmi.board.name: X9DAi dmi.board.vendor: Supermicro dmi.board.version: 0123456789 dmi.chassis.asset.tag: To Be Filled By O.E.M. dmi.chassis.type: 3 dmi.chassis.vendor: Supermicro dmi.chassis.version: 0123456789 dmi.modalias: dmi:bvnAmericanMegatrendsInc.:bvr3.2:bd05/09/2015:svnSupermicro:pnX9DAi:pvr0123456789:rvnSupermicro:rnX9DAi:rvr0123456789:cvnSupermicro:ct3:cvr0123456789: dmi.product.family: To be filled by O.E.M. dmi.product.name: X9DAi dmi.product.version: 0123456789 dmi.sys.vendor: Supermicro To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1837788/+subscriptions -- Mailing list: https://launchpad.net/~kernel-packages Post to : kernel-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~kernel-packages More help : https://help.launchpad.net/ListHelp