summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2014-01-16 09:35:38 +1100
committerBen Hutchings <ben@decadent.org.uk>2014-04-02 00:58:43 +0100
commitadce73dfdacf706d8e3c389518ff24464965e4f1 (patch)
tree02073a957745d4351748c1bde7cd4db3155486ac
parent7a9175abf3816d07fc8b87d74f3b4e4f19728f69 (diff)
downloadlwn-adce73dfdacf706d8e3c389518ff24464965e4f1.tar.gz
lwn-adce73dfdacf706d8e3c389518ff24464965e4f1.zip
md/raid5: fix long-standing problem with bitmap handling on write failure.
commit 9f97e4b128d2ea90a5f5063ea0ee3b0911f4c669 upstream. Before a write starts we set a bit in the write-intent bitmap. When the write completes we clear that bit if the write was successful to all devices. However if the write wasn't fully successful we should not clear the bit. If the faulty drive is subsequently re-added, the fact that the bit is still set ensure that we will re-write the data that is missing. This logic is mediated by the STRIPE_DEGRADED flag - we only clear the bitmap bit when this flag is not set. Currently we correctly set the flag if a write starts when some devices are failed or missing. But we do *not* set the flag if some device failed during the write attempt. This is wrong and can result in clearing the bit inappropriately. So: set the flag when a write fails. This bug has been present since bitmaps were introduces, so the fix is suitable for any -stable kernel. Reported-by: Ethan Wilson <ethan.wilson@shiftmail.org> Signed-off-by: NeilBrown <neilb@suse.de> [bwh: Backported to 3.2: adjust context, indentation] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--drivers/md/raid5.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index fb678330aaa7..c7109c8f2221 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1693,6 +1693,7 @@ static void raid5_end_write_request(struct bio *bi, int error)
}
if (!uptodate) {
+ set_bit(STRIPE_DEGRADED, &sh->state);
set_bit(WriteErrorSeen, &conf->disks[i].rdev->flags);
set_bit(R5_WriteError, &sh->dev[i].flags);
} else if (is_badblock(conf->disks[i].rdev, sh->sector, STRIPE_SECTORS,