From: NeilBrown Date: Fri, 31 Mar 2006 10:31:57 +0000 (-0800) Subject: [PATCH] md: Don't clear bits in bitmap when writing to one device fails during recovery X-Git-Tag: v3.12-rc1~36858 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b1117d50543e2484bee037ec2589fe52492a7e7;p=kernel%2Fkernel-generic.git [PATCH] md: Don't clear bits in bitmap when writing to one device fails during recovery Currently a device failure during recovery leaves bits set in the bitmap. This normally isn't a problem as the offending device will be rejected because of errors. However if device re-adding is being used with non-persistent bitmaps, this can be a problem. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 3cb0872..9b374c9 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1135,8 +1135,19 @@ static int end_sync_write(struct bio *bio, unsigned int bytes_done, int error) mirror = i; break; } - if (!uptodate) + if (!uptodate) { + int sync_blocks = 0; + sector_t s = r1_bio->sector; + long sectors_to_go = r1_bio->sectors; + /* make sure these bits doesn't get cleared. */ + do { + bitmap_end_sync(mddev->bitmap, r1_bio->sector, + &sync_blocks, 1); + s += sync_blocks; + sectors_to_go -= sync_blocks; + } while (sectors_to_go > 0); md_error(mddev, conf->mirrors[mirror].rdev); + } update_head_pos(mirror, r1_bio);