f->dump_stream("extent_requested") << extent_requested;
}
+ECBackend::ECBackend(
+ PGBackend::Listener *pg,
+ coll_t coll,
+ coll_t temp_coll,
+ ObjectStore *store,
+ CephContext *cct,
+ ErasureCodeInterfaceRef ec_impl,
+ uint64_t stripe_width)
+ : PGBackend(pg, store, coll, temp_coll),
+ cct(cct),
+ ec_impl(ec_impl),
+ sinfo(ec_impl->get_data_chunk_count(), stripe_width) {
+ assert((ec_impl->get_data_chunk_count() *
+ ec_impl->get_chunk_size(stripe_width)) == stripe_width);
+}
+
PGBackend::RecoveryHandle *ECBackend::open_recovery_op()
{
return new ECRecoveryHandle;
coll_t temp_coll,
ObjectStore *store,
CephContext *cct,
- ErasureCodeInterfaceRef ec_impl)
- : PGBackend(pg, store, coll, temp_coll),
- cct(cct),
- ec_impl(ec_impl),
- stripe_width(ec_impl->get_chunk_count()),
- stripe_size(4*(2<<10) /* TODO: make more flexible */) {}
+ ErasureCodeInterfaceRef ec_impl,
+ uint64_t stripe_width);
/// Returns to_read replicas sufficient to reconstruct want
int get_min_avail_to_read_shards(
PG *pg;
hobject_t logoid = make_pg_log_oid(pgid);
hobject_t infooid = make_pg_biginfo_oid(pgid);
- if (createmap->get_pg_type(pgid.pgid) == pg_pool_t::TYPE_REPLICATED)
+ if (createmap->get_pg_type(pgid.pgid) == pg_pool_t::TYPE_REPLICATED ||
+ createmap->get_pg_type(pgid.pgid) == pg_pool_t::TYPE_ERASURE)
pg = new ReplicatedPG(&service, createmap, pool, pgid, logoid, infooid);
else
assert(0);
#include "common/errno.h"
+#include "ReplicatedBackend.h"
+#include "ECBackend.h"
#include "PGBackend.h"
#include "OSD.h"
+#include "erasure-code/ErasureCodePlugin.h"
#define dout_subsys ceph_subsys_osd
#define DOUT_PREFIX_ARGS this
coll, ghobject_t(hoid, old_version, get_parent()->whoami_shard().shard));
}
+PGBackend *PGBackend::build_pg_backend(
+ const pg_pool_t &pool,
+ Listener *l,
+ coll_t coll,
+ coll_t temp_coll,
+ ObjectStore *store,
+ CephContext *cct)
+{
+ switch (pool.type) {
+ case pg_pool_t::TYPE_REPLICATED: {
+ return new ReplicatedBackend(l, coll, temp_coll, store, cct);
+ }
+ case pg_pool_t::TYPE_ERASURE: {
+ ErasureCodeInterfaceRef ec_impl;
+ assert(pool.properties.count("erasure-code-plugin"));
+ ceph::ErasureCodePluginRegistry::instance().factory(
+ pool.properties.find("erasure-code-plugin")->second,
+ pool.properties,
+ &ec_impl);
+ assert(ec_impl);
+ return new ECBackend(
+ l,
+ coll,
+ temp_coll,
+ store,
+ cct,
+ ec_impl,
+ pool.stripe_width);
+ }
+ default:
+ assert(0);
+ return NULL;
+ }
+}
+
/*
* pg lock may or may not be held
*/
const spg_t pgid,
const vector<int> &acting,
ostream &errorstream);
-
virtual uint64_t be_get_ondisk_size(
uint64_t logical_size) { assert(0); return 0; }
virtual void be_deep_scrub(
const hobject_t &poid,
ScrubMap::object &o,
ThreadPool::TPHandle &handle) { assert(0); }
+
+ static PGBackend *build_pg_backend(
+ const pg_pool_t &pool,
+ Listener *l,
+ coll_t coll,
+ coll_t temp_coll,
+ ObjectStore *store,
+ CephContext *cct);
};
struct PG_SendMessageOnConn: public Context {
}
ReplicatedBackend::ReplicatedBackend(
- PGBackend::Listener *pg, coll_t coll, ObjectStore *store,
+ PGBackend::Listener *pg,
+ coll_t coll,
+ coll_t temp_coll,
+ ObjectStore *store,
CephContext *cct) :
PGBackend(pg, store,
- coll, coll_t::make_temp_coll(pg->get_info().pgid)),
+ coll, temp_coll),
cct(cct) {}
void ReplicatedBackend::run_recovery_op(
CephContext *cct;
ReplicatedBackend(
- PGBackend::Listener *pg, coll_t coll, ObjectStore *store,
+ PGBackend::Listener *pg,
+ coll_t coll,
+ coll_t temp_coll,
+ ObjectStore *store,
CephContext *cct);
/// @see PGBackend::open_recovery_op
const PGPool &_pool, spg_t p, const hobject_t& oid,
const hobject_t& ioid) :
PG(o, curmap, _pool, p, oid, ioid),
- pgbackend(new ReplicatedBackend(this, coll_t(p), o->store, cct)),
+ pgbackend(
+ PGBackend::build_pg_backend(
+ _pool.info, this, coll_t(p), coll_t::make_temp_coll(p), o->store, cct)),
snapset_contexts_lock("ReplicatedPG::snapset_contexts"),
temp_seq(0),
snap_trimmer_machine(this)