From 00a3f7bba783721abf47c8be29fd70e4cf0a383f Mon Sep 17 00:00:00 2001 From: Jin Cai Date: Wed, 7 Jun 2017 18:49:16 +0800 Subject: [PATCH] osd/OSD: There are requests that will be blocked by the chunk, queue this scrub job with higher priority Signed-off-by: Jin Cai --- src/osd/OSD.h | 8 ++++++-- src/osd/PG.cc | 20 ++++++++++++++++---- src/osd/PG.h | 3 ++- src/osd/PrimaryLogPG.cc | 13 +++++++++++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 282e58a73315e..2ff0885029dd0 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -959,13 +959,17 @@ public: AsyncReserver snap_reserver; void queue_for_snap_trim(PG *pg); - void queue_for_scrub(PG *pg) { + void queue_for_scrub(PG *pg, bool with_high_priority) { + unsigned scrub_queue_priority = pg->scrubber.priority; + if (with_high_priority && scrub_queue_priority < cct->_conf->osd_client_op_priority) { + scrub_queue_priority = cct->_conf->osd_client_op_priority; + } enqueue_back( pg->info.pgid, PGQueueable( PGScrub(pg->get_osdmap()->get_epoch()), cct->_conf->osd_scrub_cost, - pg->scrubber.priority, + scrub_queue_priority, ceph_clock_now(), entity_inst_t(), pg->get_osdmap()->get_epoch())); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 3b22ff5d4b957..d66658108c3ce 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1939,7 +1939,7 @@ void PG::all_activated_and_committed() AllReplicasActivated()))); } -bool PG::requeue_scrub() +bool PG::requeue_scrub(bool high_priority) { assert(is_locked()); if (scrub_queued) { @@ -1948,7 +1948,7 @@ bool PG::requeue_scrub() } else { dout(10) << __func__ << ": queueing" << dendl; scrub_queued = true; - osd->queue_for_scrub(this); + osd->queue_for_scrub(this, high_priority); return true; } } @@ -3667,7 +3667,11 @@ void PG::do_replica_scrub_map(OpRequestRef op) --scrubber.waiting_on; scrubber.waiting_on_whom.erase(m->from); if (scrubber.waiting_on == 0) { - requeue_scrub(); + if (ops_blocked_by_scrub()) { + requeue_scrub(true); + } else { + requeue_scrub(false); + } } } @@ -3703,7 +3707,11 @@ void PG::sub_op_scrub_map(OpRequestRef op) scrubber.waiting_on_whom.erase(m->from); if (scrubber.waiting_on == 0) { - requeue_scrub(); + if (ops_blocked_by_scrub()) { + requeue_scrub(true); + } else { + requeue_scrub(false); + } } } @@ -4785,6 +4793,10 @@ bool PG::scrub_process_inconsistent() return (!scrubber.authoritative.empty() && repair); } +bool PG::ops_blocked_by_scrub() const { + return (waiting_for_scrub.size() != 0); +} + // the part that actually finalizes a scrub void PG::scrub_finish() { diff --git a/src/osd/PG.h b/src/osd/PG.h index 0f9282a44a445..28c9a349d99c2 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1345,6 +1345,7 @@ public: * return true if any inconsistency/missing is repaired, false otherwise */ bool scrub_process_inconsistent(); + bool ops_blocked_by_scrub() const; void scrub_finish(); void scrub_clear_state(); void _scan_snaps(ScrubMap &map); @@ -2376,7 +2377,7 @@ public: virtual void kick_snap_trim() = 0; virtual void snap_trimmer_scrub_complete() = 0; - bool requeue_scrub(); + bool requeue_scrub(bool high_priority = false); void queue_recovery(bool front = false); bool queue_scrub(); unsigned get_scrub_priority(); diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 87616ae48a706..957b797f0c3e2 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -8952,7 +8952,12 @@ void PrimaryLogPG::op_applied(const eversion_t &applied_version) if (is_primary()) { if (scrubber.active) { if (last_update_applied == scrubber.subset_last_update) { - requeue_scrub(); + if (ops_blocked_by_scrub()) { + requeue_scrub(true); + } else { + requeue_scrub(false); + } + } } else { assert(scrubber.start == scrubber.end); @@ -10183,7 +10188,11 @@ void PrimaryLogPG::_applied_recovered_object(ObjectContextRef obc) // requeue an active chunky scrub waiting on recovery ops if (!deleting && active_pushes == 0 && scrubber.is_chunky_scrub_active()) { - requeue_scrub(); + if (ops_blocked_by_scrub()) { + requeue_scrub(true); + } else { + requeue_scrub(false); + } } unlock(); -- 2.39.5