|
| 1 | +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
| 2 | +// vim: ts=8 sw=2 smarttab |
| 3 | +/* |
| 4 | + * Ceph - scalable distributed file system |
| 5 | + * |
| 6 | + * Copyright (C) 2013 Inktank Storage, Inc. |
| 7 | + * |
| 8 | + * This is free software; you can redistribute it and/or |
| 9 | + * modify it under the terms of the GNU Lesser General Public |
| 10 | + * License version 2.1, as published by the Free Software |
| 11 | + * Foundation. See file COPYING. |
| 12 | + * |
| 13 | + */ |
| 14 | + |
| 15 | +#pragma once |
| 16 | + |
| 17 | +#include "osd_internal_types.h" |
| 18 | +#include "OSDMap.h" |
| 19 | +#include "common/WorkQueue.h" |
| 20 | +#include "PGLog.h" |
| 21 | + |
| 22 | +// ECListener -- an interface decoupling the pipelines from |
| 23 | +// particular implementation of ECBackendL (crimson vs cassical). |
| 24 | +// https://stackoverflow.com/q/7872958 |
| 25 | +struct ECListener { |
| 26 | + virtual ~ECListener() = default; |
| 27 | + virtual const OSDMapRef& pgb_get_osdmap() const = 0; |
| 28 | + virtual epoch_t pgb_get_osdmap_epoch() const = 0; |
| 29 | + virtual const pg_info_t &get_info() const = 0; |
| 30 | + /** |
| 31 | + * Called when a pull on soid cannot be completed due to |
| 32 | + * down peers |
| 33 | + */ |
| 34 | + // XXX |
| 35 | + virtual void cancel_pull( |
| 36 | + const hobject_t &soid) = 0; |
| 37 | + |
| 38 | +#ifndef WITH_SEASTAR |
| 39 | + // XXX |
| 40 | + virtual pg_shard_t primary_shard() const = 0; |
| 41 | + virtual bool pgb_is_primary() const = 0; |
| 42 | + |
| 43 | + /** |
| 44 | + * Called when a read from a std::set of replicas/primary fails |
| 45 | + */ |
| 46 | + virtual void on_failed_pull( |
| 47 | + const std::set<pg_shard_t> &from, |
| 48 | + const hobject_t &soid, |
| 49 | + const eversion_t &v |
| 50 | + ) = 0; |
| 51 | + |
| 52 | + /** |
| 53 | + * Called with the transaction recovering oid |
| 54 | + */ |
| 55 | + virtual void on_local_recover( |
| 56 | + const hobject_t &oid, |
| 57 | + const ObjectRecoveryInfo &recovery_info, |
| 58 | + ObjectContextRef obc, |
| 59 | + bool is_delete, |
| 60 | + ceph::os::Transaction *t |
| 61 | + ) = 0; |
| 62 | + |
| 63 | + /** |
| 64 | + * Called when transaction recovering oid is durable and |
| 65 | + * applied on all replicas |
| 66 | + */ |
| 67 | + virtual void on_global_recover( |
| 68 | + const hobject_t &oid, |
| 69 | + const object_stat_sum_t &stat_diff, |
| 70 | + bool is_delete |
| 71 | + ) = 0; |
| 72 | + |
| 73 | + /** |
| 74 | + * Called when peer is recovered |
| 75 | + */ |
| 76 | + virtual void on_peer_recover( |
| 77 | + pg_shard_t peer, |
| 78 | + const hobject_t &oid, |
| 79 | + const ObjectRecoveryInfo &recovery_info |
| 80 | + ) = 0; |
| 81 | + |
| 82 | + virtual void begin_peer_recover( |
| 83 | + pg_shard_t peer, |
| 84 | + const hobject_t oid) = 0; |
| 85 | + |
| 86 | + virtual bool pg_is_repair() const = 0; |
| 87 | + |
| 88 | + virtual ObjectContextRef get_obc( |
| 89 | + const hobject_t &hoid, |
| 90 | + const std::map<std::string, ceph::buffer::list, std::less<>> &attrs) = 0; |
| 91 | + |
| 92 | + virtual bool check_failsafe_full() = 0; |
| 93 | + virtual hobject_t get_temp_recovery_object(const hobject_t& target, |
| 94 | + eversion_t version) = 0; |
| 95 | + virtual bool pg_is_remote_backfilling() = 0; |
| 96 | + virtual void pg_add_local_num_bytes(int64_t num_bytes) = 0; |
| 97 | + //virtual void pg_sub_local_num_bytes(int64_t num_bytes) = 0; |
| 98 | + virtual void pg_add_num_bytes(int64_t num_bytes) = 0; |
| 99 | + //virtual void pg_sub_num_bytes(int64_t num_bytes) = 0; |
| 100 | + virtual void inc_osd_stat_repaired() = 0; |
| 101 | + |
| 102 | + virtual void add_temp_obj(const hobject_t &oid) = 0; |
| 103 | + virtual void clear_temp_obj(const hobject_t &oid) = 0; |
| 104 | + virtual epoch_t get_last_peering_reset_epoch() const = 0; |
| 105 | +#endif |
| 106 | + |
| 107 | + // XXX |
| 108 | +#ifndef WITH_SEASTAR |
| 109 | + virtual GenContext<ThreadPool::TPHandle&> *bless_unlocked_gencontext( |
| 110 | + GenContext<ThreadPool::TPHandle&> *c) = 0; |
| 111 | + |
| 112 | + virtual void schedule_recovery_work( |
| 113 | + GenContext<ThreadPool::TPHandle&> *c, |
| 114 | + uint64_t cost) = 0; |
| 115 | +#endif |
| 116 | + |
| 117 | + virtual epoch_t get_interval_start_epoch() const = 0; |
| 118 | + virtual const std::set<pg_shard_t> &get_acting_shards() const = 0; |
| 119 | + virtual const std::set<pg_shard_t> &get_backfill_shards() const = 0; |
| 120 | + virtual const std::map<hobject_t, std::set<pg_shard_t>> &get_missing_loc_shards() |
| 121 | + const = 0; |
| 122 | + |
| 123 | + virtual const std::map<pg_shard_t, |
| 124 | + pg_missing_t> &get_shard_missing() const = 0; |
| 125 | + virtual const pg_missing_const_i &get_shard_missing(pg_shard_t peer) const = 0; |
| 126 | +#if 1 |
| 127 | + virtual const pg_missing_const_i * maybe_get_shard_missing( |
| 128 | + pg_shard_t peer) const = 0; |
| 129 | + virtual const pg_info_t &get_shard_info(pg_shard_t peer) const = 0; |
| 130 | +#endif |
| 131 | + virtual ceph_tid_t get_tid() = 0; |
| 132 | + virtual pg_shard_t whoami_shard() const = 0; |
| 133 | +#if 0 |
| 134 | + int whoami() const { |
| 135 | + return whoami_shard().osd; |
| 136 | + } |
| 137 | + spg_t whoami_spg_t() const { |
| 138 | + return get_info().pgid; |
| 139 | + } |
| 140 | +#endif |
| 141 | + // XXX |
| 142 | + virtual void send_message_osd_cluster( |
| 143 | + std::vector<std::pair<int, Message*>>& messages, epoch_t from_epoch) = 0; |
| 144 | + |
| 145 | + virtual std::ostream& gen_dbg_prefix(std::ostream& out) const = 0; |
| 146 | + |
| 147 | + // RMWPipeline |
| 148 | + virtual const pg_pool_t &get_pool() const = 0; |
| 149 | + virtual const std::set<pg_shard_t> &get_acting_recovery_backfill_shards() const = 0; |
| 150 | + // XXX |
| 151 | + virtual bool should_send_op( |
| 152 | + pg_shard_t peer, |
| 153 | + const hobject_t &hoid) = 0; |
| 154 | + virtual const std::map<pg_shard_t, pg_info_t> &get_shard_info() const = 0; |
| 155 | + virtual spg_t primary_spg_t() const = 0; |
| 156 | + virtual const PGLog &get_log() const = 0; |
| 157 | + virtual DoutPrefixProvider *get_dpp() = 0; |
| 158 | + // XXX |
| 159 | + virtual void apply_stats( |
| 160 | + const hobject_t &soid, |
| 161 | + const object_stat_sum_t &delta_stats) = 0; |
| 162 | + |
| 163 | + // new batch |
| 164 | + virtual bool is_missing_object(const hobject_t& oid) const = 0; |
| 165 | + virtual void add_local_next_event(const pg_log_entry_t& e) = 0; |
| 166 | + virtual void log_operation( |
| 167 | + std::vector<pg_log_entry_t>&& logv, |
| 168 | + const std::optional<pg_hit_set_history_t> &hset_history, |
| 169 | + const eversion_t &trim_to, |
| 170 | + const eversion_t &roll_forward_to, |
| 171 | + const eversion_t &pg_committed_to, |
| 172 | + bool transaction_applied, |
| 173 | + ceph::os::Transaction &t, |
| 174 | + bool async = false) = 0; |
| 175 | + virtual void op_applied( |
| 176 | + const eversion_t &applied_version) = 0; |
| 177 | +}; |
0 commit comments