]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/: instantiate the right backend based on pool
authorSamuel Just <sam.just@inktank.com>
Mon, 27 Jan 2014 21:37:08 +0000 (13:37 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 18 Feb 2014 04:12:16 +0000 (20:12 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/ECBackend.cc
src/osd/ECBackend.h
src/osd/OSD.cc
src/osd/PGBackend.cc
src/osd/PGBackend.h
src/osd/ReplicatedBackend.cc
src/osd/ReplicatedBackend.h
src/osd/ReplicatedPG.cc

index 8688ad17c61e9fbe0826111ae9892482e4e10e25..d430ea7d87b65d4b420da3c678dc4a1e6c3f9b98 100644 (file)
@@ -164,6 +164,22 @@ void ECBackend::RecoveryOp::dump(Formatter *f) const
   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;
index d60409365610255dacf7f063b78d9bd999fce8ed..784456342ed52467a4876645bd881f19082aaac0 100644 (file)
@@ -442,12 +442,8 @@ public:
     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(
index b3204e6996a969fbb8498e6bd2b96d3f51071127..2f7dbaeecfce62bbdf528675460b5bcbe36be8e4 100644 (file)
@@ -1785,7 +1785,8 @@ PG* OSD::_make_pg(
   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);
index 1b594f2a1c7c57c270c133b766a5782d5023f0f8..3841ede95ca32972393f880d1aa7c303a939b7cd 100644 (file)
 
 
 #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
@@ -253,6 +256,41 @@ void PGBackend::trim_stashed_object(
     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
  */
index 397efbee7891c20ac60a5f7317f38a2147fa5e7c..8ea356bd83ab88a85511033aef2f7c3b3bcf8bb3 100644 (file)
      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 {
index de550db0cbfb9ffcb4fda35f2b43cb8f94f7dac2..6b9e477f563cb5b2e9446b94ad1bf6d487bce570 100644 (file)
@@ -29,10 +29,13 @@ static ostream& _prefix(std::ostream *_dout, ReplicatedBackend *pgb) {
 }
 
 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(
index 0d29aed98f70ec2d561ac322d7f87ca8aa3d6ca8..ed27314cf0ad36c4403e345d5dd49160941d808a 100644 (file)
@@ -31,7 +31,10 @@ public:
   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
index 2ee37a3fb0c21ddef51e11a54285d68d6047f002..8bec51266f0e91677f22d0e8180d64750262f44b 100644 (file)
@@ -1020,7 +1020,9 @@ ReplicatedPG::ReplicatedPG(OSDService *o, OSDMapRef curmap,
                           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)