summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKefu Chai <tchaikov@gmail.com>2017-10-02 05:41:07 +0200
committerGitHub <noreply@github.com>2017-10-02 05:41:07 +0200
commit314dff75a463b947e5fc417c33efae437227f816 (patch)
tree027b1f753db55e7b0fbc28a6a60972c365d31b0c
parentMerge pull request #18059 from Liuchang0812/remove-duplicated-func (diff)
parentosd: hold lock while accessing recovery_needs_sleep (diff)
downloadceph-314dff75a463b947e5fc417c33efae437227f816.tar.xz
ceph-314dff75a463b947e5fc417c33efae437227f816.zip
Merge pull request #18022 from neha-ojha/wip-21566
osd: hold lock while accessing recovery_needs_sleep Reviewed-by: Gregory Farnum <gfarnum@redhat.com> Reviewed-by: Josh Durgin <jdurgin@redhat.com>
-rw-r--r--src/osd/OSD.cc53
1 files changed, 30 insertions, 23 deletions
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc
index 6524e1e9a2d..bcc7434e231 100644
--- a/src/osd/OSD.cc
+++ b/src/osd/OSD.cc
@@ -9090,33 +9090,40 @@ void OSD::do_recovery(
* queue_recovery_after_sleep.
*/
float recovery_sleep = get_osd_recovery_sleep();
- if (recovery_sleep > 0 && service.recovery_needs_sleep) {
- PGRef pgref(pg);
- auto recovery_requeue_callback = new FunctionContext([this, pgref, queued, reserved_pushes](int r) {
- dout(20) << "do_recovery wake up at "
- << ceph_clock_now()
- << ", re-queuing recovery" << dendl;
- service.recovery_needs_sleep = false;
- service.queue_recovery_after_sleep(pgref.get(), queued, reserved_pushes);
- });
+ {
Mutex::Locker l(service.recovery_sleep_lock);
-
- // This is true for the first recovery op and when the previous recovery op
- // has been scheduled in the past. The next recovery op is scheduled after
- // completing the sleep from now.
- if (service.recovery_schedule_time < ceph_clock_now()) {
- service.recovery_schedule_time = ceph_clock_now();
- }
- service.recovery_schedule_time += recovery_sleep;
- service.recovery_sleep_timer.add_event_at(service.recovery_schedule_time,
- recovery_requeue_callback);
- dout(20) << "Recovery event scheduled at "
- << service.recovery_schedule_time << dendl;
- return;
+ if (recovery_sleep > 0 && service.recovery_needs_sleep) {
+ PGRef pgref(pg);
+ auto recovery_requeue_callback = new FunctionContext([this, pgref, queued, reserved_pushes](int r) {
+ dout(20) << "do_recovery wake up at "
+ << ceph_clock_now()
+ << ", re-queuing recovery" << dendl;
+ Mutex::Locker l(service.recovery_sleep_lock);
+ service.recovery_needs_sleep = false;
+ service.queue_recovery_after_sleep(pgref.get(), queued, reserved_pushes);
+ });
+
+ // This is true for the first recovery op and when the previous recovery op
+ // has been scheduled in the past. The next recovery op is scheduled after
+ // completing the sleep from now.
+ if (service.recovery_schedule_time < ceph_clock_now()) {
+ service.recovery_schedule_time = ceph_clock_now();
+ }
+ service.recovery_schedule_time += recovery_sleep;
+ service.recovery_sleep_timer.add_event_at(service.recovery_schedule_time,
+ recovery_requeue_callback);
+ dout(20) << "Recovery event scheduled at "
+ << service.recovery_schedule_time << dendl;
+ return;
+ }
}
{
- service.recovery_needs_sleep = true;
+ {
+ Mutex::Locker l(service.recovery_sleep_lock);
+ service.recovery_needs_sleep = true;
+ }
+
if (pg->pg_has_reset_since(queued)) {
goto out;
}