drbd: Fix for a race between IO and a detach operation [Bugz 262]
authorPhilipp Reisner <philipp.reisner@linbit.com>
Mon, 28 Dec 2009 15:58:38 +0000 (16:58 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Tue, 29 Dec 2009 16:36:40 +0000 (17:36 +0100)
In D_DISKLESS we do not hand out any new references to ldev (local_cnt)
therefore waiting until all previously handed out refereces got returned
is sufficient before actually freeing mdev->ldev.

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 9348f33f6242e9088f7094ea836d7b0d19e24f0f..e898ad9eb1c3e1e77b64e374efb16f78649c54e3 100644 (file)
@@ -1298,6 +1298,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
                                dev_err(DEV, "Sending state in drbd_io_error() failed\n");
                }
 
+               wait_event(mdev->misc_wait, !atomic_read(&mdev->local_cnt));
                lc_destroy(mdev->resync);
                mdev->resync = NULL;
                lc_destroy(mdev->act_log);