]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: Change scrub cost to use average object size
authorAishwarya Mathuria <amathuri@redhat.com>
Mon, 18 Mar 2024 07:48:34 +0000 (07:48 +0000)
committerSridhar Seshasayee <sseshasa@redhat.com>
Fri, 6 Sep 2024 10:41:15 +0000 (16:11 +0530)
In order to get an accurate cost of the scrub operation for mClock scheduler, we use the cost calculated by the get_scrub_cost() method which takes into account the average of the object sizes in a PG that is queued for a scrub.

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>
(cherry picked from commit 5532f6a9d750f8437df16c4624f35adf84b24e07)

 Conflicts:
        src/osd/scrubber/pg_scrubber.cc
  - void PgScrubber::select_range_n_notify() doesn't yet increment a
    couple of counters viz., scrbcnt_chunks_selected and
    scrbcnt_chunks_busy and so those are not included.
  - void PgScrubber::replica_scrub_op() doesn't call advance_token()
    just before calling queue_for_rep_scrub(). Therefore,
    advance_token() is not included. This is introduced as part of
    PR: https://github.com/ceph/ceph/pull/54482 on main.

src/osd/OSD.cc
src/osd/OSD.h
src/osd/scrubber/pg_scrubber.cc

index bbc7b7ffe14e66bf5980aee37efc5a308d970fcd..8633e95eafa5cd2ffc3d713b930c3aefffec0cf5 100644 (file)
@@ -1834,9 +1834,10 @@ void OSDService::queue_scrub_after_repair(PG* pg, Scrub::scrub_prio_t with_prior
 void OSDService::queue_for_rep_scrub(PG* pg,
                                     Scrub::scrub_prio_t with_priority,
                                     unsigned int qu_priority,
-                                    Scrub::act_token_t act_token)
+                                    Scrub::act_token_t act_token,
+                                    uint64_t cost)
 {
-  queue_scrub_event_msg<PGRepScrub>(pg, with_priority, qu_priority, act_token, get_scrub_cost());
+  queue_scrub_event_msg<PGRepScrub>(pg, with_priority, qu_priority, act_token, cost);
 }
 
 void OSDService::queue_for_rep_scrub_resched(PG* pg,
@@ -1873,10 +1874,10 @@ void OSDService::queue_scrub_pushes_update(PG* pg, Scrub::scrub_prio_t with_prio
   queue_scrub_event_msg_default_cost<PGScrubPushesUpdate>(pg, with_priority);
 }
 
-void OSDService::queue_scrub_chunk_free(PG* pg, Scrub::scrub_prio_t with_priority)
+void OSDService::queue_scrub_chunk_free(PG* pg, Scrub::scrub_prio_t with_priority, uint64_t cost)
 {
   // Resulting scrub event: 'SelectedChunkFree'
-  queue_scrub_event_msg<PGScrubChunkIsFree>(pg, with_priority, get_scrub_cost());
+  queue_scrub_event_msg<PGScrubChunkIsFree>(pg, with_priority, cost);
 }
 
 void OSDService::queue_scrub_chunk_busy(PG* pg, Scrub::scrub_prio_t with_priority)
index e8090970ce535f8d508caf591ae4e490e9c04403..8c1bda9e9ee076397c0b95bcee56d3d6e8fcb0b4 100644 (file)
@@ -535,7 +535,7 @@ public:
   void queue_scrub_applied_update(PG* pg, Scrub::scrub_prio_t with_priority);
 
   /// Signals that the selected chunk (objects range) is available for scrubbing
-  void queue_scrub_chunk_free(PG* pg, Scrub::scrub_prio_t with_priority);
+  void queue_scrub_chunk_free(PG* pg, Scrub::scrub_prio_t with_priority, uint64_t cost);
 
   /// The chunk selected is blocked by user operations, and cannot be scrubbed now
   void queue_scrub_chunk_busy(PG* pg, Scrub::scrub_prio_t with_priority);
@@ -564,7 +564,8 @@ public:
   void queue_for_rep_scrub(PG* pg,
                           Scrub::scrub_prio_t with_high_priority,
                           unsigned int qu_priority,
-                          Scrub::act_token_t act_token);
+                          Scrub::act_token_t act_token,
+                          uint64_t cost);
 
   /// Signals a change in the number of in-flight recovery writes
   void queue_scrub_replica_pushes(PG *pg, Scrub::scrub_prio_t with_priority);
index 7aba344058a651581d303488713e5184c928e79c..893e59e74d8cd52b7a945d4306221630e209d462 100644 (file)
@@ -773,10 +773,12 @@ std::optional<uint64_t> PgScrubber::select_range()
 
 void PgScrubber::select_range_n_notify()
 {
-  if (select_range()) {
+  auto num_chunk_objects = select_range();
+  if (num_chunk_objects.has_value()) {
     // the next chunk to handle is not blocked
     dout(20) << __func__ << ": selection OK" << dendl;
-    m_osds->queue_scrub_chunk_free(m_pg, Scrub::scrub_prio_t::low_priority);
+    auto cost = get_scrub_cost(num_chunk_objects.value());
+    m_osds->queue_scrub_chunk_free(m_pg, Scrub::scrub_prio_t::low_priority, cost);
   } else {
     // we will wait for the objects range to become available for scrubbing
     dout(10) << __func__ << ": selected chunk is busy" << dendl;
@@ -1503,10 +1505,15 @@ void PgScrubber::replica_scrub_op(OpRequestRef op)
   replica_scrubmap_pos.reset();         // needed? RRR
 
   set_queued_or_active();
+  const auto& conf = m_pg->get_cct()->_conf;
+  const int max_from_conf = size_from_conf(
+    m_is_deep, conf, "osd_scrub_chunk_max", "osd_shallow_scrub_chunk_max");
+  auto cost = get_scrub_cost(max_from_conf);
   m_osds->queue_for_rep_scrub(m_pg,
                              m_replica_request_priority,
                              m_flags.priority,
-                             m_current_token);
+                             m_current_token,
+                             cost);
 }
 
 void PgScrubber::set_op_parameters(const requested_scrub_t& request)