]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
md/raid1: avoid reusing a resync bio after error handling.
authorNeilBrown <neilb@suse.com>
Thu, 6 Apr 2017 02:06:37 +0000 (12:06 +1000)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 20 Jun 2017 08:50:45 +0000 (10:50 +0200)
commit6e05fc2a3492186319efbed32c58a19777877b5a
tree755f34dc7a1b4854bf10a006cba2963c86dda5bb
parentce319ecec54961471c0e1abb6334f2adc9232b50
md/raid1: avoid reusing a resync bio after error handling.

BugLink: http://bugs.launchpad.net/bugs/1692898
commit 0c9d5b127f695818c2c5a3868c1f28ca2969e905 upstream.

fix_sync_read_error() modifies a bio on a newly faulty
device by setting bi_end_io to end_sync_write.
This ensure that put_buf() will still call rdev_dec_pending()
as required, but makes sure that subsequent code in
fix_sync_read_error() doesn't try to read from the device.

Unfortunately this interacts badly with sync_request_write()
which assumes that any bio with bi_end_io set to non-NULL
other than end_sync_read is safe to write to.

As the device is now faulty it doesn't make sense to write.
As the bio was recently used for a read, it is "dirty"
and not suitable for immediate submission.
In particular, ->bi_next might be non-NULL, which will cause
generic_make_request() to complain.

Break this interaction by refusing to write to devices
which are marked as Faulty.

Reported-and-tested-by: Michael Wang <yun.wang@profitbricks.com>
Fixes: 2e52d449bcec ("md/raid1: add failfast handling for reads.")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/md/raid1.c