[110/111] md/raid1: delay reads that could overtake behind-writes.

Previous thread: [109/111] [SCSI] ibmvfc: Reduce error recovery timeout by Greg KH on Wednesday, August 11, 2010 - 4:55 pm. (1 message)

Next thread: [111/111] mm: fix corruption of hibernation caused by reusing swap during image saving by Greg KH on Wednesday, August 11, 2010 - 4:55 pm. (1 message)
From: Greg KH
Date: Wednesday, August 11, 2010 - 4:55 pm

2.6.32-stable review patch.  If anyone has any objections, please let us know.

------------------

From: NeilBrown <neilb@suse.de>

commit e555190d82c0f58e825e3cbd9e6ebe2e7ac713bd upstream.

When a raid1 array is configured to support write-behind
on some devices, it normally only reads from other devices.
If all devices are write-behind (because the rest have failed)
it is possible for a read request to be serviced before a
behind-write request, which would appear as data corruption.

So when forced to read from a WriteMostly device, wait for any
write-behind to complete, and don't start any more behind-writes.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


---
 drivers/md/bitmap.c |    4 +++-
 drivers/md/bitmap.h |    3 +++
 drivers/md/raid1.c  |   25 ++++++++++++++++++-------
 3 files changed, 24 insertions(+), 8 deletions(-)

--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1317,7 +1317,8 @@ void bitmap_endwrite(struct bitmap *bitm
 {
 	if (!bitmap) return;
 	if (behind) {
-		atomic_dec(&bitmap->behind_writes);
+		if (atomic_dec_and_test(&bitmap->behind_writes))
+			wake_up(&bitmap->behind_wait);
 		PRINTK(KERN_DEBUG "dec write-behind count %d/%d\n",
 		  atomic_read(&bitmap->behind_writes), bitmap->max_write_behind);
 	}
@@ -1629,6 +1630,7 @@ int bitmap_create(mddev_t *mddev)
 	atomic_set(&bitmap->pending_writes, 0);
 	init_waitqueue_head(&bitmap->write_wait);
 	init_waitqueue_head(&bitmap->overflow_wait);
+	init_waitqueue_head(&bitmap->behind_wait);
 
 	bitmap->mddev = mddev;
 
--- a/drivers/md/bitmap.h
+++ b/drivers/md/bitmap.h
@@ -254,6 +254,9 @@ struct bitmap {
 	wait_queue_head_t write_wait;
 	wait_queue_head_t overflow_wait;
 
+#ifndef __GENKSYMS__
+	wait_queue_head_t behind_wait;
+#endif
 };
 
 /* the bitmap API */
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -845,6 +845,15 @@ static int make_request(struct request_q
 		}
 		mirror = conf->mirrors + rdisk;
 
+		if ...
Previous thread: [109/111] [SCSI] ibmvfc: Reduce error recovery timeout by Greg KH on Wednesday, August 11, 2010 - 4:55 pm. (1 message)

Next thread: [111/111] mm: fix corruption of hibernation caused by reusing swap during image saving by Greg KH on Wednesday, August 11, 2010 - 4:55 pm. (1 message)