diff options
author | Philipp Reisner <philipp.reisner@linbit.com> | 2010-09-01 09:47:15 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2010-10-14 12:38:29 -0400 |
commit | 63106d3c6c769b6219bd04edde513b12abae3f61 (patch) | |
tree | 5131a90796858c44bfb4cceda6c2a4760d7e007d /drivers/block | |
parent | ef50a3e34f93a067ada541346be3175e924331a2 (diff) |
drbd: Removed a race that could cause unexpected execution of w_make_resync_request()
The actual race happened int the drbd_start_resync() function. Where
drbd_resync_finished() -> __drbd_set_state() set STOP_SYNC_TIMER and
armed the timer.
If the timer fired before execution reaches the mod_timer statement
at the end of drbd_start_resync() the latter would cause an
unexpected call to w_make_resync_request().
Removed the STOP_SYNC_TIMER bit, and base it on the connection state.
The STOP_SYNC_TIMER bit probably originates probably the time before
the state engine.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 1 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 18 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 1 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_worker.c | 21 |
4 files changed, 11 insertions, 30 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index bb3a488b6fd6..d5e38de83a19 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -827,7 +827,6 @@ enum { | |||
827 | SIGNAL_ASENDER, /* whether asender wants to be interrupted */ | 827 | SIGNAL_ASENDER, /* whether asender wants to be interrupted */ |
828 | SEND_PING, /* whether asender should send a ping asap */ | 828 | SEND_PING, /* whether asender should send a ping asap */ |
829 | 829 | ||
830 | STOP_SYNC_TIMER, /* tell timer to cancel itself */ | ||
831 | UNPLUG_QUEUED, /* only relevant with kernel 2.4 */ | 830 | UNPLUG_QUEUED, /* only relevant with kernel 2.4 */ |
832 | UNPLUG_REMOTE, /* sending a "UnplugRemote" could help */ | 831 | UNPLUG_REMOTE, /* sending a "UnplugRemote" could help */ |
833 | MD_DIRTY, /* current uuids and flags not yet on disk */ | 832 | MD_DIRTY, /* current uuids and flags not yet on disk */ |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 73c905d0ef18..5dd071e5c921 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -1052,12 +1052,6 @@ int __drbd_set_state(struct drbd_conf *mdev, | |||
1052 | wake_up(&mdev->misc_wait); | 1052 | wake_up(&mdev->misc_wait); |
1053 | wake_up(&mdev->state_wait); | 1053 | wake_up(&mdev->state_wait); |
1054 | 1054 | ||
1055 | /* post-state-change actions */ | ||
1056 | if (os.conn >= C_SYNC_SOURCE && ns.conn <= C_CONNECTED) { | ||
1057 | set_bit(STOP_SYNC_TIMER, &mdev->flags); | ||
1058 | mod_timer(&mdev->resync_timer, jiffies); | ||
1059 | } | ||
1060 | |||
1061 | /* aborted verify run. log the last position */ | 1055 | /* aborted verify run. log the last position */ |
1062 | if ((os.conn == C_VERIFY_S || os.conn == C_VERIFY_T) && | 1056 | if ((os.conn == C_VERIFY_S || os.conn == C_VERIFY_T) && |
1063 | ns.conn < C_CONNECTED) { | 1057 | ns.conn < C_CONNECTED) { |
@@ -1072,22 +1066,14 @@ int __drbd_set_state(struct drbd_conf *mdev, | |||
1072 | dev_info(DEV, "Syncer continues.\n"); | 1066 | dev_info(DEV, "Syncer continues.\n"); |
1073 | mdev->rs_paused += (long)jiffies | 1067 | mdev->rs_paused += (long)jiffies |
1074 | -(long)mdev->rs_mark_time[mdev->rs_last_mark]; | 1068 | -(long)mdev->rs_mark_time[mdev->rs_last_mark]; |
1075 | if (ns.conn == C_SYNC_TARGET) { | 1069 | if (ns.conn == C_SYNC_TARGET) |
1076 | if (!test_and_clear_bit(STOP_SYNC_TIMER, &mdev->flags)) | 1070 | mod_timer(&mdev->resync_timer, jiffies); |
1077 | mod_timer(&mdev->resync_timer, jiffies); | ||
1078 | /* This if (!test_bit) is only needed for the case | ||
1079 | that a device that has ceased to used its timer, | ||
1080 | i.e. it is already in drbd_resync_finished() gets | ||
1081 | paused and resumed. */ | ||
1082 | } | ||
1083 | } | 1071 | } |
1084 | 1072 | ||
1085 | if ((os.conn == C_SYNC_TARGET || os.conn == C_SYNC_SOURCE) && | 1073 | if ((os.conn == C_SYNC_TARGET || os.conn == C_SYNC_SOURCE) && |
1086 | (ns.conn == C_PAUSED_SYNC_T || ns.conn == C_PAUSED_SYNC_S)) { | 1074 | (ns.conn == C_PAUSED_SYNC_T || ns.conn == C_PAUSED_SYNC_S)) { |
1087 | dev_info(DEV, "Resync suspended\n"); | 1075 | dev_info(DEV, "Resync suspended\n"); |
1088 | mdev->rs_mark_time[mdev->rs_last_mark] = jiffies; | 1076 | mdev->rs_mark_time[mdev->rs_last_mark] = jiffies; |
1089 | if (ns.conn == C_PAUSED_SYNC_T) | ||
1090 | set_bit(STOP_SYNC_TIMER, &mdev->flags); | ||
1091 | } | 1077 | } |
1092 | 1078 | ||
1093 | if (os.conn == C_CONNECTED && | 1079 | if (os.conn == C_CONNECTED && |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 4249117f1f67..885471ded2fb 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -3803,7 +3803,6 @@ static void drbd_disconnect(struct drbd_conf *mdev) | |||
3803 | 3803 | ||
3804 | /* make sure syncer is stopped and w_resume_next_sg queued */ | 3804 | /* make sure syncer is stopped and w_resume_next_sg queued */ |
3805 | del_timer_sync(&mdev->resync_timer); | 3805 | del_timer_sync(&mdev->resync_timer); |
3806 | set_bit(STOP_SYNC_TIMER, &mdev->flags); | ||
3807 | resync_timer_fn((unsigned long)mdev); | 3806 | resync_timer_fn((unsigned long)mdev); |
3808 | 3807 | ||
3809 | /* wait for all w_e_end_data_req, w_e_end_rsdata_req, w_send_barrier, | 3808 | /* wait for all w_e_end_data_req, w_e_end_rsdata_req, w_send_barrier, |
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index 8be983263374..0e5bf8c98293 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c | |||
@@ -395,25 +395,22 @@ defer: | |||
395 | 395 | ||
396 | void resync_timer_fn(unsigned long data) | 396 | void resync_timer_fn(unsigned long data) |
397 | { | 397 | { |
398 | unsigned long flags; | ||
399 | struct drbd_conf *mdev = (struct drbd_conf *) data; | 398 | struct drbd_conf *mdev = (struct drbd_conf *) data; |
400 | int queue; | 399 | int queue; |
401 | 400 | ||
402 | spin_lock_irqsave(&mdev->req_lock, flags); | 401 | queue = 1; |
403 | 402 | switch (mdev->state.conn) { | |
404 | if (likely(!test_and_clear_bit(STOP_SYNC_TIMER, &mdev->flags))) { | 403 | case C_VERIFY_S: |
405 | queue = 1; | 404 | mdev->resync_work.cb = w_make_ov_request; |
406 | if (mdev->state.conn == C_VERIFY_S) | 405 | break; |
407 | mdev->resync_work.cb = w_make_ov_request; | 406 | case C_SYNC_TARGET: |
408 | else | 407 | mdev->resync_work.cb = w_make_resync_request; |
409 | mdev->resync_work.cb = w_make_resync_request; | 408 | break; |
410 | } else { | 409 | default: |
411 | queue = 0; | 410 | queue = 0; |
412 | mdev->resync_work.cb = w_resync_inactive; | 411 | mdev->resync_work.cb = w_resync_inactive; |
413 | } | 412 | } |
414 | 413 | ||
415 | spin_unlock_irqrestore(&mdev->req_lock, flags); | ||
416 | |||
417 | /* harmless race: list_empty outside data.work.q_lock */ | 414 | /* harmless race: list_empty outside data.work.q_lock */ |
418 | if (list_empty(&mdev->resync_work.list) && queue) | 415 | if (list_empty(&mdev->resync_work.list) && queue) |
419 | drbd_queue_work(&mdev->data.work, &mdev->resync_work); | 416 | drbd_queue_work(&mdev->data.work, &mdev->resync_work); |