]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: handle configuration changes in OsdScrub
authorRonen Friedman <rfriedma@redhat.com>
Tue, 19 Sep 2023 12:16:03 +0000 (07:16 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Wed, 20 Sep 2023 06:39:10 +0000 (01:39 -0500)
Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/OSD.cc
src/osd/scrubber/osd_scrub.cc
src/osd/scrubber/osd_scrub.h

index 4b7ecfc00cbe0b8476fd692d41a35385e4d21edd..d6948cf05a76f0b8cb23bc2a3c09bac72c7c57a1 100644 (file)
@@ -9839,10 +9839,17 @@ void OSD::handle_conf_change(const ConfigProxy& conf,
   }
 
   if (changed.count("osd_scrub_min_interval") ||
-      changed.count("osd_scrub_max_interval")) {
-    resched_all_scrubs();
-    dout(0) << __func__ << ": scrub interval change" << dendl;
+      changed.count("osd_scrub_max_interval") ||
+      changed.count("osd_deep_scrub_interval")) {
+    service.get_scrub_services().on_config_change();
+    dout(0) << fmt::format(
+                  "{}: scrub interval change (min:{} deep:{} max:{})",
+                  __func__, cct->_conf->osd_scrub_min_interval,
+                  cct->_conf->osd_deep_scrub_interval,
+                  cct->_conf->osd_scrub_max_interval)
+           << dendl;
   }
+
   check_config();
   if (changed.count("osd_asio_thread_count")) {
     service.poolctx.stop();
index 6c31dce802b4bbd7d88af0f62db59881ec3e8b1f..ee82bb5f21696c74290642e5dcf0159ea4430823 100644 (file)
@@ -260,43 +260,24 @@ Scrub::schedule_result_t OsdScrub::initiate_a_scrub(
   return locked_pg->pg()->sched_scrub();
 }
 
-
-// ////////////////////////////////////////////////////////////////////////// //
-// scrub initiation - OSD code temporarily moved here from OSD.cc
-
-// temporary dout() support for OSD members:
-static ostream& _prefix(std::ostream* _dout, int whoami, epoch_t epoch) {
-  return *_dout << "osd." << whoami << " " << epoch << " ";
-}
-#undef dout_prefix
-#define dout_prefix _prefix(_dout, whoami, get_osdmap_epoch())
-
-void OSD::resched_all_scrubs()
+void OsdScrub::on_config_change()
 {
-  dout(10) << __func__ << ": start" << dendl;
-  auto all_jobs = service.get_scrub_services().list_registered_jobs();
-  for (auto& e : all_jobs) {
-
-    auto& job = *e;
-    dout(20) << __func__ << ": examine " << job.pgid << dendl;
+  auto to_notify = m_queue.list_registered_jobs();
 
-    PGRef pg = _lookup_lock_pg(job.pgid);
-    if (!pg)
+  for (const auto& p : to_notify) {
+    dout(30) << fmt::format("rescheduling pg[{}] scrubs", *p) << dendl;
+    auto locked_pg = m_osd_svc.get_locked_pg(p->pgid);
+    if (!locked_pg)
       continue;
 
-    dout(15) << __func__ << ": updating scrub schedule on " << job.pgid << dendl;
-    pg->on_scrub_schedule_input_change();
-
-    pg->unlock();
+    dout(15) << fmt::format(
+                   "updating scrub schedule on {}",
+                   (locked_pg->pg())->get_pgid())
+            << dendl;
+    locked_pg->pg()->on_scrub_schedule_input_change();
   }
-  dout(10) << __func__ << ": done" << dendl;
 }
 
-
-// restoring local dout() settings (to be removed in a followup commit)
-#undef dout_prefix
-#define dout_prefix _prefix_fn(_dout, this, __func__)
-
 void ScrubQueue::dump_scrubs(ceph::Formatter* f) const
 {
   ceph_assert(f != nullptr);
index 75ad02fd60714938f0632fc36e020c0e43600450..4bfbe1e646dfefb0653cb39933875eb6ca8fe93e 100644 (file)
@@ -28,9 +28,6 @@ class OsdScrub {
 
   ~OsdScrub() = default;
 
-  // temporary friendship - only required in this transitory commit
-  friend class OSD;
-
   // note: public, as accessed by the dout macros
   std::ostream& gen_prefix(std::ostream& out, std::string_view fn) const;
 
@@ -53,6 +50,16 @@ class OsdScrub {
 
   void dump_scrubs(ceph::Formatter* f) const;  ///< fwd to the queue
 
+  /**
+   * on_config_change() (the refactored "OSD::sched_all_scrubs()")
+   *
+   * for each PG registered with the OSD (i.e. - for which we are the primary):
+   * lock that PG, and call its on_scrub_schedule_input_change() method
+   * to handle a possible change in one of the configuration parameters
+   * that affect scrub scheduling.
+   */
+  void on_config_change();
+
 
   // implementing the PGs interface to the scrub scheduling objects
   // ---------------------------------------------------------------