Comment 15 for bug 1829563

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

I/O Error Test 5
================

commit "bcache: stop bcache device when backing device is offline"

Problem: bcache is unaware that a backing device goes offline,
and accepts writes.

Original kernel: bcache doesn't realize backing device is offline.
Modified kernel: bcache device is removed after backing device is offline.

Original
--------

# uname -rv
4.15.0-55-generic #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019

# apt install -y linux-modules-extra-$(uname -r)=4.15.0-55.60

# modprobe scsi_debug dev_size_mb=1024
# dmesg | tail
[ 17.339336] scsi host2: scsi_debug: version 1.86 [20160430]
                 dev_size_mb=1024, opts=0x0, submit_queues=1, statistics=0
[ 17.339667] scsi 2:0:0:0: Direct-Access Linux scsi_debug 0186 PQ: 0 ANSI: 7
[ 17.339989] sd 2:0:0:0: Power-on or device reset occurred
[ 17.340184] sd 2:0:0:0: Attached scsi generic sg0 type 0
[ 17.348436] sd 2:0:0:0: [sda] 2097152 512-byte logical blocks: (1.07 GB/1.00 GiB)
[ 17.352496] sd 2:0:0:0: [sda] Write Protect is off
[ 17.352501] sd 2:0:0:0: [sda] Mode Sense: 73 00 10 08
[ 17.360686] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
[ 17.451956] sd 2:0:0:0: [sda] Attached SCSI disk

# ./setup-sda.sh >/dev/null 2>&1
[ 37.515474] bcache: run_cache_set() invalidating existing data
[ 37.527275] bcache: register_cache() registered cache device dm-0
[ 37.625160] bcache: register_bdev() registered backing device sda
[ 38.466997] bcache: bch_cached_dev_attach() Caching sda as bcache0 on set 0e23e266-6032-4700-a4c9-464964ed1349

# lsblk -e 252
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 1G 0 loop
└─fake-loop0 253:0 0 1024M 0 dm
  └─bcache0 251:0 0 1024M 0 disk
sda 8:0 0 1G 0 disk
└─bcache0 251:0 0 1024M 0 disk

# echo writeback > /sys/block/sda/bcache/cache_mode

# echo 1 > /sys/block/sda/device/delete
[ 77.878624] sd 2:0:0:0: [sda] Synchronizing SCSI cache

# sleep 10
#

# dd if=/dev/zero of=/dev/bcache0 bs=4k
[ 120.268072] Buffer I/O error on dev bcache0, logical block 0, lost async page write
[ 120.271978] Buffer I/O error on dev bcache0, logical block 1, lost async page write
[ 120.274554] Buffer I/O error on dev bcache0, logical block 2, lost async page write
[ 120.276671] Buffer I/O error on dev bcache0, logical block 3, lost async page write
[ 120.278760] Buffer I/O error on dev bcache0, logical block 4, lost async page write
[ 120.288042] Buffer I/O error on dev bcache0, logical block 5, lost async page write
[ 120.290178] Buffer I/O error on dev bcache0, logical block 6, lost async page write
[ 120.296043] Buffer I/O error on dev bcache0, logical block 7, lost async page write
[ 120.298167] Buffer I/O error on dev bcache0, logical block 8, lost async page write
[ 120.300220] Buffer I/O error on dev bcache0, logical block 3260, lost async page write
dd: error writing '/dev/bcache0': No space left on device
262143+0 records in
262142+0 records out
1073733632 bytes (1.1 GB, 1.0 GiB) copied, 3.49705 s, 307 MB/s

# lsblk -e 252
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 1G 0 loop
└─fake-loop0 253:0 0 1024M 0 dm
  └─bcache0 251:0 0 1024M 0 disk

Modified
--------

# uname -rv
4.15.0-55-generic #60+test20190703build1bcache1-Ubuntu SMP Wed Jul 3 21:41:37 UTC

# modprobe scsi_debug dev_size_mb=1024
# dmesg | tail
[ 27.855163] scsi host2: scsi_debug: version 1.86 [20160430]
                 dev_size_mb=1024, opts=0x0, submit_queues=1, statistics=0
[ 27.855497] scsi 2:0:0:0: Direct-Access Linux scsi_debug 0186 PQ: 0 ANSI: 7
[ 27.855829] sd 2:0:0:0: Power-on or device reset occurred
[ 27.855883] sd 2:0:0:0: Attached scsi generic sg0 type 0
[ 27.863979] sd 2:0:0:0: [sda] 2097152 512-byte logical blocks: (1.07 GB/1.00 GiB)
[ 27.868028] sd 2:0:0:0: [sda] Write Protect is off
[ 27.868031] sd 2:0:0:0: [sda] Mode Sense: 73 00 10 08
[ 27.876114] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
[ 27.966877] sd 2:0:0:0: [sda] Attached SCSI disk
#

# ./setup-sda.sh >/dev/null 2>&1
[ 46.294586] bcache: run_cache_set() invalidating existing data
[ 46.306769] bcache: register_cache() registered cache device dm-0
[ 46.400510] bcache: register_bdev() registered backing device sda
[ 47.247662] bcache: bch_cached_dev_attach() Caching sda as bcache0 on set d3d7816b-6bd9-4dea-bf0c-4bde76b45f91

# lsblk -e 252
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 1G 0 loop
└─fake-loop0 253:0 0 1024M 0 dm
  └─bcache0 251:0 0 1024M 0 disk
sda 8:0 0 1G 0 disk
└─bcache0 251:0 0 1024M 0 disk

# echo writeback > /sys/block/sda/bcache/cache_mode

# echo 1 > /sys/block/sda/device/delete
[ 85.713826] sd 2:0:0:0: [sda] Synchronizing SCSI cache

# sleep 10
[ 90.428125] bcache: cached_dev_status_update() sda: device offline for 5 seconds
[ 90.431495] bcache: cached_dev_status_update() bdev0: disable I/O request due to backing device offline
[ 90.435591] bcache: bcache_device_free() bcache0 stopped
#

# lsblk -e 252
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 1G 0 loop
└─fake-loop0 253:0 0 1024M 0 dm

# ls /dev/bcache0
ls: cannot access '/dev/bcache0': No such file or directory