drbd: Fixed race condition in drbd_queue_bitmap_io
authorPhilipp Reisner <philipp.reisner@linbit.com>
Tue, 16 Nov 2010 14:30:44 +0000 (15:30 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 10 Mar 2011 10:35:03 +0000 (11:35 +0100)
May only test for ap_bio_cnt == 0 under req_lock. It can increase
only under req_lock.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_main.c

index 843b909669200f8b17ad9b65b918a85a50fda416..975dc5a665499bd13e6b2a7e77721404d61ac55d 100644 (file)
@@ -3849,11 +3849,13 @@ void drbd_queue_bitmap_io(struct drbd_conf *mdev,
        mdev->bm_io_work.done = done;
        mdev->bm_io_work.why = why;
 
+       spin_lock_irq(&mdev->req_lock);
        set_bit(BITMAP_IO, &mdev->flags);
        if (atomic_read(&mdev->ap_bio_cnt) == 0) {
                if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags))
                        drbd_queue_work(&mdev->data.work, &mdev->bm_io_work.w);
        }
+       spin_unlock_irq(&mdev->req_lock);
 }
 
 /**