]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: pool creation helper for size
authorLoic Dachary <loic@dachary.org>
Sun, 2 Feb 2014 08:51:50 +0000 (09:51 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 4 Feb 2014 07:06:26 +0000 (08:06 +0100)
The size of the replicated pools are by default set to
osd_pool_default_size but it may vary depending on the pool type. Create
a helper to compute the pool size.

http://tracker.ceph.com/issues/7277 refs #7277

Reviewed-By: Christophe Courtaut <christophe.courtaut@gmail.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 4992e6df6f2a6ad95e01aafabfc9d817419e87b0..8545457db43982b6eefa5f18423f82c3ff0320a1 100644 (file)
@@ -2774,6 +2774,23 @@ int OSDMonitor::prepare_pool_properties(const unsigned pool_type,
   return 0;
 }
 
+int OSDMonitor::prepare_pool_size(const unsigned pool_type,
+                                 const map<string,string> &properties,
+                                 unsigned *size,
+                                 stringstream &ss)
+{
+  int err = 0;
+  switch (pool_type) {
+  case pg_pool_t::TYPE_REPLICATED:
+    *size = g_conf->osd_pool_default_size;
+    break;
+  default:
+    ss << "prepare_pool_size: " << pool_type << " is not a known pool type";
+    err = -EINVAL;
+    break;
+  }
+  return err;
+}
 /**
  * @param name The name of the new pool
  * @param auid The auid of the pool owner. Can be -1
@@ -2805,6 +2822,10 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_ruleset,
       return -EINVAL;
     }
   }
+  unsigned size;
+  r = prepare_pool_size(pool_type, properties_map, &size, ss);
+  if (r)
+    return r;
 
   for (map<int64_t,string>::iterator p = pending_inc.new_pool_names.begin();
        p != pending_inc.new_pool_names.end();
@@ -2823,7 +2844,7 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_ruleset,
   if (g_conf->osd_pool_default_flag_hashpspool)
     pi->flags |= pg_pool_t::FLAG_HASHPSPOOL;
 
-  pi->size = g_conf->osd_pool_default_size;
+  pi->size = size;
   pi->min_size = g_conf->get_osd_pool_default_min_size();
   pi->crush_ruleset = crush_ruleset;
   pi->object_hash = CEPH_STR_HASH_RJENKINS;
index cabd680f5318064ba29d06f03af3079e4203c48f..2b16234994322e46fe24a6cc0e77afae5ea503a1 100644 (file)
@@ -240,6 +240,10 @@ private:
                              const vector<string> &properties,
                              map<string,string> *properties_map,
                              stringstream &ss);
+  int prepare_pool_size(const unsigned pool_type,
+                       const map<string,string> &properties,
+                       unsigned *size,
+                       stringstream &ss);
   int prepare_new_pool(string& name, uint64_t auid, int crush_ruleset,
                        unsigned pg_num, unsigned pgp_num,
                       const vector<string> &properties,