From b2057629ea96c33e4ae38102ecd0f27ed9a3c3ef Mon Sep 17 00:00:00 2001 From: Philipp Reisner Date: Mon, 27 Jun 2011 12:23:33 +0200 Subject: [PATCH] drbd: Hold a reference to ldev while doing meta-data IO Signed-off-by: Philipp Reisner Signed-off-by: Lars Ellenberg --- drivers/block/drbd/drbd_actlog.c | 6 ++++++ drivers/block/drbd/drbd_worker.c | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c index 528342c82ba1..3d7c2153daca 100644 --- a/drivers/block/drbd/drbd_actlog.c +++ b/drivers/block/drbd/drbd_actlog.c @@ -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)) diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index 6dcd9f6e78c8..933091ffefca 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c @@ -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, -- 2.30.2