Skip to content

Commit c9e67c9

Browse files
committed
osd: Move ECListener to its own file.
This will be used by both legacy and optimised EC, so is move out to be common. Signed-off-by: Alex Ainscow <[email protected]>
1 parent 31a2b10 commit c9e67c9

File tree

3 files changed

+180
-157
lines changed

3 files changed

+180
-157
lines changed

src/osd/ECCommonL.h

Lines changed: 1 addition & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -47,167 +47,12 @@ typedef crimson::osd::ObjectContextRef ObjectContextRef;
4747

4848
#include "ECTransactionL.h"
4949
#include "ECExtentCacheL.h"
50+
#include "ECListener.h"
5051

5152
//forward declaration
5253
struct ECSubWrite;
5354
struct PGLog;
5455

55-
// ECListener -- an interface decoupling the pipelines from
56-
// particular implementation of ECBackendL (crimson vs cassical).
57-
// https://stackoverflow.com/q/7872958
58-
struct ECListener {
59-
virtual ~ECListener() = default;
60-
virtual const OSDMapRef& pgb_get_osdmap() const = 0;
61-
virtual epoch_t pgb_get_osdmap_epoch() const = 0;
62-
virtual const pg_info_t &get_info() const = 0;
63-
/**
64-
* Called when a pull on soid cannot be completed due to
65-
* down peers
66-
*/
67-
// XXX
68-
virtual void cancel_pull(
69-
const hobject_t &soid) = 0;
70-
71-
#ifndef WITH_SEASTAR
72-
// XXX
73-
virtual pg_shard_t primary_shard() const = 0;
74-
virtual bool pgb_is_primary() const = 0;
75-
76-
/**
77-
* Called when a read from a std::set of replicas/primary fails
78-
*/
79-
virtual void on_failed_pull(
80-
const std::set<pg_shard_t> &from,
81-
const hobject_t &soid,
82-
const eversion_t &v
83-
) = 0;
84-
85-
/**
86-
* Called with the transaction recovering oid
87-
*/
88-
virtual void on_local_recover(
89-
const hobject_t &oid,
90-
const ObjectRecoveryInfo &recovery_info,
91-
ObjectContextRef obc,
92-
bool is_delete,
93-
ceph::os::Transaction *t
94-
) = 0;
95-
96-
/**
97-
* Called when transaction recovering oid is durable and
98-
* applied on all replicas
99-
*/
100-
virtual void on_global_recover(
101-
const hobject_t &oid,
102-
const object_stat_sum_t &stat_diff,
103-
bool is_delete
104-
) = 0;
105-
106-
/**
107-
* Called when peer is recovered
108-
*/
109-
virtual void on_peer_recover(
110-
pg_shard_t peer,
111-
const hobject_t &oid,
112-
const ObjectRecoveryInfo &recovery_info
113-
) = 0;
114-
115-
virtual void begin_peer_recover(
116-
pg_shard_t peer,
117-
const hobject_t oid) = 0;
118-
119-
virtual bool pg_is_repair() const = 0;
120-
121-
virtual ObjectContextRef get_obc(
122-
const hobject_t &hoid,
123-
const std::map<std::string, ceph::buffer::list, std::less<>> &attrs) = 0;
124-
125-
virtual bool check_failsafe_full() = 0;
126-
virtual hobject_t get_temp_recovery_object(const hobject_t& target,
127-
eversion_t version) = 0;
128-
virtual bool pg_is_remote_backfilling() = 0;
129-
virtual void pg_add_local_num_bytes(int64_t num_bytes) = 0;
130-
//virtual void pg_sub_local_num_bytes(int64_t num_bytes) = 0;
131-
virtual void pg_add_num_bytes(int64_t num_bytes) = 0;
132-
//virtual void pg_sub_num_bytes(int64_t num_bytes) = 0;
133-
virtual void inc_osd_stat_repaired() = 0;
134-
135-
virtual void add_temp_obj(const hobject_t &oid) = 0;
136-
virtual void clear_temp_obj(const hobject_t &oid) = 0;
137-
virtual epoch_t get_last_peering_reset_epoch() const = 0;
138-
#endif
139-
140-
// XXX
141-
#ifndef WITH_SEASTAR
142-
virtual GenContext<ThreadPool::TPHandle&> *bless_unlocked_gencontext(
143-
GenContext<ThreadPool::TPHandle&> *c) = 0;
144-
145-
virtual void schedule_recovery_work(
146-
GenContext<ThreadPool::TPHandle&> *c,
147-
uint64_t cost) = 0;
148-
#endif
149-
150-
virtual epoch_t get_interval_start_epoch() const = 0;
151-
virtual const std::set<pg_shard_t> &get_acting_shards() const = 0;
152-
virtual const std::set<pg_shard_t> &get_backfill_shards() const = 0;
153-
virtual const std::map<hobject_t, std::set<pg_shard_t>> &get_missing_loc_shards()
154-
const = 0;
155-
156-
virtual const std::map<pg_shard_t,
157-
pg_missing_t> &get_shard_missing() const = 0;
158-
virtual const pg_missing_const_i &get_shard_missing(pg_shard_t peer) const = 0;
159-
#if 1
160-
virtual const pg_missing_const_i * maybe_get_shard_missing(
161-
pg_shard_t peer) const = 0;
162-
virtual const pg_info_t &get_shard_info(pg_shard_t peer) const = 0;
163-
#endif
164-
virtual ceph_tid_t get_tid() = 0;
165-
virtual pg_shard_t whoami_shard() const = 0;
166-
#if 0
167-
int whoami() const {
168-
return whoami_shard().osd;
169-
}
170-
spg_t whoami_spg_t() const {
171-
return get_info().pgid;
172-
}
173-
#endif
174-
// XXX
175-
virtual void send_message_osd_cluster(
176-
std::vector<std::pair<int, Message*>>& messages, epoch_t from_epoch) = 0;
177-
178-
virtual std::ostream& gen_dbg_prefix(std::ostream& out) const = 0;
179-
180-
// RMWPipeline
181-
virtual const pg_pool_t &get_pool() const = 0;
182-
virtual const std::set<pg_shard_t> &get_acting_recovery_backfill_shards() const = 0;
183-
// XXX
184-
virtual bool should_send_op(
185-
pg_shard_t peer,
186-
const hobject_t &hoid) = 0;
187-
virtual const std::map<pg_shard_t, pg_info_t> &get_shard_info() const = 0;
188-
virtual spg_t primary_spg_t() const = 0;
189-
virtual const PGLog &get_log() const = 0;
190-
virtual DoutPrefixProvider *get_dpp() = 0;
191-
// XXX
192-
virtual void apply_stats(
193-
const hobject_t &soid,
194-
const object_stat_sum_t &delta_stats) = 0;
195-
196-
// new batch
197-
virtual bool is_missing_object(const hobject_t& oid) const = 0;
198-
virtual void add_local_next_event(const pg_log_entry_t& e) = 0;
199-
virtual void log_operation(
200-
std::vector<pg_log_entry_t>&& logv,
201-
const std::optional<pg_hit_set_history_t> &hset_history,
202-
const eversion_t &trim_to,
203-
const eversion_t &roll_forward_to,
204-
const eversion_t &pg_committed_to,
205-
bool transaction_applied,
206-
ceph::os::Transaction &t,
207-
bool async = false) = 0;
208-
virtual void op_applied(
209-
const eversion_t &applied_version) = 0;
210-
};
21156

21257
struct ECCommonL {
21358

src/osd/ECListener.h

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
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+
};

src/osd/PGBackend.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#ifndef PGBACKEND_H
1919
#define PGBACKEND_H
2020

21-
#include "ECCommonL.h"
21+
#include "ECListener.h"
22+
#include "ECTypes.h"
2223
#include "osd_types.h"
2324
#include "pg_features.h"
2425
#include "common/intrusive_timer.h"

0 commit comments

Comments
 (0)