Skip to content

Commit e565780

Browse files
committed
osd: ECBackendL should not implement PGBackend directly (only ECSwitch) and add ECLegacy namespace
A few changes merged into a single commit here, sorry. THis was about two things: 1. Getting things to compile. 2. Inserting a namespace called ECLegacy to ensure that all old stuctures/functions are independent. Signed-off-by: Alex Ainscow <[email protected]>
1 parent df7decd commit e565780

File tree

9 files changed

+138
-143
lines changed

9 files changed

+138
-143
lines changed

src/osd/ECBackendL.cc

Lines changed: 36 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "messages/MOSDECSubOpReadReply.h"
2626
#include "ECMsgTypes.h"
2727
#include "ECTypes.h"
28+
#include "ECSwitch.h"
2829

2930
#include "PrimaryLogPG.h"
3031
#include "osd_tracer.h"
@@ -54,12 +55,14 @@ using ceph::bufferptr;
5455
using ceph::ErasureCodeInterfaceRef;
5556
using ceph::Formatter;
5657

58+
namespace ECLegacy {
59+
5760
static ostream& _prefix(std::ostream *_dout, ECBackendL *pgb) {
58-
return pgb->get_parent()->gen_dbg_prefix(*_dout);
61+
return pgb->get_parent()->gen_dbg_prefix(*_dout) << "ECBackendL ";
5962
}
6063

6164
static ostream& _prefix(std::ostream *_dout, ECBackendL::RecoveryBackend *pgb) {
62-
return pgb->get_parent()->gen_dbg_prefix(*_dout);
65+
return pgb->get_parent()->gen_dbg_prefix(*_dout) << "ECBackendL ";
6366
}
6467

6568
struct ECRecoveryHandle : public PGBackend::RecoveryHandle {
@@ -123,16 +126,14 @@ void ECBackendL::RecoveryBackend::RecoveryOp::dump(Formatter *f) const
123126

124127
ECBackendL::ECBackendL(
125128
PGBackend::Listener *pg,
126-
const coll_t &coll,
127-
ObjectStore::CollectionHandle &ch,
128-
ObjectStore *store,
129129
CephContext *cct,
130130
ErasureCodeInterfaceRef ec_impl,
131-
uint64_t stripe_width)
132-
: PGBackend(cct, pg, store, coll, ch),
131+
uint64_t stripe_width,
132+
ECSwitch *s)
133+
: parent(pg), cct(cct), switcher(s),
133134
read_pipeline(cct, ec_impl, this->sinfo, get_parent()->get_eclistener()),
134135
rmw_pipeline(cct, ec_impl, this->sinfo, get_parent()->get_eclistener(), *this),
135-
recovery_backend(cct, this->coll, ec_impl, this->sinfo, read_pipeline, unstable_hashinfo_registry, get_parent(), this),
136+
recovery_backend(cct, switcher->coll, ec_impl, this->sinfo, read_pipeline, unstable_hashinfo_registry, get_parent(), this),
136137
ec_impl(ec_impl),
137138
sinfo(ec_impl, stripe_width),
138139
unstable_hashinfo_registry(cct, ec_impl) {
@@ -235,7 +236,7 @@ void ECBackendL::handle_recovery_push(
235236
!(get_parent()->pgb_is_primary()) &&
236237
get_parent()->pg_is_remote_backfilling()) {
237238
struct stat st;
238-
int r = store->stat(ch, ghobject_t(op.soid, ghobject_t::NO_GEN,
239+
int r = switcher->store->stat(switcher->ch, ghobject_t(op.soid, ghobject_t::NO_GEN,
239240
get_parent()->whoami_shard().shard), &st);
240241
if (r == 0) {
241242
get_parent()->pg_sub_local_num_bytes(st.st_size);
@@ -722,13 +723,13 @@ void ECBackendL::RecoveryBackend::continue_recovery_op(
722723
}
723724

724725
void ECBackendL::run_recovery_op(
725-
RecoveryHandle *_h,
726+
PGBackend::RecoveryHandle *_h,
726727
int priority)
727728
{
728729
ceph_assert(_h);
729730
ECRecoveryHandle &h = static_cast<ECRecoveryHandle&>(*_h);
730731
recovery_backend.run_recovery_op(h, priority);
731-
send_recovery_deletes(priority, h.deletes);
732+
switcher->send_recovery_deletes(priority, h.deletes);
732733
delete _h;
733734
}
734735

@@ -753,7 +754,7 @@ int ECBackendL::recover_object(
753754
eversion_t v,
754755
ObjectContextRef head,
755756
ObjectContextRef obc,
756-
RecoveryHandle *_h)
757+
PGBackend::RecoveryHandle *_h)
757758
{
758759
return recovery_backend.recover_object(hoid, v, head, obc, _h);
759760
}
@@ -763,7 +764,7 @@ int ECBackendL::RecoveryBackend::recover_object(
763764
eversion_t v,
764765
ObjectContextRef head,
765766
ObjectContextRef obc,
766-
RecoveryHandle *_h)
767+
PGBackend::RecoveryHandle *_h)
767768
{
768769
ECRecoveryHandle *h = static_cast<ECRecoveryHandle*>(_h);
769770
h->ops.push_back(RecoveryOp());
@@ -834,7 +835,7 @@ bool ECBackendL::_handle_message(
834835
auto op = _op->get_req<MOSDECSubOpRead>();
835836
MOSDECSubOpReadReply *reply = new MOSDECSubOpReadReply;
836837
reply->pgid = get_parent()->primary_spg_t();
837-
reply->map_epoch = get_osdmap_epoch();
838+
reply->map_epoch = switcher->get_osdmap_epoch();
838839
reply->min_epoch = get_parent()->get_interval_start_epoch();
839840
handle_sub_read(op->op.from, op->op, &(reply->op), _op->pg_trace);
840841
reply->trace = _op->pg_trace;
@@ -920,7 +921,7 @@ void ECBackendL::sub_write_committed(
920921
get_parent()->update_last_complete_ondisk(last_complete);
921922
MOSDECSubOpWriteReply *r = new MOSDECSubOpWriteReply;
922923
r->pgid = get_parent()->primary_spg_t();
923-
r->map_epoch = get_osdmap_epoch();
924+
r->map_epoch = switcher->get_osdmap_epoch();
924925
r->min_epoch = get_parent()->get_interval_start_epoch();
925926
r->op.tid = tid;
926927
r->op.last_complete = last_complete;
@@ -931,7 +932,7 @@ void ECBackendL::sub_write_committed(
931932
r->trace = trace;
932933
r->trace.event("sending sub op commit");
933934
get_parent()->send_message_osd_cluster(
934-
get_parent()->primary_shard().osd, r, get_osdmap_epoch());
935+
get_parent()->primary_shard().osd, r, switcher->get_osdmap_epoch());
935936
}
936937
}
937938

@@ -955,7 +956,7 @@ void ECBackendL::handle_sub_write(
955956
get_parent()->update_stats(op.stats);
956957
ObjectStore::Transaction localt;
957958
if (!op.temp_added.empty()) {
958-
add_temp_objs(op.temp_added);
959+
switcher->add_temp_objs(op.temp_added);
959960
}
960961
if (op.backfill_or_async_recovery) {
961962
for (set<hobject_t>::iterator i = op.temp_removed.begin();
@@ -964,14 +965,14 @@ void ECBackendL::handle_sub_write(
964965
dout(10) << __func__ << ": removing object " << *i
965966
<< " since we won't get the transaction" << dendl;
966967
localt.remove(
967-
coll,
968+
switcher->coll,
968969
ghobject_t(
969970
*i,
970971
ghobject_t::NO_GEN,
971972
get_parent()->whoami_shard().shard));
972973
}
973974
}
974-
clear_temp_objs(op.temp_removed);
975+
switcher->clear_temp_objs(op.temp_removed);
975976
dout(30) << __func__ << " missing before " << get_parent()->get_log().get_missing().get_items() << dendl;
976977
// flag set to true during async recovery
977978
bool async = false;
@@ -1035,8 +1036,8 @@ void ECBackendL::handle_sub_read(
10351036
(op.subchunks.find(i->first)->second.front().second ==
10361037
ec_impl->get_sub_chunk_count())) {
10371038
dout(20) << __func__ << " case1: reading the complete chunk/shard." << dendl;
1038-
r = store->read(
1039-
ch,
1039+
r = switcher->store->read(
1040+
switcher->ch,
10401041
ghobject_t(i->first, ghobject_t::NO_GEN, shard),
10411042
j->get<0>(),
10421043
j->get<1>(),
@@ -1052,8 +1053,8 @@ void ECBackendL::handle_sub_read(
10521053
m += sinfo.get_chunk_size()) {
10531054
for (auto &&k:op.subchunks.find(i->first)->second) {
10541055
bufferlist bl0;
1055-
r = store->read(
1056-
ch,
1056+
r = switcher->store->read(
1057+
switcher->ch,
10571058
ghobject_t(i->first, ghobject_t::NO_GEN, shard),
10581059
j->get<0>() + m + (k.first)*subchunk_size,
10591060
(k.second)*subchunk_size,
@@ -1103,7 +1104,7 @@ void ECBackendL::handle_sub_read(
11031104
int r = object_stat(i->first, &st);
11041105
if (r >= 0) {
11051106
dout(10) << __func__ << ": found on disk, size " << st.st_size << dendl;
1106-
r = PGBackend::objects_get_attrs(i->first, &attrs);
1107+
r = switcher->objects_get_attrs_with_hinfo(i->first, &attrs);
11071108
}
11081109
if (r >= 0) {
11091110
hinfo = unstable_hashinfo_registry.get_hash_info(i->first, false, attrs, st.st_size);
@@ -1150,8 +1151,8 @@ void ECBackendL::handle_sub_read(
11501151
<< *i << dendl;
11511152
if (reply->errors.count(*i))
11521153
continue;
1153-
int r = store->getattrs(
1154-
ch,
1154+
int r = switcher->store->getattrs(
1155+
switcher->ch,
11551156
ghobject_t(
11561157
*i, ghobject_t::NO_GEN, shard),
11571158
reply->attrs_read[*i]);
@@ -1484,7 +1485,7 @@ std::tuple<
14841485
return { r, {}, 0 };
14851486
}
14861487
map<string, bufferlist, less<>> real_attrs;
1487-
if (int r = PGBackend::objects_get_attrs(hoid, &real_attrs); r < 0) {
1488+
if (int r = switcher->objects_get_attrs_with_hinfo(hoid, &real_attrs); r < 0) {
14881489
dout(10) << __func__ << ": get attr error " << r << " on" << hoid << dendl;
14891490
return { r, {}, 0 };
14901491
}
@@ -1569,6 +1570,7 @@ int ECBackendL::objects_read_sync(
15691570

15701571
void ECBackendL::objects_read_async(
15711572
const hobject_t &hoid,
1573+
uint64_t object_size,
15721574
const list<pair<ec_align_t,
15731575
pair<bufferlist*, Context*>>> &to_read,
15741576
Context *on_complete,
@@ -1699,8 +1701,8 @@ int ECBackendL::object_stat(
16991701
const hobject_t &hoid,
17001702
struct stat* st)
17011703
{
1702-
int r = store->stat(
1703-
ch,
1704+
int r = switcher->store->stat(
1705+
switcher->ch,
17041706
ghobject_t{hoid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard},
17051707
st);
17061708
return r;
@@ -1710,11 +1712,6 @@ int ECBackendL::objects_get_attrs(
17101712
const hobject_t &hoid,
17111713
map<string, bufferlist, less<>> *out)
17121714
{
1713-
// call from parents -- get raw attrs, without any filtering for hinfo
1714-
int r = PGBackend::objects_get_attrs(hoid, out);
1715-
if (r < 0)
1716-
return r;
1717-
17181715
for (map<string, bufferlist>::iterator i = out->begin();
17191716
i != out->end();
17201717
) {
@@ -1723,20 +1720,7 @@ int ECBackendL::objects_get_attrs(
17231720
else
17241721
++i;
17251722
}
1726-
return r;
1727-
}
1728-
1729-
void ECBackendL::rollback_append(
1730-
const hobject_t &hoid,
1731-
uint64_t old_size,
1732-
ObjectStore::Transaction *t)
1733-
{
1734-
ceph_assert(old_size % sinfo.get_stripe_width() == 0);
1735-
t->truncate(
1736-
coll,
1737-
ghobject_t(hoid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard),
1738-
sinfo.aligned_logical_offset_to_chunk_offset(
1739-
old_size));
1723+
return 0;
17401724
}
17411725

17421726
int ECBackendL::be_deep_scrub(
@@ -1749,7 +1733,7 @@ int ECBackendL::be_deep_scrub(
17491733
int r;
17501734

17511735
uint32_t fadvise_flags = CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL |
1752-
CEPH_OSD_OP_FLAG_FADVISE_DONTNEED |
1736+
CEPH_OSD_OP_FLAG_FADVISE_DONTNEED |
17531737
CEPH_OSD_OP_FLAG_BYPASS_CLEAN_CACHE;
17541738

17551739
utime_t sleeptime;
@@ -1768,8 +1752,8 @@ int ECBackendL::be_deep_scrub(
17681752
stride += sinfo.get_chunk_size() - (stride % sinfo.get_chunk_size());
17691753

17701754
bufferlist bl;
1771-
r = store->read(
1772-
ch,
1755+
r = switcher->store->read(
1756+
switcher->ch,
17731757
ghobject_t(
17741758
poid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard),
17751759
pos.data_pos,
@@ -1849,3 +1833,4 @@ int ECBackendL::be_deep_scrub(
18491833
o.omap_digest_present = true;
18501834
return 0;
18511835
}
1836+
}

0 commit comments

Comments
 (0)