浏览代码

md/raid1: fix counting of write targets.

There is a very small race window when writing to a
RAID1 such that if a device is marked faulty at exactly the wrong
time, the write-in-progress will not be sent to the device,
but the bitmap (if present) will be updated to say that
the write was sent.

Then if the device turned out to still be usable as was re-added
to the array, the bitmap-based-resync would skip resyncing that
block, possibly leading to corruption.  This would only be a problem
if no further writes were issued to that area of the device (i.e.
that bitmap chunk).

Suitable for any pending -stable kernel.

Cc: stable@kernel.org
Signed-off-by: NeilBrown <neilb@suse.de>
NeilBrown 15 年之前
父节点
当前提交
964147d5c8
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      drivers/md/raid1.c

+ 3 - 2
drivers/md/raid1.c

@@ -911,9 +911,10 @@ static int make_request(struct request_queue *q, struct bio * bio)
 			if (test_bit(Faulty, &rdev->flags)) {
 			if (test_bit(Faulty, &rdev->flags)) {
 				rdev_dec_pending(rdev, mddev);
 				rdev_dec_pending(rdev, mddev);
 				r1_bio->bios[i] = NULL;
 				r1_bio->bios[i] = NULL;
-			} else
+			} else {
 				r1_bio->bios[i] = bio;
 				r1_bio->bios[i] = bio;
-			targets++;
+				targets++;
+			}
 		} else
 		} else
 			r1_bio->bios[i] = NULL;
 			r1_bio->bios[i] = NULL;
 	}
 	}