]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
bcache: add stop_when_cache_set_failed option to backing device
authorColy Li <colyli@suse.de>
Mon, 8 Jul 2019 00:50:00 +0000 (02:50 +0200)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:59:41 +0000 (19:59 -0600)
commit35c5e3c8b734382cf46a06d0d2d8179ce5c2cdbb
tree1caf4301258142e3f238457f4412ab52bb6c6681
parentbc2e6da150fad42bd012c592f814d33974eff64d
bcache: add stop_when_cache_set_failed option to backing device

BugLink: https://bugs.launchpad.net/bugs/1829563
When there are too many I/O errors on cache device, current bcache code
will retire the whole cache set, and detach all bcache devices. But the
detached bcache devices are not stopped, which is problematic when bcache
is in writeback mode.

If the retired cache set has dirty data of backing devices, continue
writing to bcache device will write to backing device directly. If the
LBA of write request has a dirty version cached on cache device, next time
when the cache device is re-registered and backing device re-attached to
it again, the stale dirty data on cache device will be written to backing
device, and overwrite latest directly written data. This situation causes
a quite data corruption.

But we cannot simply stop all attached bcache devices when the cache set is
broken or disconnected. For example, use bcache to accelerate performance
of an email service. In such workload, if cache device is broken but no
dirty data lost, keep the bcache device alive and permit email service
continue to access user data might be a better solution for the cache
device failure.

Nix <nix@esperi.org.uk> points out the issue and provides the above example
to explain why it might be necessary to not stop bcache device for broken
cache device. Pavel Goran <via-bcache@pvgoran.name> provides a brilliant
suggestion to provide "always" and "auto" options to per-cached device
sysfs file stop_when_cache_set_failed. If cache set is retiring and the
backing device has no dirty data on cache, it should be safe to keep the
bcache device alive. In this case, if stop_when_cache_set_failed is set to
"auto", the device failure handling code will not stop this bcache device
and permit application to access the backing device with a unattached
bcache device.

Changelog:
[mlyle: edited to not break string constants across lines]
v3: fix typos pointed out by Nix.
v2: change option values of stop_when_cache_set_failed from 1/0 to
    "auto"/"always".
v1: initial version, stop_when_cache_set_failed can be 0 (not stop) or 1
    (always stop).

Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Signed-off-by: Michael Lyle <mlyle@lyle.org>
Cc: Nix <nix@esperi.org.uk>
Cc: Pavel Goran <via-bcache@pvgoran.name>
Cc: Junhui Tang <tang.junhui@zte.com.cn>
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(backported from commit 7e027ca4b534b6b99a7c0471e13ba075ffa3f482)
[ mfo: backport: super.c, hunk 3: in __cache_set_unregister(),
  s/c->devices_max_used/c->nr_uuids/ due to lack of non-required
  upstream commit 2831231d4c3f ("bcache: reduce cache_set devices
  iteration by devices_max_used"), which is just an optimization,
  not a fix for index range, and requires one more Fixes: commit.]
Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Acked-by: Andrea Righi <andrea.righi@canonical.com>
Acked-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/md/bcache/bcache.h
drivers/md/bcache/super.c
drivers/md/bcache/sysfs.c