From 9b7f911d9a139cc347f2d3ac3068fc1d212058c7 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Tue, 24 Nov 2020 15:23:20 -0800 Subject: [PATCH] osd: Check for nosrub/nodeep-scrub in between chunks, to avoid races Fixes: https://tracker.ceph.com/issues/47767 Signed-off-by: David Zafman --- src/osd/PG.cc | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 4afcec660882a..e5a9214994386 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2643,24 +2643,6 @@ void PG::abort_scrub() */ void PG::chunky_scrub(ThreadPool::TPHandle &handle) { - // Since repair is only by request and we need to scrub afterward - // treat the same as req_scrub. - if (!scrubber.req_scrub) { - if (state_test(PG_STATE_DEEP_SCRUB)) { - if (get_osdmap()->test_flag(CEPH_OSDMAP_NODEEP_SCRUB) || - pool.info.has_flag(pg_pool_t::FLAG_NODEEP_SCRUB)) { - dout(10) << "nodeep_scrub set, aborting" << dendl; - abort_scrub(); - return; - } - } else if (state_test(PG_STATE_SCRUBBING)) { - if (get_osdmap()->test_flag(CEPH_OSDMAP_NOSCRUB) || pool.info.has_flag(pg_pool_t::FLAG_NOSCRUB)) { - dout(10) << "noscrub set, aborting" << dendl; - abort_scrub(); - return; - } - } - } // check for map changes if (scrubber.is_chunky_scrub_active()) { if (scrubber.epoch_start != info.history.same_interval_since) { @@ -2906,6 +2888,24 @@ void PG::chunky_scrub(ThreadPool::TPHandle &handle) done = true; break; } + // Since repair is only by request and we need to scrub afterward + // treat the same as req_scrub. + if (!scrubber.req_scrub) { + if (state_test(PG_STATE_DEEP_SCRUB)) { + if (get_osdmap()->test_flag(CEPH_OSDMAP_NODEEP_SCRUB) || + pool.info.has_flag(pg_pool_t::FLAG_NODEEP_SCRUB)) { + dout(10) << "nodeep_scrub set, aborting" << dendl; + abort_scrub(); + return; + } + } else if (state_test(PG_STATE_SCRUBBING)) { + if (get_osdmap()->test_flag(CEPH_OSDMAP_NOSCRUB) || pool.info.has_flag(pg_pool_t::FLAG_NOSCRUB)) { + dout(10) << "noscrub set, aborting" << dendl; + abort_scrub(); + return; + } + } + } // end (possible) preemption window scrub_can_preempt = false; if (scrub_preempted) { -- 2.39.5