]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #pragma once | |
5 | ||
20effc67 TL |
6 | #include "crimson/common/interruptible_future.h" |
7 | #include "crimson/osd/pg_interval_interrupt_condition.h" | |
f67539c2 TL |
8 | #include "crimson/osd/recovery_backend.h" |
9 | ||
10 | #include "messages/MOSDPGPull.h" | |
11 | #include "messages/MOSDPGPush.h" | |
12 | #include "messages/MOSDPGPushReply.h" | |
13 | #include "messages/MOSDPGRecoveryDelete.h" | |
14 | #include "messages/MOSDPGRecoveryDeleteReply.h" | |
15 | #include "os/ObjectStore.h" | |
16 | ||
17 | class ReplicatedRecoveryBackend : public RecoveryBackend { | |
18 | public: | |
19 | ReplicatedRecoveryBackend(crimson::osd::PG& pg, | |
20 | crimson::osd::ShardServices& shard_services, | |
21 | crimson::os::CollectionRef coll, | |
22 | PGBackend* backend) | |
20effc67 TL |
23 | : RecoveryBackend(pg, shard_services, coll, backend) |
24 | {} | |
25 | interruptible_future<> handle_recovery_op( | |
f67539c2 TL |
26 | Ref<MOSDFastDispatchOp> m) final; |
27 | ||
20effc67 | 28 | interruptible_future<> recover_object( |
f67539c2 TL |
29 | const hobject_t& soid, |
30 | eversion_t need) final; | |
20effc67 | 31 | interruptible_future<> recover_delete( |
f67539c2 TL |
32 | const hobject_t& soid, |
33 | eversion_t need) final; | |
20effc67 | 34 | interruptible_future<> push_delete( |
f67539c2 TL |
35 | const hobject_t& soid, |
36 | eversion_t need) final; | |
37 | protected: | |
20effc67 | 38 | interruptible_future<> handle_pull( |
f67539c2 | 39 | Ref<MOSDPGPull> m); |
20effc67 | 40 | interruptible_future<> handle_pull_response( |
f67539c2 | 41 | Ref<MOSDPGPush> m); |
20effc67 | 42 | interruptible_future<> handle_push( |
f67539c2 | 43 | Ref<MOSDPGPush> m); |
20effc67 | 44 | interruptible_future<> handle_push_reply( |
f67539c2 | 45 | Ref<MOSDPGPushReply> m); |
20effc67 | 46 | interruptible_future<> handle_recovery_delete( |
f67539c2 | 47 | Ref<MOSDPGRecoveryDelete> m); |
20effc67 | 48 | interruptible_future<> handle_recovery_delete_reply( |
f67539c2 | 49 | Ref<MOSDPGRecoveryDeleteReply> m); |
20effc67 | 50 | interruptible_future<PushOp> prep_push( |
f67539c2 TL |
51 | const hobject_t& soid, |
52 | eversion_t need, | |
53 | pg_shard_t pg_shard); | |
54 | void prepare_pull( | |
55 | PullOp& po, | |
56 | PullInfo& pi, | |
57 | const hobject_t& soid, | |
58 | eversion_t need); | |
59 | std::vector<pg_shard_t> get_shards_to_push( | |
60 | const hobject_t& soid) const; | |
20effc67 | 61 | interruptible_future<PushOp> build_push_op( |
f67539c2 TL |
62 | const ObjectRecoveryInfo& recovery_info, |
63 | const ObjectRecoveryProgress& progress, | |
64 | object_stat_sum_t* stat); | |
65 | /// @returns true if this push op is the last push op for | |
66 | /// recovery @c pop.soid | |
20effc67 | 67 | interruptible_future<bool> _handle_pull_response( |
f67539c2 | 68 | pg_shard_t from, |
20effc67 | 69 | PushOp& pop, |
f67539c2 TL |
70 | PullOp* response, |
71 | ceph::os::Transaction* t); | |
72 | std::pair<interval_set<uint64_t>, ceph::bufferlist> trim_pushed_data( | |
73 | const interval_set<uint64_t> ©_subset, | |
74 | const interval_set<uint64_t> &intervals_received, | |
75 | ceph::bufferlist data_received); | |
20effc67 | 76 | interruptible_future<> submit_push_data( |
f67539c2 TL |
77 | const ObjectRecoveryInfo &recovery_info, |
78 | bool first, | |
79 | bool complete, | |
80 | bool clear_omap, | |
20effc67 TL |
81 | interval_set<uint64_t>&& data_zeros, |
82 | interval_set<uint64_t>&& intervals_included, | |
83 | ceph::bufferlist&& data_included, | |
84 | ceph::bufferlist&& omap_header, | |
85 | const std::map<std::string, bufferlist, std::less<>> &attrs, | |
86 | std::map<std::string, bufferlist>&& omap_entries, | |
f67539c2 TL |
87 | ceph::os::Transaction *t); |
88 | void submit_push_complete( | |
89 | const ObjectRecoveryInfo &recovery_info, | |
90 | ObjectStore::Transaction *t); | |
20effc67 | 91 | interruptible_future<> _handle_push( |
f67539c2 | 92 | pg_shard_t from, |
20effc67 | 93 | PushOp& pop, |
f67539c2 TL |
94 | PushReplyOp *response, |
95 | ceph::os::Transaction *t); | |
20effc67 | 96 | interruptible_future<std::optional<PushOp>> _handle_push_reply( |
f67539c2 TL |
97 | pg_shard_t peer, |
98 | const PushReplyOp &op); | |
20effc67 | 99 | interruptible_future<> on_local_recover_persist( |
f67539c2 TL |
100 | const hobject_t& soid, |
101 | const ObjectRecoveryInfo& _recovery_info, | |
102 | bool is_delete, | |
103 | epoch_t epoch_to_freeze); | |
20effc67 | 104 | interruptible_future<> local_recover_delete( |
f67539c2 TL |
105 | const hobject_t& soid, |
106 | eversion_t need, | |
107 | epoch_t epoch_frozen); | |
108 | seastar::future<> on_stop() final { | |
109 | return seastar::now(); | |
110 | } | |
111 | private: | |
112 | /// pull missing object from peer | |
20effc67 | 113 | interruptible_future<> maybe_pull_missing_obj( |
f67539c2 TL |
114 | const hobject_t& soid, |
115 | eversion_t need); | |
116 | ||
117 | /// load object context for recovery if it is not ready yet | |
118 | using load_obc_ertr = crimson::errorator< | |
119 | crimson::ct_error::object_corrupted>; | |
20effc67 TL |
120 | using load_obc_iertr = |
121 | ::crimson::interruptible::interruptible_errorator< | |
122 | ::crimson::osd::IOInterruptCondition, | |
123 | load_obc_ertr>; | |
f67539c2 | 124 | |
20effc67 | 125 | interruptible_future<> maybe_push_shards( |
f67539c2 TL |
126 | const hobject_t& soid, |
127 | eversion_t need); | |
128 | ||
129 | /// read the data attached to given object. the size of them is supposed to | |
130 | /// be relatively small. | |
131 | /// | |
132 | /// @return @c oi.version | |
20effc67 | 133 | interruptible_future<eversion_t> read_metadata_for_push_op( |
f67539c2 TL |
134 | const hobject_t& oid, |
135 | const ObjectRecoveryProgress& progress, | |
136 | ObjectRecoveryProgress& new_progress, | |
137 | eversion_t ver, | |
138 | PushOp* push_op); | |
139 | /// read the remaining extents of object to be recovered and fill push_op | |
140 | /// with them | |
141 | /// | |
142 | /// @param oid object being recovered | |
143 | /// @param copy_subset extents we want | |
144 | /// @param offset the offset in object from where we should read | |
145 | /// @return the new offset | |
20effc67 | 146 | interruptible_future<uint64_t> read_object_for_push_op( |
f67539c2 TL |
147 | const hobject_t& oid, |
148 | const interval_set<uint64_t>& copy_subset, | |
149 | uint64_t offset, | |
150 | uint64_t max_len, | |
151 | PushOp* push_op); | |
20effc67 | 152 | interruptible_future<> read_omap_for_push_op( |
f67539c2 TL |
153 | const hobject_t& oid, |
154 | const ObjectRecoveryProgress& progress, | |
155 | ObjectRecoveryProgress& new_progress, | |
156 | uint64_t* max_len, | |
157 | PushOp* push_op); | |
20effc67 TL |
158 | interruptible_future<hobject_t> prep_push_target( |
159 | const ObjectRecoveryInfo &recovery_info, | |
160 | bool first, | |
161 | bool complete, | |
162 | bool clear_omap, | |
163 | ObjectStore::Transaction* t, | |
164 | const std::map<std::string, bufferlist, std::less<>> &attrs, | |
165 | bufferlist&& omap_header); | |
166 | using interruptor = crimson::interruptible::interruptor< | |
167 | crimson::osd::IOInterruptCondition>; | |
f67539c2 | 168 | }; |