aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLars Ellenberg <lars.ellenberg@linbit.com>2012-06-19 04:27:58 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-07-24 08:15:58 -0400
commit7ee1fb93f390f7a7231abec4e34e6ab20abeed45 (patch)
tree34a4e86335dc8f6dca13abcae3bf60ca5f8b37ab /drivers
parentc12e9c8964215aaf2b5dcd06048444c2b672f0b9 (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')
-rw-r--r--drivers/block/drbd/drbd_int.h10
-rw-r--r--drivers/block/drbd/drbd_nl.c8
2 files changed, 12 insertions, 6 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 5136510ec8be..2704af2ccf61 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -2421,15 +2421,17 @@ static inline void dec_ap_bio(struct drbd_conf *mdev)
2421 int ap_bio = atomic_dec_return(&mdev->ap_bio_cnt); 2421 int ap_bio = atomic_dec_return(&mdev->ap_bio_cnt);
2422 2422
2423 D_ASSERT(ap_bio >= 0); 2423 D_ASSERT(ap_bio >= 0);
2424
2425 if (ap_bio == 0 && test_bit(BITMAP_IO, &mdev->flags)) {
2426 if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags))
2427 drbd_queue_work(&mdev->data.work, &mdev->bm_io_work.w);
2428 }
2429
2424 /* this currently does wake_up for every dec_ap_bio! 2430 /* this currently does wake_up for every dec_ap_bio!
2425 * maybe rather introduce some type of hysteresis? 2431 * maybe rather introduce some type of hysteresis?
2426 * e.g. (ap_bio == mxb/2 || ap_bio == 0) ? */ 2432 * e.g. (ap_bio == mxb/2 || ap_bio == 0) ? */
2427 if (ap_bio < mxb) 2433 if (ap_bio < mxb)
2428 wake_up(&mdev->misc_wait); 2434 wake_up(&mdev->misc_wait);
2429 if (ap_bio == 0 && test_bit(BITMAP_IO, &mdev->flags)) {
2430 if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags))
2431 drbd_queue_work(&mdev->data.work, &mdev->bm_io_work.w);
2432 }
2433} 2435}
2434 2436
2435static inline int drbd_set_ed_uuid(struct drbd_conf *mdev, u64 val) 2437static 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 a68d9bfb731c..c47df7cf7f80 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1977,9 +1977,11 @@ static int drbd_nl_invalidate(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl
1977 int retcode; 1977 int retcode;
1978 1978
1979 /* If there is still bitmap IO pending, probably because of a previous 1979 /* If there is still bitmap IO pending, probably because of a previous
1980 * resync just being finished, wait for it before requesting a new resync. */ 1980 * resync just being finished, wait for it before requesting a new resync.
1981 * Also wait for it's after_state_ch(). */
1981 drbd_suspend_io(mdev); 1982 drbd_suspend_io(mdev);
1982 wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); 1983 wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags));
1984 drbd_flush_workqueue(mdev);
1983 1985
1984 retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_T), CS_ORDERED); 1986 retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_T), CS_ORDERED);
1985 1987
@@ -2018,9 +2020,11 @@ static int drbd_nl_invalidate_peer(struct drbd_conf *mdev, struct drbd_nl_cfg_re
2018 int retcode; 2020 int retcode;
2019 2021
2020 /* If there is still bitmap IO pending, probably because of a previous 2022 /* If there is still bitmap IO pending, probably because of a previous
2021 * resync just being finished, wait for it before requesting a new resync. */ 2023 * resync just being finished, wait for it before requesting a new resync.
2024 * Also wait for it's after_state_ch(). */
2022 drbd_suspend_io(mdev); 2025 drbd_suspend_io(mdev);
2023 wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); 2026 wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags));
2027 drbd_flush_workqueue(mdev);
2024 2028
2025 retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_S), CS_ORDERED); 2029 retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_S), CS_ORDERED);
2026 2030