diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2012-07-30 03:11:38 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:58:41 -0500 |
commit | 970fbde1f1ebae0c85bbaed3de83684a58d60fad (patch) | |
tree | b0b61dd455f63fd7cbad4d26bbc6f6a50cd7c9dc /drivers/block/drbd | |
parent | 6f1a656325ea01638de44f8d40bb77c73181b275 (diff) |
drbd: flush drbd work queue before invalidate/invalidate remote
If you do back to back wait-sync/invalidate on a Primary in a tight loop,
during application IO load, you could trigger a race:
kernel: block drbd6: FIXME going to queue 'set_n_write from StartingSync'
but 'write from resync_finished' still pending?
Fix this by changing the order of the drbd_queue_work() and
the wake_up() in dec_ap_pending(), and adding the additional
drbd_flush_workqueue() before requesting the full sync.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 10 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_nl.c | 8 |
2 files changed, 12 insertions, 6 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index e010afff336a..22adfc7189de 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -2251,15 +2251,17 @@ static inline void dec_ap_bio(struct drbd_conf *mdev) | |||
2251 | int ap_bio = atomic_dec_return(&mdev->ap_bio_cnt); | 2251 | int ap_bio = atomic_dec_return(&mdev->ap_bio_cnt); |
2252 | 2252 | ||
2253 | D_ASSERT(ap_bio >= 0); | 2253 | D_ASSERT(ap_bio >= 0); |
2254 | |||
2255 | if (ap_bio == 0 && test_bit(BITMAP_IO, &mdev->flags)) { | ||
2256 | if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags)) | ||
2257 | drbd_queue_work(&mdev->tconn->sender_work, &mdev->bm_io_work.w); | ||
2258 | } | ||
2259 | |||
2254 | /* this currently does wake_up for every dec_ap_bio! | 2260 | /* this currently does wake_up for every dec_ap_bio! |
2255 | * maybe rather introduce some type of hysteresis? | 2261 | * maybe rather introduce some type of hysteresis? |
2256 | * e.g. (ap_bio == mxb/2 || ap_bio == 0) ? */ | 2262 | * e.g. (ap_bio == mxb/2 || ap_bio == 0) ? */ |
2257 | if (ap_bio < mxb) | 2263 | if (ap_bio < mxb) |
2258 | wake_up(&mdev->misc_wait); | 2264 | wake_up(&mdev->misc_wait); |
2259 | if (ap_bio == 0 && test_bit(BITMAP_IO, &mdev->flags)) { | ||
2260 | if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags)) | ||
2261 | drbd_queue_work(&mdev->tconn->sender_work, &mdev->bm_io_work.w); | ||
2262 | } | ||
2263 | } | 2265 | } |
2264 | 2266 | ||
2265 | static inline int drbd_set_ed_uuid(struct drbd_conf *mdev, u64 val) | 2267 | static inline int drbd_set_ed_uuid(struct drbd_conf *mdev, u64 val) |
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index a2925dedc23f..4afd626ca3dc 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c | |||
@@ -2408,9 +2408,11 @@ int drbd_adm_invalidate(struct sk_buff *skb, struct genl_info *info) | |||
2408 | mdev = adm_ctx.mdev; | 2408 | mdev = adm_ctx.mdev; |
2409 | 2409 | ||
2410 | /* If there is still bitmap IO pending, probably because of a previous | 2410 | /* If there is still bitmap IO pending, probably because of a previous |
2411 | * resync just being finished, wait for it before requesting a new resync. */ | 2411 | * resync just being finished, wait for it before requesting a new resync. |
2412 | * Also wait for it's after_state_ch(). */ | ||
2412 | drbd_suspend_io(mdev); | 2413 | drbd_suspend_io(mdev); |
2413 | wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); | 2414 | wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); |
2415 | drbd_flush_workqueue(mdev); | ||
2414 | 2416 | ||
2415 | retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_T), CS_ORDERED); | 2417 | retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_T), CS_ORDERED); |
2416 | 2418 | ||
@@ -2475,9 +2477,11 @@ int drbd_adm_invalidate_peer(struct sk_buff *skb, struct genl_info *info) | |||
2475 | mdev = adm_ctx.mdev; | 2477 | mdev = adm_ctx.mdev; |
2476 | 2478 | ||
2477 | /* If there is still bitmap IO pending, probably because of a previous | 2479 | /* If there is still bitmap IO pending, probably because of a previous |
2478 | * resync just being finished, wait for it before requesting a new resync. */ | 2480 | * resync just being finished, wait for it before requesting a new resync. |
2481 | * Also wait for it's after_state_ch(). */ | ||
2479 | drbd_suspend_io(mdev); | 2482 | drbd_suspend_io(mdev); |
2480 | wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); | 2483 | wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); |
2484 | drbd_flush_workqueue(mdev); | ||
2481 | 2485 | ||
2482 | retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_S), CS_ORDERED); | 2486 | retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_S), CS_ORDERED); |
2483 | if (retcode < SS_SUCCESS) { | 2487 | if (retcode < SS_SUCCESS) { |