diff mbox

[3.13.y.z,extended,stable] Patch "md/raid1: Don't use next_resync to determine how far resync has progressed" has been added to staging queue

Message ID 1412887904-22205-1-git-send-email-kamal@canonical.com
State New
Headers show

Commit Message

Kamal Mostafa Oct. 9, 2014, 8:51 p.m. UTC
This is a note to let you know that I have just added a patch titled

    md/raid1: Don't use next_resync to determine how far resync has progressed

to the linux-3.13.y-queue branch of the 3.13.y.z extended stable tree 
which can be found at:

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.13.y-queue

This patch is scheduled to be released in version 3.13.11.9.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.13.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

From 0e4db0f695bec63154c48d6768911ef2521ba975 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Wed, 10 Sep 2014 15:56:57 +1000
Subject: md/raid1: Don't use next_resync to determine how far resync has
 progressed

commit 235549605eb7f1c5a37cef8b09d12e6d412c5cd6 upstream.

next_resync is (approximately) the location for the next resync request.
However it does *not* reliably determine the earliest location
at which resync might be happening.
This is because resync requests can complete out of order, and
we only limit the number of current requests, not the distance
from the earliest pending request to the latest.

mddev->curr_resync_completed is a reliable indicator of the earliest
position at which resync could be happening.   It is updated less
frequently, but is actually reliable which is more important.

So use it to determine if a write request is before the region
being resynced and so safe from conflict.

This error can allow resync IO to interfere with normal IO which
could lead to data corruption. Hence: stable.

Fixes: 79ef3a8aa1cb1523cc231c9a90a278333c21f761
Signed-off-by: NeilBrown <neilb@suse.de>
[ kamal: backport to 3.13-stable: no bi_iter struct ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/md/raid1.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

--
1.9.1
diff mbox

Patch

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index c85ac43..11d0bd8 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -877,12 +877,10 @@  static bool need_to_wait_for_sync(struct r1conf *conf, struct bio *bio)
 	if (conf->array_frozen || !bio)
 		wait = true;
 	else if (conf->barrier && bio_data_dir(bio) == WRITE) {
-		if (conf->next_resync < RESYNC_WINDOW_SECTORS)
-			wait = true;
-		else if ((conf->next_resync - RESYNC_WINDOW_SECTORS
-				>= bio_end_sector(bio)) ||
-			 (conf->next_resync + NEXT_NORMALIO_DISTANCE
-				<= bio->bi_sector))
+		if ((conf->mddev->curr_resync_completed
+		     >= bio_end_sector(bio)) ||
+		    (conf->next_resync + NEXT_NORMALIO_DISTANCE
+		     <= bio->bi_sector))
 			wait = false;
 		else
 			wait = true;
@@ -920,7 +918,7 @@  static sector_t wait_barrier(struct r1conf *conf, struct bio *bio)

 	if (bio && bio_data_dir(bio) == WRITE) {
 		if (bio->bi_sector >=
-		    conf->next_resync) {
+		    conf->mddev->curr_resync_completed) {
 			if (conf->start_next_window == MaxSector)
 				conf->start_next_window =
 					conf->next_resync +