From dfc90cf3b95e519d1b8c7dc5f161bdfd953bafe1 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Wed, 5 Feb 2014 20:40:46 +0100 Subject: [PATCH] mon: osd pool create sets pg_pool_t::stripe_width 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 --- src/mon/OSDMonitor.cc | 35 +++++++++++++++++++++++++++++++++++ src/mon/OSDMonitor.h | 4 ++++ 2 files changed, 39 insertions(+) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 1142990af2473..0834e371a4b0b 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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 &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 &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; } diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index e2eadc62a489a..5e02b23f88108 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -254,6 +254,10 @@ private: const map &properties, unsigned *size, stringstream &ss); + int prepare_pool_stripe_width(const unsigned pool_type, + const map &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 &properties, -- 2.39.5