Tested with disco-proposed (problem exists) ----- # uname -rv 5.0.0-22-generic #23-Ubuntu SMP Tue Jul 23 17:23:54 UTC 2019 # ./setup-bcache-wb_percent-before-attach.sh >/dev/null 2>&1 [ 57.992319] bcache: register_bdev() registered backing device loop0/null 2>&1 [ 57.997331] bcache: run_cache_set() invalidating existing data [ 58.009201] bcache: register_cache() registered cache device loop1 [ 58.009232] bcache: register_bcache() error /dev/loop0: device already registered (emitting change event) [ 62.008954] WARNING: CPU: 2 PID: 1294 at drivers/md/bcache/writeback.c:837 bch_cached_dev_writeback_start+0x156/0x164 [bcache] [ 62.014280] Modules linked in: bcache crc64 isofs nls_iso8859_1 kvm_intel kvm irqbypass input_leds joydev serio_raw sch_fq_codel ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables x_tables autofs4 btrfs zstd_compress raid10 raid$ 56 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear psmouse virtio_blk virtio$ net net_failover failover floppy [ 62.027201] CPU: 2 PID: 1294 Comm: setup-bcache-wb Not tainted 5.0.0-22-generic #23-Ubuntu [ 62.029611] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 [ 62.032236] RIP: 0010:bch_cached_dev_writeback_start+0x156/0x164 [bcache] [ 62.034227] Code: 88 4c 0d 00 00 74 09 8b 83 e0 0c 00 00 5b 5d c3 48 8b 35 35 ee b6 e0 48 8d 93 08 0c 00 00 bf 00 20 00 00 e8 7c 81 3e d$ eb dd <0f> 0b e9 55 ff ff ff b8 f4 ff ff ff eb 8c 48 c7 c7 e0 e1 8c c0 e8 [ 62.039605] RSP: 0018:ffffae25012a3d38 EFLAGS: 00010207 [ 62.042135] RAX: ffff8ae1b1e915c0 RBX: ffff8ae1b20d0000 RCX: 0000000000000000 [ 62.045616] RDX: 0000000000000000 RSI: ffff8ae1b7b270a0 RDI: ffff8ae1b7403800 [ 62.049086] RBP: ffffae25012a3d40 R08: 00000000000270a0 R09: ffffffff9fcbc4cb [ 62.052583] R10: ffffd2e708ce0bc0 R11: 0000000000000001 R12: ffff8ae1b20d0010 [ 62.056077] R13: ffff8ae1b20d0000 R14: ffff8ae1b20d0c30 R15: ffff8ae1b2180000 [ 62.059568] FS: 00007f1d4770e540(0000) GS:ffff8ae1b7b00000(0000) knlGS:0000000000000000 [ 62.063629] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 62.066534] CR2: 0000557518fb58f0 CR3: 00000002333fa000 CR4: 00000000000006e0 [ 62.070048] Call Trace: [ 62.071530] bch_cached_dev_attach+0x356/0x480 [bcache] [ 62.074201] ? bch_keybuf_init+0x70/0x70 [bcache] [ 62.076666] __cached_dev_store+0x59f/0x8b0 [bcache] [ 62.079234] bch_cached_dev_store+0x39/0xc0 [bcache] [ 62.081786] sysfs_kf_write+0x3b/0x40 [ 62.083785] kernfs_fop_write+0x12e/0x1b0 [ 62.085921] __vfs_write+0x1b/0x40 [ 62.087809] vfs_write+0xab/0x1b0 [ 62.089649] ksys_write+0x5c/0xd0 [ 62.091497] __x64_sys_write+0x1a/0x20 [ 62.093520] do_syscall_64+0x5a/0x110 [ 62.095523] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 62.098106] RIP: 0033:0x7f1d4720e154 [ 62.100071] Code: 89 02 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 8d 05 b1 07 2e 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 f3 c3 66 90 41 54 55 49 89 d4 53 48 89 f5 [ 62.108931] RSP: 002b:00007ffddf05ed58 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 62.112761] RAX: ffffffffffffffda RBX: 0000557518fb37f0 RCX: 00007f1d4720e154 [ 62.116233] RDX: 0000000000000025 RSI: 0000557518fb37f0 RDI: 0000000000000001 [ 62.119751] RBP: 0000000000000025 R08: 000000000000f000 R09: 0000557518fb594d [ 62.123233] R10: 00000000000001b6 R11: 0000000000000246 R12: 0000000000000001 [ 62.126711] R13: 0000000000000025 R14: 7fffffffffffffff R15: 00007ffddf060f39 [ 62.130191] ---[ end trace c47ed79da668a296 ]--- [ 62.135336] bcache: bch_cached_dev_attach() Caching loop0 as bcache0 on set 7abc55ca-0c2d-44bb-ae1e-dd51a6028769 # reboot # # comment last line in script. # ./setup-bcache-wb_percent-before-attach.sh >/dev/null 2>&1 # [ 30.327906] bcache: register_bdev() registered backing device loop0 [ 30.397705] bcache: run_cache_set() invalidating existing data [ 30.409402] bcache: register_cache() registered cache device loop1 (wait a few seconds) [ 38.603598] BUG: unable to handle kernel NULL pointer dereference at 0000000000000340 [ 38.607376] #PF error: [normal kernel read fault] [ 38.609705] PGD 0 P4D 0 [ 38.611045] Oops: 0000 [#1] SMP PTI [ 38.612835] CPU: 2 PID: 53 Comm: kworker/2:1 Not tainted 5.0.0-22-generic #23-Ubuntu [ 38.616264] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 [ 38.618928] Workqueue: events update_writeback_rate [bcache] [ 38.620658] RIP: 0010:update_writeback_rate+0x36/0x330 [bcache] [ 38.622436] Code: 56 41 55 41 54 53 48 83 ec 08 4c 8b af 10 f4 ff ff f0 80 8f 30 f4 ff ff 10 f0 83 44 24 fc 00 48 8b 87 30 f4 ff ff a8 0$ 74 59 <49> 8b 85 40 03 00 00 48 c1 e8 03 83 e0 01 49 89 c4 75 46 8b 47 e8 [ 38.627822] RSP: 0018:ffffb6fac0e23e50 EFLAGS: 00010202 [ 38.629401] RAX: 0000000000000018 RBX: ffff9fb637b22700 RCX: ffff9fb637b22720 [ 38.631481] RDX: 0000000000000001 RSI: ffff9fb63740aeb0 RDI: ffff9fb632120c70 [ 38.633587] RBP: ffffb6fac0e23e80 R08: 0000000000000000 R09: 000073746e657665 [ 38.635792] R10: 8080808080808080 R11: 00000008e9a3614c R12: ffff9fb637b27700 [ 38.637995] R13: 0000000000000000 R14: ffff9fb632120c70 R15: 0ffff9fb637b2770 [ 38.640215] FS: 0000000000000000(0000) GS:ffff9fb637b00000(0000) knlGS:0000000000000000 [ 38.642770] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 38.644586] CR2: 0000000000000340 CR3: 0000000234358000 CR4: 00000000000006e0 [ 38.646768] Call Trace: [ 38.647705] ? __schedule+0x2d8/0x840 [ 38.648961] process_one_work+0x20f/0x410 [ 38.650297] worker_thread+0x34/0x400 [ 38.651539] kthread+0x120/0x140 [ 38.652670] ? process_one_work+0x410/0x410 [ 38.654051] ? __kthread_parkme+0x70/0x70 [ 38.655386] ret_from_fork+0x35/0x40 [ 38.656617] Modules linked in: bcache crc64 isofs nls_iso8859_1 kvm_intel kvm irqbypass input_leds joydev serio_raw sch_fq_codel ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables x_tables autofs4 btrfs zstd_compress raid10 raid4 56 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear psmouse virtio_net floppy virtio_blk net_failover failover [ 38.668111] CR2: 0000000000000340 [ 38.669245] ---[ end trace 583df0fb8c5b15fe ]--- [ 38.670752] RIP: 0010:update_writeback_rate+0x36/0x330 [bcache] [ 38.672617] Code: 56 41 55 41 54 53 48 83 ec 08 4c 8b af 10 f4 ff ff f0 80 8f 30 f4 ff ff 10 f0 83 44 24 fc 00 48 8b 87 30 f4 ff ff a8 08 74 59 <49> 8b 85 40 03 00 00 48 c1 e8 03 83 e0 01 49 89 c4 75 46 8b 47 e8 [ 38.678121] RSP: 0018:ffffb6fac0e23e50 EFLAGS: 00010202 [ 38.679761] RAX: 0000000000000018 RBX: ffff9fb637b22700 RCX: ffff9fb637b22720 [ 38.683382] RDX: 0000000000000001 RSI: ffff9fb63740aeb0 RDI: ffff9fb632120c70 [ 38.686852] RBP: ffffb6fac0e23e80 R08: 0000000000000000 R09: 000073746e657665 [ 38.690348] R10: 8080808080808080 R11: 00000008e9a3614c R12: ffff9fb637b27700 [ 38.693839] R13: 0000000000000000 R14: ffff9fb632120c70 R15: 0ffff9fb637b2770 [ 38.697305] FS: 0000000000000000(0000) GS:ffff9fb637b00000(0000) knlGS:0000000000000000 [ 38.701376] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 38.704236] CR2: 0000000000000340 CR3: 0000000234358000 CR4: 00000000000006e0