diff options
author | NeilBrown <neilb@suse.de> | 2013-07-21 22:57:21 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-04 04:50:54 -0400 |
commit | c1dadcc1086bbbac1b5eeb4d5e157c76f2d8dfba (patch) | |
tree | b9a49a01b861c0d999d233cec8bf3340e4e2b17b /drivers/md/raid5.h | |
parent | 8afb90da9f16abc5e577318544419bfcf3565391 (diff) |
md/raid5: fix interaction of 'replace' and 'recovery'.
commit f94c0b6658c7edea8bc19d13be321e3860a3fa54 upstream.
If a device in a RAID4/5/6 is being replaced while another is being
recovered, then the writes to the replacement device currently don't
happen, resulting in corruption when the replacement completes and the
new drive takes over.
This is because the replacement writes are only triggered when
's.replacing' is set and not when the similar 's.sync' is set (which
is the case during resync and recovery - it means all devices need to
be read).
So schedule those writes when s.replacing is set as well.
In this case we cannot use "STRIPE_INSYNC" to record that the
replacement has happened as that is needed for recording that any
parity calculation is complete. So introduce STRIPE_REPLACED to
record if the replacement has happened.
For safety we should also check that STRIPE_COMPUTE_RUN is not set.
This has a similar effect to the "s.locked == 0" test. The latter
ensure that now IO has been flagged but not started. The former
checks if any parity calculation has been flagged by not started.
We must wait for both of these to complete before triggering the
'replace'.
Add a similar test to the subsequent check for "are we finished yet".
This possibly isn't needed (is subsumed in the STRIPE_INSYNC test),
but it makes it more obvious that the REPLACE will happen before we
think we are finished.
Finally if a NeedReplace device is not UPTODATE then that is an
error. We really must trigger a warning.
This bug was introduced in commit 9a3e1101b827a59ac9036a672f5fa8d5279d0fe2
(md/raid5: detect and handle replacements during recovery.)
which introduced replacement for raid5.
That was in 3.3-rc3, so any stable kernel since then would benefit
from this fix.
Reported-by: qindehua <13691222965@163.com>
Tested-by: qindehua <qindehua@163.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/md/raid5.h')
-rw-r--r-- | drivers/md/raid5.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h index b0b663b119a8..70c49329ca9a 100644 --- a/drivers/md/raid5.h +++ b/drivers/md/raid5.h | |||
@@ -306,6 +306,7 @@ enum { | |||
306 | STRIPE_SYNC_REQUESTED, | 306 | STRIPE_SYNC_REQUESTED, |
307 | STRIPE_SYNCING, | 307 | STRIPE_SYNCING, |
308 | STRIPE_INSYNC, | 308 | STRIPE_INSYNC, |
309 | STRIPE_REPLACED, | ||
309 | STRIPE_PREREAD_ACTIVE, | 310 | STRIPE_PREREAD_ACTIVE, |
310 | STRIPE_DELAYED, | 311 | STRIPE_DELAYED, |
311 | STRIPE_DEGRADED, | 312 | STRIPE_DEGRADED, |