]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PrimaryLogPG: move BackfillInterval to recovery_types.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 10 Mar 2020 14:07:45 +0000 (15:07 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 7 Jul 2020 10:46:10 +0000 (12:46 +0200)
It will be needed in crimson as well.

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/CMakeLists.txt
src/osd/CMakeLists.txt
src/osd/PG.cc
src/osd/PG.h
src/osd/PeeringState.h
src/osd/recovery_types.cc [new file with mode: 0644]
src/osd/recovery_types.h [new file with mode: 0644]

index 1eaf862ab84be1322c6d15a98e7e350760203600..b740e45b0fab954bd749a088b5ec1f58fa22e875 100644 (file)
@@ -35,6 +35,7 @@ add_executable(crimson-osd
   ${PROJECT_SOURCE_DIR}/src/osd/PGStateUtils.cc
   ${PROJECT_SOURCE_DIR}/src/osd/MissingLoc.cc
   ${PROJECT_SOURCE_DIR}/src/osd/PGLog.cc
+  ${PROJECT_SOURCE_DIR}/src/osd/recovery_types.cc
   ${PROJECT_SOURCE_DIR}/src/osd/osd_perf_counters.cc
   watch.cc
   )
index c5f2804a5f4a2639b6bf42a8db14e5d8e7703369..c76e96fe1f8701d113ee27f25fa4d2d6a59f3d98 100644 (file)
@@ -33,6 +33,7 @@ set(osd_srcs
   scheduler/mClockScheduler.cc
   PeeringState.cc
   PGStateUtils.cc
+  recovery_types.cc
   MissingLoc.cc
   osd_perf_counters.cc
   ${CMAKE_SOURCE_DIR}/src/common/TrackedOp.cc
index 59b133e0d08953240062b487ba84c1e4cd5dc414..3734c07699a4f144b72da353a0eae2f2f802ea28 100644 (file)
@@ -3926,16 +3926,6 @@ int PG::pg_stat_adjust(osd_stat_t *ns)
   return 0;
 }
 
-ostream& operator<<(ostream& out, const PG::BackfillInterval& bi)
-{
-  out << "BackfillInfo(" << bi.begin << "-" << bi.end
-      << " " << bi.objects.size() << " objects";
-  if (!bi.objects.empty())
-    out << " " << bi.objects;
-  out << ")";
-  return out;
-}
-
 void PG::dump_pgstate_history(Formatter *f)
 {
   std::scoped_lock l{*this};
index 1177b9c22fec1ad7d8231178ae23ad0ef81ead92..0fcf7967d2f445feb4aff9db501a93d02c855171 100644 (file)
@@ -38,6 +38,7 @@
 #include "PGBackend.h"
 #include "PGPeeringEvent.h"
 #include "PeeringState.h"
+#include "recovery_types.h"
 #include "MissingLoc.h"
 
 #include "mgr/OSDPerfMetricTypes.h"
@@ -683,91 +684,6 @@ protected:
   std::set<int> heartbeat_peers;
   std::set<int> probe_targets;
 
-public:
-  /**
-   * BackfillInterval
-   *
-   * Represents the objects in a range [begin, end)
-   *
-   * Possible states:
-   * 1) begin == end == hobject_t() indicates the the interval is unpopulated
-   * 2) Else, objects contains all objects in [begin, end)
-   */
-  struct BackfillInterval {
-    // info about a backfill interval on a peer
-    eversion_t version; /// version at which the scan occurred
-    std::map<hobject_t,eversion_t> objects;
-    hobject_t begin;
-    hobject_t end;
-
-    /// clear content
-    void clear() {
-      *this = BackfillInterval();
-    }
-
-    /// clear objects std::list only
-    void clear_objects() {
-      objects.clear();
-    }
-
-    /// reinstantiate with a new start+end position and sort order
-    void reset(hobject_t start) {
-      clear();
-      begin = end = start;
-    }
-
-    /// true if there are no objects in this interval
-    bool empty() const {
-      return objects.empty();
-    }
-
-    /// true if interval extends to the end of the range
-    bool extends_to_end() const {
-      return end.is_max();
-    }
-
-    /// removes items <= soid and adjusts begin to the first object
-    void trim_to(const hobject_t &soid) {
-      trim();
-      while (!objects.empty() &&
-            objects.begin()->first <= soid) {
-       pop_front();
-      }
-    }
-
-    /// Adjusts begin to the first object
-    void trim() {
-      if (!objects.empty())
-       begin = objects.begin()->first;
-      else
-       begin = end;
-    }
-
-    /// drop first entry, and adjust @begin accordingly
-    void pop_front() {
-      ceph_assert(!objects.empty());
-      objects.erase(objects.begin());
-      trim();
-    }
-
-    /// dump
-    void dump(ceph::Formatter *f) const {
-      f->dump_stream("begin") << begin;
-      f->dump_stream("end") << end;
-      f->open_array_section("objects");
-      for (std::map<hobject_t, eversion_t>::const_iterator i =
-            objects.begin();
-          i != objects.end();
-          ++i) {
-       f->open_object_section("object");
-       f->dump_stream("object") << i->first;
-       f->dump_stream("version") << i->second;
-       f->close_section();
-      }
-      f->close_section();
-    }
-  };
-
 protected:
   BackfillInterval backfill_info;
   std::map<pg_shard_t, BackfillInterval> peer_backfill_info;
@@ -1509,7 +1425,4 @@ protected:
   const pg_info_t &info;
 };
 
-
-ostream& operator<<(ostream& out, const PG::BackfillInterval& bi);
-
 #endif
index 6a02a052757589dab03c4be869e17cfbbd49caa4..bea01410ba3fbf145b4d9686ad5d063bac899c16 100644 (file)
@@ -245,7 +245,7 @@ struct PeeringCtxWrapper {
   }
 };
 
-  /* Encapsulates PG recovery process */
+/* Encapsulates PG recovery process */
 class PeeringState : public MissingLoc::MappingInfo {
 public:
   struct PeeringListener : public EpochSource {
diff --git a/src/osd/recovery_types.cc b/src/osd/recovery_types.cc
new file mode 100644 (file)
index 0000000..3dd49a8
--- /dev/null
@@ -0,0 +1,16 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "recovery_types.h"
+
+ostream& operator<<(ostream& out, const BackfillInterval& bi)
+{
+  out << "BackfillInfo(" << bi.begin << "-" << bi.end
+      << " " << bi.objects.size() << " objects";
+  if (!bi.objects.empty())
+    out << " " << bi.objects;
+  out << ")";
+  return out;
+}
+
+
diff --git a/src/osd/recovery_types.h b/src/osd/recovery_types.h
new file mode 100644 (file)
index 0000000..73a6218
--- /dev/null
@@ -0,0 +1,95 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include <map>
+
+#include "osd_types.h"
+
+/**
+ * BackfillInterval
+ *
+ * Represents the objects in a range [begin, end)
+ *
+ * Possible states:
+ * 1) begin == end == hobject_t() indicates the the interval is unpopulated
+ * 2) Else, objects contains all objects in [begin, end)
+ */
+struct BackfillInterval {
+  // info about a backfill interval on a peer
+  eversion_t version; /// version at which the scan occurred
+  std::map<hobject_t,eversion_t> objects;
+  hobject_t begin;
+  hobject_t end;
+
+  /// clear content
+  void clear() {
+    *this = BackfillInterval();
+  }
+
+  /// clear objects std::list only
+  void clear_objects() {
+    objects.clear();
+  }
+
+  /// reinstantiate with a new start+end position and sort order
+  void reset(hobject_t start) {
+    clear();
+    begin = end = start;
+  }
+
+  /// true if there are no objects in this interval
+  bool empty() const {
+    return objects.empty();
+  }
+
+  /// true if interval extends to the end of the range
+  bool extends_to_end() const {
+    return end.is_max();
+  }
+
+  /// removes items <= soid and adjusts begin to the first object
+  void trim_to(const hobject_t &soid) {
+    trim();
+    while (!objects.empty() &&
+           objects.begin()->first <= soid) {
+      pop_front();
+    }
+  }
+
+  /// Adjusts begin to the first object
+  void trim() {
+    if (!objects.empty())
+      begin = objects.begin()->first;
+    else
+      begin = end;
+  }
+
+  /// drop first entry, and adjust @begin accordingly
+  void pop_front() {
+    ceph_assert(!objects.empty());
+    objects.erase(objects.begin());
+    trim();
+  }
+
+  /// dump
+  void dump(ceph::Formatter *f) const {
+    f->dump_stream("begin") << begin;
+    f->dump_stream("end") << end;
+    f->open_array_section("objects");
+    for (std::map<hobject_t, eversion_t>::const_iterator i =
+           objects.begin();
+         i != objects.end();
+         ++i) {
+      f->open_object_section("object");
+      f->dump_stream("object") << i->first;
+      f->dump_stream("version") << i->second;
+      f->close_section();
+    }
+    f->close_section();
+  }
+};
+
+std::ostream &operator<<(std::ostream &out, const BackfillInterval &bi);
+