drbd: Fixed a deadlock, probably only affected UP machines
authorPhilipp Reisner <philipp.reisner@linbit.com>
Wed, 23 Jun 2010 09:20:05 +0000 (11:20 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 14 Oct 2010 13:04:46 +0000 (15:04 +0200)
After disconnect (most likely mdev->net_cnt == 0) and we are
still in an unstable state (!drbd_state_is_stable()). When we
get an IO request in drbd_get_max_buffers() (called from
__inc_ap_bio_cond(), called from inc_ap_bio()) we wake up
misc_wait. Misc_wait is also used in inc_ap_bio() to sleep
until the outcome of __inc_ap_bio_cond() changes. => Busy loop!

Solution: Have a dedicated wait queue for get_net_conf() and
put_net_conf().

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

index e0e08f5e0a76183e95e26d6694a7b963a47350ec..aa9bb213fe705b1424f8391996d4c35122019bc3 100644 (file)
@@ -947,6 +947,7 @@ struct drbd_conf {
        union drbd_state state;
        wait_queue_head_t misc_wait;
        wait_queue_head_t state_wait;  /* upon each state change. */
+       wait_queue_head_t net_cnt_wait;
        unsigned int send_cnt;
        unsigned int recv_cnt;
        unsigned int read_cnt;
@@ -2018,7 +2019,7 @@ static inline void inc_unacked(struct drbd_conf *mdev)
 static inline void put_net_conf(struct drbd_conf *mdev)
 {
        if (atomic_dec_and_test(&mdev->net_cnt))
-               wake_up(&mdev->misc_wait);
+               wake_up(&mdev->net_cnt_wait);
 }
 
 /**
index 440b1d5dcfe2be8091312c20cb53739cb12f449c..9fe9bdd9e33d7c0f1bfa32e5fcc7c85e595de93b 100644 (file)
@@ -2763,6 +2763,7 @@ void drbd_init_set_defaults(struct drbd_conf *mdev)
 
        init_waitqueue_head(&mdev->misc_wait);
        init_waitqueue_head(&mdev->state_wait);
+       init_waitqueue_head(&mdev->net_cnt_wait);
        init_waitqueue_head(&mdev->ee_wait);
        init_waitqueue_head(&mdev->al_wait);
        init_waitqueue_head(&mdev->seq_wait);
index 224c79ed16e958c27dd9d3647ad21551cc5cc90c..22d74d79ba42cfa6934fccb58a9e5b7304fecb78 100644 (file)
@@ -3775,7 +3775,7 @@ static void drbd_disconnect(struct drbd_conf *mdev)
 
        if (os.conn == C_DISCONNECTING) {
                struct hlist_head *h;
-               wait_event(mdev->misc_wait, atomic_read(&mdev->net_cnt) == 0);
+               wait_event(mdev->net_cnt_wait, atomic_read(&mdev->net_cnt) == 0);
 
                /* we must not free the tl_hash
                 * while application io is still on the fly */