]> Pileus Git - ~andy/linux/blobdiff - drivers/md/bitmap.c
md/raid1: delay reads that could overtake behind-writes.
[~andy/linux] / drivers / md / bitmap.c
index 49d6080387c8877c4a9e308ffced15cc5c752384..c9c6a345e17bbb674239a8d39ce7748fb0fc2d49 100644 (file)
@@ -1356,7 +1356,8 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
 {
        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);
        }
@@ -1680,6 +1681,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;