drbd: Hold a reference to ldev while doing meta-data IO
authorPhilipp Reisner <philipp.reisner@linbit.com>
Mon, 27 Jun 2011 10:23:33 +0000 (12:23 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Wed, 9 May 2012 08:31:11 +0000 (10:31 +0200)
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_actlog.c
drivers/block/drbd/drbd_worker.c

index 528342c82ba1a8dec903b4302820216abd6a2e31..3d7c2153daca1bc7b4bf756f5b896ad882da6d58 100644 (file)
@@ -118,6 +118,12 @@ static int _drbd_md_sync_page_io(struct drbd_conf *mdev,
        bio->bi_end_io = drbd_md_io_complete;
        bio->bi_rw = rw;
 
+       if (!get_ldev_if_state(mdev, D_ATTACHING)) {  /* Corresponding put_ldev in drbd_md_io_complete() */
+               dev_err(DEV, "ASSERT FAILED: get_ldev_if_state() == 1 in _drbd_md_sync_page_io()\n");
+               ok = 0;
+               goto out;
+       }
+
        bio_get(bio); /* one bio_put() is in the completion handler */
        atomic_inc(&mdev->md_io_in_use); /* drbd_md_put_buffer() is in the completion handler */
        if (drbd_insert_fault(mdev, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD))
index 6dcd9f6e78c81370e33b6749238824fc4e37ad75..933091ffefcac5c1234672fca45c6bbc533c1ba6 100644 (file)
@@ -81,6 +81,7 @@ void drbd_md_io_complete(struct bio *bio, int error)
        wake_up(&mdev->misc_wait);
        bio_put(bio);
        drbd_md_put_buffer(mdev);
+       put_ldev(mdev);
 }
 
 /* reads on behalf of the partner,