From: Radosław Zarzyński Date: Fri, 15 Sep 2023 12:07:46 +0000 (+0200) Subject: osd: lay down the ECListener for ECBackend::ReadPipeline X-Git-Tag: v19.3.0~13^2~31 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1b3040a24814a28b283e3eca57b257820b040b27;p=ceph.git osd: lay down the ECListener for ECBackend::ReadPipeline Signed-off-by: Radosław Zarzyński --- diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index a1d777cba248..e597129626f5 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -224,7 +224,7 @@ ECBackend::ECBackend( ErasureCodeInterfaceRef ec_impl, uint64_t stripe_width) : PGBackend(cct, pg, store, coll, ch), - read_pipeline(cct, ec_impl, this->sinfo, get_parent()), + read_pipeline(cct, ec_impl, this->sinfo, get_parent()->get_eclistener()), rmw_pipeline(cct, ec_impl, this->sinfo, get_parent(), *this), ec_impl(ec_impl), sinfo(ec_impl->get_data_chunk_count(), stripe_width) { @@ -1897,7 +1897,7 @@ void ECBackend::ReadPipeline::do_read_op(ReadOp &op) MOSDECSubOpRead *msg = new MOSDECSubOpRead; msg->set_priority(priority); msg->pgid = spg_t( - get_parent()->whoami_spg_t().pgid, + get_info().pgid.pgid, i->first.shard); msg->map_epoch = get_osdmap_epoch(); msg->min_epoch = get_parent()->get_interval_start_epoch(); diff --git a/src/osd/ECBackend.h b/src/osd/ECBackend.h index 0bc4f9f423be..238895d3e5b3 100644 --- a/src/osd/ECBackend.h +++ b/src/osd/ECBackend.h @@ -32,6 +32,54 @@ struct ECSubRead; struct ECSubReadReply; struct RecoveryMessages; + + // ECListener -- an interface decoupling the pipelines from + // particular implementation of ECBackend (crimson vs cassical). + // https://stackoverflow.com/q/7872958 + struct ECListener { + virtual ~ECListener() = default; + virtual const OSDMapRef& pgb_get_osdmap() const = 0; + virtual epoch_t pgb_get_osdmap_epoch() const = 0; + virtual const pg_info_t &get_info() const = 0; + /** + * Called when a pull on soid cannot be completed due to + * down peers + */ + virtual void cancel_pull( + const hobject_t &soid) = 0; + virtual void schedule_recovery_work( + GenContext *c, + uint64_t cost) = 0; + + virtual epoch_t get_interval_start_epoch() const = 0; + virtual const std::set &get_acting_shards() const = 0; + virtual const std::set &get_backfill_shards() const = 0; + virtual const std::map> &get_missing_loc_shards() + const = 0; + + virtual const std::map &get_shard_missing() const = 0; + virtual const pg_missing_const_i &get_shard_missing(pg_shard_t peer) const = 0; +#if 1 + virtual const pg_missing_const_i * maybe_get_shard_missing( + pg_shard_t peer) const = 0; + virtual const pg_info_t &get_shard_info(pg_shard_t peer) const = 0; +#endif + virtual ceph_tid_t get_tid() = 0; + virtual pg_shard_t whoami_shard() const = 0; +#if 0 + int whoami() const { + return whoami_shard().osd; + } + spg_t whoami_spg_t() const { + return get_info().pgid; + } +#endif + virtual void send_message_osd_cluster( + std::vector>& messages, epoch_t from_epoch) = 0; + + virtual std::ostream& gen_dbg_prefix(std::ostream& out) const = 0; + }; class ECBackend : public PGBackend { public: RecoveryHandle *open_recovery_op() override; @@ -446,9 +494,9 @@ public: ceph::ErasureCodeInterfaceRef ec_impl; const ECUtil::stripe_info_t& sinfo; // TODO: lay an interface down here - PGBackend::Listener* parent; + ECListener* parent; - PGBackend::Listener *get_parent() const { return parent; } + ECListener *get_parent() const { return parent; } const OSDMapRef& get_osdmap() const { return get_parent()->pgb_get_osdmap(); } epoch_t get_osdmap_epoch() const { return get_parent()->pgb_get_osdmap_epoch(); } const pg_info_t &get_info() { return get_parent()->get_info(); } @@ -456,7 +504,7 @@ public: ReadPipeline(CephContext* cct, ceph::ErasureCodeInterfaceRef ec_impl, const ECUtil::stripe_info_t& sinfo, - PGBackend::Listener* parent) + ECListener* parent) : cct(cct), ec_impl(std::move(ec_impl)), sinfo(sinfo), diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index ac17f05035db..274d1fb874bc 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -171,25 +171,7 @@ typedef std::shared_ptr OSDMapRef; virtual void add_local_next_event(const pg_log_entry_t& e) = 0; virtual const std::map &get_shard_missing() const = 0; - virtual const pg_missing_const_i * maybe_get_shard_missing( - pg_shard_t peer) const { - if (peer == primary_shard()) { - return &get_local_missing(); - } else { - std::map::const_iterator i = - get_shard_missing().find(peer); - if (i == get_shard_missing().end()) { - return nullptr; - } else { - return &(i->second); - } - } - } - virtual const pg_missing_const_i &get_shard_missing(pg_shard_t peer) const { - auto m = maybe_get_shard_missing(peer); - ceph_assert(m); - return *m; - } + virtual const pg_missing_const_i &get_shard_missing(pg_shard_t peer) const = 0; virtual const std::map &get_shard_info() const = 0; virtual const pg_info_t &get_shard_info(pg_shard_t peer) const { @@ -305,6 +287,7 @@ typedef std::shared_ptr OSDMapRef; virtual void pg_add_num_bytes(int64_t num_bytes) = 0; virtual void pg_sub_num_bytes(int64_t num_bytes) = 0; virtual bool maybe_preempt_replica_scrub(const hobject_t& oid) = 0; + virtual struct ECListener *get_eclistener() = 0; virtual ~Listener() {} }; Listener *parent; diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 4ecbe58a1f38..f3d03df1d368 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -15799,6 +15799,11 @@ bool PrimaryLogPG::maybe_preempt_replica_scrub(const hobject_t& oid) return m_scrubber->write_blocked_by_scrub(oid); } +struct ECListener *PrimaryLogPG::get_eclistener() +{ + return this; +} + void intrusive_ptr_add_ref(PrimaryLogPG *pg) { pg->get("intptr"); } void intrusive_ptr_release(PrimaryLogPG *pg) { pg->put("intptr"); } diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index 6ed29927463d..420871b1990e 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -29,6 +29,7 @@ #include "common/sharedptr_registry.hpp" #include "common/shared_cache.hpp" #include "ReplicatedBackend.h" +#include "ECBackend.h" #include "PGTransaction.h" #include "cls/cas/cls_cas_ops.h" @@ -55,7 +56,9 @@ void put_with_id(PrimaryLogPG *pg, uint64_t id); struct inconsistent_snapset_wrapper; -class PrimaryLogPG : public PG, public PGBackend::Listener { +class PrimaryLogPG : public PG, + public PGBackend::Listener, + public ECListener { friend class OSD; friend class Watch; friend class PrimaryLogScrub; @@ -391,11 +394,24 @@ public: const std::map &get_shard_missing() const override { return recovery_state.get_peer_missing(); } - using PGBackend::Listener::get_shard_missing; + const pg_missing_const_i &get_shard_missing(pg_shard_t peer) const override { + auto m = maybe_get_shard_missing(peer); + ceph_assert(m); + return *m; + } const std::map &get_shard_info() const override { return recovery_state.get_peer_info(); } - using PGBackend::Listener::get_shard_info; + const pg_info_t &get_shard_info(pg_shard_t peer) const override { + if (peer == primary_shard()) { + return get_info(); + } else { + std::map::const_iterator i = + get_shard_info().find(peer); + ceph_assert(i != get_shard_info().end()); + return i->second; + } + } const pg_missing_tracker_t &get_local_missing() const override { return recovery_state.get_pg_log().get_missing(); } @@ -1892,6 +1908,21 @@ public: void on_shutdown() override; bool check_failsafe_full() override; bool maybe_preempt_replica_scrub(const hobject_t& oid) override; + struct ECListener *get_eclistener() override; + const pg_missing_const_i * maybe_get_shard_missing( + pg_shard_t peer) const { + if (peer == primary_shard()) { + return &get_local_missing(); + } else { + std::map::const_iterator i = + get_shard_missing().find(peer); + if (i == get_shard_missing().end()) { + return nullptr; + } else { + return &(i->second); + } + } + } int rep_repair_primary_object(const hobject_t& soid, OpContext *ctx); // attr cache handling