]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Replacing friend declerations for passkey interface 43056/head
authorMatan Breizman <Matan.Brz@gmail.com>
Wed, 1 Sep 2021 16:18:40 +0000 (16:18 +0000)
committerMatan Breizman <Matan.Brz@gmail.com>
Thu, 9 Sep 2021 07:16:26 +0000 (07:16 +0000)
removing friend decleration from PrimaryLogScrub and ReplicaReservations

Signed-off-by: Matan Breizman <Matan.Brz@gmail.com>
src/osd/PG.h
src/osd/PrimaryLogScrub.cc
src/osd/pg_scrubber.cc
src/osd/pg_scrubber.h

index c288ff265e76e09ce9cc2e9812d9262aa540d476..690ccc325158e83559f00e330214df42a516f650 100644 (file)
@@ -161,12 +161,20 @@ class PGRecoveryStats {
  *
  */
 
+/// Facilitating scrub-realated object access to private PG data
+class ScrubberPasskey {
+private:
+  friend class Scrub::ReplicaReservations;
+  friend class PrimaryLogScrub;
+  ScrubberPasskey() {}
+  ScrubberPasskey(const ScrubberPasskey&) = default;
+  ScrubberPasskey& operator=(const ScrubberPasskey&) = delete;
+};
+
 class PG : public DoutPrefixProvider, public PeeringState::PeeringListener {
   friend struct NamedState;
   friend class PeeringState;
   friend class PgScrubber;
-  friend class PrimaryLogScrub;
-  friend class Scrub::ReplicaReservations;
   friend class Scrub::LocalReservation;  // dout()-only friendship
   friend class Scrub::ReservedByRemotePrimary;  //  dout()-only friendship
 
@@ -1318,6 +1326,18 @@ protected:
 
   // ref to recovery_state.info
   const pg_info_t &info;
+
+
+// ScrubberPasskey getters:
+public:
+  const pg_info_t& get_pg_info(ScrubberPasskey) const {
+    return info;
+  }
+
+  OSDService* get_pg_osd(ScrubberPasskey) const {
+    return osd;
+  }
+
 };
 
 #endif
index dd5aa84e8babf3eb83b8d3519849789024cd2261..4a6166a9f505deeaf106dbcee4e39f51f2962c58 100644 (file)
@@ -9,7 +9,7 @@
 #include "PrimaryLogPG.h"
 #include "scrub_machine.h"
 
-#define dout_context (m_pg->cct)
+#define dout_context (m_pg->get_cct())
 #define dout_subsys ceph_subsys_osd
 #undef dout_prefix
 #define dout_prefix _prefix(_dout, this->m_pg)
@@ -43,7 +43,7 @@ bool PrimaryLogScrub::get_store_errors(const scrub_ls_arg_t& arg,
 
 void PrimaryLogScrub::_scrub_finish()
 {
-  auto& info = m_pg->info;  ///< a temporary alias
+  auto& info = m_pg->get_pg_info(ScrubberPasskey{});  ///< a temporary alias
 
   dout(10) << __func__
           << " info stats: " << (info.stats.stats_invalid ? "invalid" : "valid")
index 1ad3775853979a36a330593a3cb56baa3c4bff67..fa6ff80e76918a8e6d69d5223239a2846bc207bf 100644 (file)
@@ -30,7 +30,7 @@ using namespace std::chrono;
 using namespace std::chrono_literals;
 using namespace std::literals;
 
-#define dout_context (m_pg->cct)
+#define dout_context (m_pg->get_cct())
 #define dout_subsys ceph_subsys_osd
 #undef dout_prefix
 #define dout_prefix _prefix(_dout, this->m_pg)
@@ -2079,7 +2079,7 @@ namespace Scrub {
 
 void ReplicaReservations::release_replica(pg_shard_t peer, epoch_t epoch)
 {
-  auto m = new MOSDScrubReserve(spg_t(m_pg->info.pgid.pgid, peer.shard), epoch,
+  auto m = new MOSDScrubReserve(spg_t(m_pg_info.pgid.pgid, peer.shard), epoch,
                                MOSDScrubReserve::RELEASE, m_pg->pg_whoami);
   m_osds->send_message_osd_cluster(peer.osd, m, epoch);
 }
@@ -2087,8 +2087,9 @@ void ReplicaReservations::release_replica(pg_shard_t peer, epoch_t epoch)
 ReplicaReservations::ReplicaReservations(PG* pg, pg_shard_t whoami)
     : m_pg{pg}
     , m_acting_set{pg->get_actingset()}
-    , m_osds{m_pg->osd}
+    , m_osds{m_pg->get_pg_osd(ScrubberPasskey())}
     , m_pending{static_cast<int>(m_acting_set.size()) - 1}
+    , m_pg_info{m_pg->get_pg_info(ScrubberPasskey())}
 {
   epoch_t epoch = m_pg->get_osdmap_epoch();
 
@@ -2102,7 +2103,7 @@ ReplicaReservations::ReplicaReservations(PG* pg, pg_shard_t whoami)
     for (auto p : m_acting_set) {
       if (p == whoami)
        continue;
-      auto m = new MOSDScrubReserve(spg_t(m_pg->info.pgid.pgid, p.shard), epoch,
+      auto m = new MOSDScrubReserve(spg_t(m_pg_info.pgid.pgid, p.shard), epoch,
                                    MOSDScrubReserve::REQUEST, m_pg->pg_whoami);
       m_osds->send_message_osd_cluster(p.osd, m, epoch);
       m_waited_for_peers.push_back(p);
index aba2450c7b9944f2cdccb51ae8e85f6b8e9b0d85..e151a4d1b1eb986969fc0440788561b6aefadbaf 100644 (file)
@@ -45,6 +45,7 @@ class ReplicaReservations {
   std::vector<pg_shard_t> m_reserved_peers;
   bool m_had_rejections{false};
   int m_pending{-1};
+  const pg_info_t& m_pg_info;
 
   void release_replica(pg_shard_t peer, epoch_t epoch);