md/raid10: don't clear bitmap during recovery if array will still be degraded.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Thursday, May 7, 2009 - 12:59 pm

Gitweb:     http://git.kernel.org/linus/18055569127253755d01733f6ecc004ed02f88d0
Commit:     18055569127253755d01733f6ecc004ed02f88d0
Parent:     b74fd2826c5acce20e6f691437b2d19372bc2057
Author:     NeilBrown <neilb@suse.de>
AuthorDate: Thu May 7 12:48:10 2009 +1000
Committer:  NeilBrown <neilb@suse.de>
CommitDate: Thu May 7 12:48:10 2009 +1000

    md/raid10: don't clear bitmap during recovery if array will still be degraded.
    
    If we have a raid10 with multiple missing devices, and we recover just
    one of these to a spare, then we risk (depending on the bitmap and
    array chunk size) clearing bits of the bitmap for which recovery isn't
    complete (because a device is still missing).
    
    This can lead to a subsequent "re-add" being recovered without
    any IO happening, which would result in loss of data.
    
    This patch takes the safe approach of not clearing bitmap bits
    if the array will still be degraded.
    
    This patch is suitable for all active -stable kernels.
    
    Cc: stable@kernel.org
    Signed-off-by: NeilBrown <neilb@suse.de>
---
 drivers/md/raid10.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 81a54f1..499620a 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1809,17 +1809,17 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
 				r10_bio->sector = sect;
 
 				raid10_find_phys(conf, r10_bio);
-				/* Need to check if this section will still be
+
+				/* Need to check if the array will still be
 				 * degraded
 				 */
-				for (j=0; j<conf->copies;j++) {
-					int d = r10_bio->devs[j].devnum;
-					if (conf->mirrors[d].rdev == NULL ||
-					    test_bit(Faulty, &conf->mirrors[d].rdev->flags)) {
+				for (j=0; j<conf->raid_disks; j++)
+					if (conf->mirrors[j].rdev == NULL ||
+					    test_bit(Faulty, &conf->mirrors[j].rdev->flags)) {
 						still_degraded = 1;
 						break;
 					}
-				}
+
 				must_sync = bitmap_start_sync(mddev->bitmap, sect,
 							      &sync_blocks, still_degraded);
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
md/raid10: don't clear bitmap during recovery if array wil ..., Linux Kernel Mailing ..., (Thu May 7, 12:59 pm)