diff options
author | NeilBrown <neilb@suse.de> | 2010-03-30 20:21:44 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-05-18 01:27:57 -0400 |
commit | e555190d82c0f58e825e3cbd9e6ebe2e7ac713bd (patch) | |
tree | ea9c8e548c4d5eb5fc903bab05af3bda4192ed00 /drivers/md/bitmap.c | |
parent | d754c5ae1ff76b20d3ecde8ad666d7865eada8ae (diff) |
md/raid1: delay reads that could overtake behind-writes.
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>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 49d6080387c8..c9c6a345e17b 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -1356,7 +1356,8 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto | |||
1356 | { | 1356 | { |
1357 | if (!bitmap) return; | 1357 | if (!bitmap) return; |
1358 | if (behind) { | 1358 | if (behind) { |
1359 | atomic_dec(&bitmap->behind_writes); | 1359 | if (atomic_dec_and_test(&bitmap->behind_writes)) |
1360 | wake_up(&bitmap->behind_wait); | ||
1360 | PRINTK(KERN_DEBUG "dec write-behind count %d/%d\n", | 1361 | PRINTK(KERN_DEBUG "dec write-behind count %d/%d\n", |
1361 | atomic_read(&bitmap->behind_writes), bitmap->max_write_behind); | 1362 | atomic_read(&bitmap->behind_writes), bitmap->max_write_behind); |
1362 | } | 1363 | } |
@@ -1680,6 +1681,7 @@ int bitmap_create(mddev_t *mddev) | |||
1680 | atomic_set(&bitmap->pending_writes, 0); | 1681 | atomic_set(&bitmap->pending_writes, 0); |
1681 | init_waitqueue_head(&bitmap->write_wait); | 1682 | init_waitqueue_head(&bitmap->write_wait); |
1682 | init_waitqueue_head(&bitmap->overflow_wait); | 1683 | init_waitqueue_head(&bitmap->overflow_wait); |
1684 | init_waitqueue_head(&bitmap->behind_wait); | ||
1683 | 1685 | ||
1684 | bitmap->mddev = mddev; | 1686 | bitmap->mddev = mddev; |
1685 | 1687 | ||