From: Radoslaw Zarzynski Date: Tue, 10 Mar 2020 14:07:45 +0000 (+0100) Subject: osd/PrimaryLogPG: move BackfillInterval to recovery_types. X-Git-Tag: v16.1.0~1720^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f3c6bad82b2e12f3acaca7d0989e013753f8a1de;p=ceph.git osd/PrimaryLogPG: move BackfillInterval to recovery_types. It will be needed in crimson as well. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/osd/CMakeLists.txt b/src/crimson/osd/CMakeLists.txt index 1eaf862ab84b..b740e45b0fab 100644 --- a/src/crimson/osd/CMakeLists.txt +++ b/src/crimson/osd/CMakeLists.txt @@ -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 ) diff --git a/src/osd/CMakeLists.txt b/src/osd/CMakeLists.txt index c5f2804a5f4a..c76e96fe1f87 100644 --- a/src/osd/CMakeLists.txt +++ b/src/osd/CMakeLists.txt @@ -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 diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 59b133e0d089..3734c07699a4 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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}; diff --git a/src/osd/PG.h b/src/osd/PG.h index 1177b9c22fec..0fcf7967d2f4 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -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 heartbeat_peers; std::set 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 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::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 peer_backfill_info; @@ -1509,7 +1425,4 @@ protected: const pg_info_t &info; }; - -ostream& operator<<(ostream& out, const PG::BackfillInterval& bi); - #endif diff --git a/src/osd/PeeringState.h b/src/osd/PeeringState.h index 6a02a0527575..bea01410ba3f 100644 --- a/src/osd/PeeringState.h +++ b/src/osd/PeeringState.h @@ -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 index 000000000000..3dd49a82d06a --- /dev/null +++ b/src/osd/recovery_types.cc @@ -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 index 000000000000..73a62188289e --- /dev/null +++ b/src/osd/recovery_types.h @@ -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 + +#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 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::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); +