Commit 8869d683 authored by Philipp Reisner's avatar Philipp Reisner

drbd: Fixed inc_ap_bio()

The condition must be checked after perpare_to_wait(). The old
implementaion could loose wakeup events. Never observed in real
life.
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 127b3178
...@@ -2309,15 +2309,21 @@ static inline int __inc_ap_bio_cond(struct drbd_conf *mdev) ...@@ -2309,15 +2309,21 @@ static inline int __inc_ap_bio_cond(struct drbd_conf *mdev)
return 1; return 1;
} }
/* I'd like to use wait_event_lock_irq, static inline int _inc_ap_bio_cond(struct drbd_conf *mdev, int count)
* but I'm not sure when it got introduced,
* and not sure when it has 3 or 4 arguments */
static inline void inc_ap_bio(struct drbd_conf *mdev, int count)
{ {
/* compare with after_state_ch, int rv = 0;
* os.conn != C_WF_BITMAP_S && ns.conn == C_WF_BITMAP_S */
DEFINE_WAIT(wait); spin_lock_irq(&mdev->req_lock);
rv = __inc_ap_bio_cond(mdev);
if (rv)
atomic_add(count, &mdev->ap_bio_cnt);
spin_unlock_irq(&mdev->req_lock);
return rv;
}
static inline void inc_ap_bio(struct drbd_conf *mdev, int count)
{
/* we wait here /* we wait here
* as long as the device is suspended * as long as the device is suspended
* until the bitmap is no longer on the fly during connection * until the bitmap is no longer on the fly during connection
...@@ -2326,16 +2332,7 @@ static inline void inc_ap_bio(struct drbd_conf *mdev, int count) ...@@ -2326,16 +2332,7 @@ static inline void inc_ap_bio(struct drbd_conf *mdev, int count)
* to avoid races with the reconnect code, * to avoid races with the reconnect code,
* we need to atomic_inc within the spinlock. */ * we need to atomic_inc within the spinlock. */
spin_lock_irq(&mdev->req_lock); wait_event(mdev->misc_wait, _inc_ap_bio_cond(mdev, count));
while (!__inc_ap_bio_cond(mdev)) {
prepare_to_wait(&mdev->misc_wait, &wait, TASK_UNINTERRUPTIBLE);
spin_unlock_irq(&mdev->req_lock);
schedule();
finish_wait(&mdev->misc_wait, &wait);
spin_lock_irq(&mdev->req_lock);
}
atomic_add(count, &mdev->ap_bio_cnt);
spin_unlock_irq(&mdev->req_lock);
} }
static inline void dec_ap_bio(struct drbd_conf *mdev) static inline void dec_ap_bio(struct drbd_conf *mdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment