@@ -188,97 +188,41 @@ sched_params_t ScrubQueue::determine_scrub_time(
188188}
189189
190190
191- // used under jobs_lock
192- void ScrubQueue::move_failed_pgs (utime_t now_is)
193- {
194- int punished_cnt{0 }; // for log/debug only
195-
196- for (auto job = to_scrub.begin (); job != to_scrub.end ();) {
197- if ((*job)->resources_failure ) {
198- auto sjob = *job;
199-
200- // last time it was scheduled for a scrub, this PG failed in securing
201- // remote resources. Move it to the secondary scrub queue.
202-
203- dout (15 ) << " moving " << sjob->pgid
204- << " state: " << ScrubJob::qu_state_text (sjob->state ) << dendl;
205-
206- // determine the penalty time, after which the job should be reinstated
207- utime_t after = now_is;
208- after += conf ()->osd_scrub_sleep * 2 + utime_t {300' 000ms};
209-
210- // note: currently - not taking 'deadline' into account when determining
211- // 'penalty_timeout'.
212- sjob->penalty_timeout = after;
213- sjob->resources_failure = false ;
214- sjob->updated = false ; // as otherwise will be pardoned immediately
215-
216- // place in the penalty list, and remove from the to-scrub group
217- penalized.push_back (sjob);
218- job = to_scrub.erase (job);
219- punished_cnt++;
220- } else {
221- job++;
222- }
223- }
224-
225- if (punished_cnt) {
226- dout (15 ) << " # of jobs penalized: " << punished_cnt << dendl;
227- }
228- }
229-
230191std::vector<ScrubTargetId> ScrubQueue::ready_to_scrub (
231192 OSDRestrictions restrictions, // note: 4B in size! (copy)
232193 utime_t scrub_tick)
233194{
234195 dout (10 ) << fmt::format (
235- " @{:s}: reg./pen. sizes: {} / {} ({})" , scrub_tick,
236- to_scrub.size (), penalized. size (), restrictions)
196+ " @{:s}: registered: {} ({})" , scrub_tick,
197+ to_scrub.size (), restrictions)
237198 << dendl;
199+
238200 // create a list of candidates (copying, as otherwise creating a deadlock):
239- // - possibly restore penalized
240201 // - (if we didn't handle directly) remove invalid jobs
241202 // - create a copy of the to_scrub (possibly up to first not-ripe)
242- // - same for the penalized (although that usually be a waste)
243203 // unlock, then try the lists
244-
245204 std::unique_lock lck{jobs_lock};
246205
247- // pardon all penalized jobs that have deadlined (or were updated)
248- scan_penalized (restore_penalized, scrub_tick);
249- restore_penalized = false ;
250-
251206 // remove the 'updated' flag from all entries
252207 std::for_each (
253208 to_scrub.begin (), to_scrub.end (),
254209 [](const auto & jobref) -> void { jobref->updated = false ; });
255210
256- // add failed scrub attempts to the penalized list
257- move_failed_pgs (scrub_tick);
258-
259- // collect all valid & ripe jobs from the two lists. Note that we must copy,
211+ // collect all valid & ripe jobs. Note that we must copy,
260212 // as when we use the lists we will not be holding jobs_lock (see
261213 // explanation above)
262214
263215 // and in this step 1 of the refactoring (Aug 2023): the set returned must be
264216 // transformed into a vector of targets (which, in this phase, are
265217 // the PG id-s).
266218 auto to_scrub_copy = collect_ripe_jobs (to_scrub, restrictions, scrub_tick);
267- auto penalized_copy = collect_ripe_jobs (penalized, restrictions, scrub_tick);
268219 lck.unlock ();
269220
270221 std::vector<ScrubTargetId> all_ready;
271222 std::transform (
272223 to_scrub_copy.cbegin (), to_scrub_copy.cend (),
273224 std::back_inserter (all_ready),
274225 [](const auto & jobref) -> ScrubTargetId { return jobref->pgid ; });
275- // not bothering to handle the "reached the penalized - so all should be
276- // forgiven" case, as the penalty queue is destined to be removed in a
277- // followup PR.
278- std::transform (
279- penalized_copy.cbegin (), penalized_copy.cend (),
280- std::back_inserter (all_ready),
281- [](const auto & jobref) -> ScrubTargetId { return jobref->pgid ; });
282226 return all_ready;
283227}
284228
@@ -389,71 +333,29 @@ Scrub::scrub_schedule_t ScrubQueue::adjust_target_time(
389333}
390334
391335
392- // note: called with jobs_lock held
393- void ScrubQueue::scan_penalized (bool forgive_all, utime_t time_now)
394- {
395- dout (20 ) << time_now << (forgive_all ? " all " : " - " ) << penalized.size ()
396- << dendl;
397-
398- // clear dead entries (deleted PGs, or those PGs we are no longer their
399- // primary)
400- rm_unregistered_jobs (penalized);
401-
402- if (forgive_all) {
403-
404- std::copy (penalized.begin (), penalized.end (), std::back_inserter (to_scrub));
405- penalized.clear ();
406-
407- } else {
408-
409- auto forgiven_last = std::partition (
410- penalized.begin (),
411- penalized.end (),
412- [time_now](const auto & e) {
413- return (*e).updated || ((*e).penalty_timeout <= time_now);
414- });
415-
416- std::copy (penalized.begin (), forgiven_last, std::back_inserter (to_scrub));
417- penalized.erase (penalized.begin (), forgiven_last);
418- dout (20 ) << " penalized after screening: " << penalized.size () << dendl;
419- }
420- }
421-
422336void ScrubQueue::dump_scrubs (ceph::Formatter* f) const
423337{
424338 ceph_assert (f != nullptr );
425339 std::lock_guard lck (jobs_lock);
426340
427341 f->open_array_section (" scrubs" );
428-
429342 std::for_each (
430343 to_scrub.cbegin (), to_scrub.cend (),
431344 [&f](const Scrub::ScrubJobRef& j) { j->dump (f); });
432-
433- std::for_each (
434- penalized.cbegin (), penalized.cend (),
435- [&f](const Scrub::ScrubJobRef& j) { j->dump (f); });
436-
437345 f->close_section ();
438346}
439347
440348ScrubQContainer ScrubQueue::list_registered_jobs () const
441349{
442350 ScrubQContainer all_jobs;
443- all_jobs.reserve (to_scrub.size () + penalized. size () );
351+ all_jobs.reserve (to_scrub.size ());
444352 dout (20 ) << " size: " << all_jobs.capacity () << dendl;
445353
446354 std::lock_guard lck{jobs_lock};
447-
448355 std::copy_if (to_scrub.begin (),
449356 to_scrub.end (),
450357 std::back_inserter (all_jobs),
451358 registered_job);
452- std::copy_if (penalized.begin (),
453- penalized.end (),
454- std::back_inserter (all_jobs),
455- registered_job);
456-
457359 return all_jobs;
458360}
459361
0 commit comments