WSL2-Linux-Kernel/drivers/md/bcache
Tang Junhui 73ac105be3 bcache: fix for data collapse after re-attaching an attached device
back-end device sdm has already attached a cache_set with ID
f67ebe1f-f8bc-4d73-bfe5-9dc88607f119, then try to attach with
another cache set, and it returns with an error:
[root]# cd /sys/block/sdm/bcache
[root]# echo 5ccd0a63-148e-48b8-afa2-aca9cbd6279f > attach
-bash: echo: write error: Invalid argument

After that, execute a command to modify the label of bcache
device:
[root]# echo data_disk1 > label

Then we reboot the system, when the system power on, the back-end
device can not attach to cache_set, a messages show in the log:
Feb  5 12:05:52 ceph152 kernel: [922385.508498] bcache:
bch_cached_dev_attach() couldn't find uuid for sdm in set

In sysfs_attach(), dc->sb.set_uuid was assigned to the value
which input through sysfs, no matter whether it is success
or not in bch_cached_dev_attach(). For example, If the back-end
device has already attached to an cache set, bch_cached_dev_attach()
would fail, but dc->sb.set_uuid was changed. Then modify the
label of bcache device, it will call bch_write_bdev_super(),
which would write the dc->sb.set_uuid to the super block, so we
record a wrong cache set ID in the super block, after the system
reboot, the cache set couldn't find the uuid of the back-end
device, so the bcache device couldn't exist and use any more.

In this patch, we don't assigned cache set ID to dc->sb.set_uuid
in sysfs_attach() directly, but input it into bch_cached_dev_attach(),
and assigned dc->sb.set_uuid to the cache set ID after the back-end
device attached to the cache set successful.

Signed-off-by: Tang Junhui <tang.junhui@zte.com.cn>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-02-07 12:50:01 -07:00
..
Kconfig bcache: Kill dead cgroup code 2014-03-18 12:22:35 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
alloc.c bcache: properly set task state in bch_writeback_thread() 2018-02-07 12:50:01 -07:00
bcache.h bcache: fix for data collapse after re-attaching an attached device 2018-02-07 12:50:01 -07:00
bset.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bset.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
btree.c bcache: fix for allocator and register thread race 2018-02-07 12:50:01 -07:00
btree.h Merge branch 'for-4.15/block' of git://git.kernel.dk/linux-block 2017-11-14 15:32:19 -08:00
closure.c bcache: mark closure_sync() __sched 2018-01-08 13:29:00 -07:00
closure.h bcache: closures: move control bits one bit right 2018-01-09 12:18:51 -07:00
debug.c bcache: fix wrong return value in bch_debug_init() 2018-01-08 13:29:00 -07:00
debug.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
extents.c bcache: Fix building error on MIPS 2017-11-24 16:22:58 -07:00
extents.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
io.c bcache: fix misleading error message in bch_count_io_errors() 2018-01-08 13:29:00 -07:00
journal.c bcache: fix high CPU occupancy during journal 2018-02-07 12:50:01 -07:00
journal.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
movinggc.c block: move bio_alloc_pages() to bcache 2018-01-06 09:18:00 -07:00
request.c bcache: fix unmatched generic_end_io_acct() & generic_start_io_acct() 2018-01-08 13:29:00 -07:00
request.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
stats.c md: Convert timers to use timer_setup() 2017-11-14 20:11:57 -07:00
stats.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
super.c bcache: fix for data collapse after re-attaching an attached device 2018-02-07 12:50:01 -07:00
sysfs.c bcache: fix for data collapse after re-attaching an attached device 2018-02-07 12:50:01 -07:00
sysfs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
util.c block: move bio_alloc_pages() to bcache 2018-01-06 09:18:00 -07:00
util.h bcache: fix high CPU occupancy during journal 2018-02-07 12:50:01 -07:00
writeback.c bcache: set writeback_rate_update_seconds in range [1, 60] seconds 2018-02-07 12:50:01 -07:00
writeback.h bcache: set writeback_rate_update_seconds in range [1, 60] seconds 2018-02-07 12:50:01 -07:00