]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: osd pool create sets pg_pool_t::stripe_width
authorLoic Dachary <loic@dachary.org>
Wed, 5 Feb 2014 19:40:46 +0000 (20:40 +0100)
committerLoic Dachary <loic@dachary.org>
Wed, 5 Feb 2014 19:40:46 +0000 (20:40 +0100)
It does nothing if the pool is replicated. Otherwise it uses
osd_pool_erasure_code_stripe_width as the desired stripe width and run
it by get_chunk_size() on the erasure code plugin to get the actual
stripe_width. It will always be >= 0 to the desired stripe_width, padded
to match the alignment constraints imposed by the erasure code plugin.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 1142990af24733f198dd03f3e0a84a02887a46c3..0834e371a4b0b13cc14d780f355d9b3b157967d8 100644 (file)
@@ -2849,6 +2849,36 @@ int OSDMonitor::prepare_pool_size(const unsigned pool_type,
   }
   return err;
 }
+
+int OSDMonitor::prepare_pool_stripe_width(const unsigned pool_type,
+                                         const map<string,string> &properties,
+                                         uint32_t *stripe_width,
+                                         stringstream &ss)
+{
+  int err = 0;
+  switch (pool_type) {
+  case pg_pool_t::TYPE_REPLICATED:
+    // ignored
+    break;
+  case pg_pool_t::TYPE_ERASURE:
+    {
+      ErasureCodeInterfaceRef erasure_code;
+      err = get_erasure_code(properties, &erasure_code, ss);
+      uint32_t desired_stripe_width = g_conf->osd_pool_erasure_code_stripe_width;
+      if (err == 0)
+       *stripe_width = erasure_code->get_data_chunk_count() *
+         erasure_code->get_chunk_size(desired_stripe_width);
+    }
+    break;
+  default:
+    ss << "prepare_pool_stripe_width: "
+       << pool_type << " is not a known pool type";
+    err = -EINVAL;
+    break;
+  }
+  return err;
+}
+
 int OSDMonitor::prepare_pool_crush_ruleset(const unsigned pool_type,
                                           const map<string,string> &properties,
                                           int *crush_ruleset,
@@ -2925,6 +2955,10 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_ruleset,
     return r;
   unsigned size;
   r = prepare_pool_size(pool_type, properties_map, &size, ss);
+  if (r)
+    return r;
+  uint32_t stripe_width = 0;
+  r = prepare_pool_stripe_width(pool_type, properties_map, &stripe_width, ss);
   if (r)
     return r;
 
@@ -2954,6 +2988,7 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_ruleset,
   pi->last_change = pending_inc.epoch;
   pi->auid = auid;
   pi->properties = properties_map;
+  pi->stripe_width = stripe_width;
   pending_inc.new_pool_names[pool] = name;
   return 0;
 }
index e2eadc62a489acb6ba29ce5a2df188b2ba5896a4..5e02b23f88108de97039d93b780d1bf1f5f79217 100644 (file)
@@ -254,6 +254,10 @@ private:
                        const map<string,string> &properties,
                        unsigned *size,
                        stringstream &ss);
+  int prepare_pool_stripe_width(const unsigned pool_type,
+                               const map<string,string> &properties,
+                               unsigned *stripe_width,
+                               stringstream &ss);
   int prepare_new_pool(string& name, uint64_t auid, int crush_ruleset,
                        unsigned pg_num, unsigned pgp_num,
                       const vector<string> &properties,