summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-09-10 09:15:42 -0700
committerSage Weil <sage@inktank.com>2013-09-10 09:15:42 -0700
commit277d26671310ad268b25dae2f3c9003efe28bb4c (patch)
treea3b8e60aad76a9e39ee7b7c261fbd62a7c8fd1d9
parent8c76f3a0f9cf100ea2c941dc2b61c470aa5033d7 (diff)
parent454c116d38a005fc91c9d3e70258b4dac8a80547 (diff)
downloadceph-277d26671310ad268b25dae2f3c9003efe28bb4c.tar.gz
Merge pull request #578 from dachary/wip-6113
mon: add key[=value] ... to osd pool create Reviewed-by: Sage Weil <sage@inktank.com>
-rw-r--r--src/mon/MonCommands.h3
-rw-r--r--src/mon/OSDMonitor.cc27
-rw-r--r--src/mon/OSDMonitor.h3
-rw-r--r--src/osd/osd_types.cc16
-rw-r--r--src/osd/osd_types.h1
5 files changed, 43 insertions, 7 deletions
diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h
index 28fa80e00b7..2949f863888 100644
--- a/src/mon/MonCommands.h
+++ b/src/mon/MonCommands.h
@@ -479,7 +479,8 @@ COMMAND("osd pool rmsnap " \
COMMAND("osd pool create " \
"name=pool,type=CephPoolname " \
"name=pg_num,type=CephInt,range=0 " \
- "name=pgp_num,type=CephInt,range=0,req=false", \
+ "name=pgp_num,type=CephInt,range=0,req=false" \
+ "name=properties,type=CephString,n=N,req=false,goodchars=[A-Za-z0-9-_.=]", \
"create pool", "osd", "rw", "cli,rest")
COMMAND("osd pool delete " \
"name=pool,type=CephPoolname " \
diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc
index 5450532e46d..8eb88a829b1 100644
--- a/src/mon/OSDMonitor.cc
+++ b/src/mon/OSDMonitor.cc
@@ -2473,10 +2473,11 @@ int OSDMonitor::prepare_new_pool(MPoolOp *m)
MonSession *session = m->get_session();
if (!session)
return -EPERM;
+ vector<string> properties;
if (m->auid)
- return prepare_new_pool(m->name, m->auid, m->crush_rule, 0, 0);
+ return prepare_new_pool(m->name, m->auid, m->crush_rule, 0, 0, properties);
else
- return prepare_new_pool(m->name, session->auid, m->crush_rule, 0, 0);
+ return prepare_new_pool(m->name, session->auid, m->crush_rule, 0, 0, properties);
}
/**
@@ -2485,11 +2486,13 @@ int OSDMonitor::prepare_new_pool(MPoolOp *m)
* @param crush_rule The crush rule to use. If <0, will use the system default
* @param pg_num The pg_num to use. If set to 0, will use the system default
* @param pgp_num The pgp_num to use. If set to 0, will use the system default
+ * @param properties An opaque list of key[=value] pairs for pool configuration
*
* @return 0 in all cases. That's silly.
*/
int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_rule,
- unsigned pg_num, unsigned pgp_num)
+ unsigned pg_num, unsigned pgp_num,
+ const vector<string> &properties)
{
for (map<int64_t,string>::iterator p = pending_inc.new_pool_names.begin();
p != pending_inc.new_pool_names.end();
@@ -2519,6 +2522,18 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, int crush_rule,
pi->set_pgp_num(pgp_num ? pgp_num : g_conf->osd_pool_default_pgp_num);
pi->last_change = pending_inc.epoch;
pi->auid = auid;
+ for (vector<string>::const_iterator i = properties.begin();
+ i != properties.end();
+ i++) {
+ size_t equal = i->find('=');
+ if (equal != string::npos)
+ pi->properties[*i] = string();
+ else {
+ const string key = i->substr(0, equal);
+ const string value = i->substr(equal);
+ pi->properties[key] = value;
+ }
+ }
pending_inc.new_pool_names[pool] = name;
return 0;
}
@@ -3480,9 +3495,13 @@ done:
goto reply;
}
+ vector<string> properties;
+ cmd_getval(g_ceph_context, cmdmap, "properties", properties);
+
err = prepare_new_pool(poolstr, 0, // auid=0 for admin created pool
-1, // default crush rule
- pg_num, pgp_num);
+ pg_num, pgp_num,
+ properties);
if (err < 0 && err != -EEXIST) {
goto reply;
}
diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h
index 04f7cf5b196..304f9c4f609 100644
--- a/src/mon/OSDMonitor.h
+++ b/src/mon/OSDMonitor.h
@@ -235,7 +235,8 @@ private:
bool prepare_pool_op_create (MPoolOp *m);
bool prepare_pool_op_delete(MPoolOp *m);
int prepare_new_pool(string& name, uint64_t auid, int crush_rule,
- unsigned pg_num, unsigned pgp_num);
+ unsigned pg_num, unsigned pgp_num,
+ const vector<string> &properties);
int prepare_new_pool(MPoolOp *m);
void update_pool_flags(int64_t pool_id, uint64_t flags);
diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc
index 3451d520ff2..34ae75b12b9 100644
--- a/src/osd/osd_types.cc
+++ b/src/osd/osd_types.cc
@@ -649,6 +649,14 @@ void pg_pool_t::dump(Formatter *f) const
f->dump_int("read_tier", read_tier);
f->dump_int("write_tier", write_tier);
f->dump_string("cache_mode", get_cache_mode_name());
+ f->open_array_section("properties");
+ for (map<string,string>::const_iterator i = properties.begin();
+ i != properties.end();
+ ++i) {
+ string name = i->first;
+ f->dump_string(name.c_str(), i->second);
+ }
+ f->close_section();
}
@@ -853,7 +861,7 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
return;
}
- ENCODE_START(9, 5, bl);
+ ENCODE_START(10, 5, bl);
::encode(type, bl);
::encode(size, bl);
::encode(crush_ruleset, bl);
@@ -880,6 +888,7 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
::encode(c, bl);
::encode(read_tier, bl);
::encode(write_tier, bl);
+ ::encode(properties, bl);
ENCODE_FINISH(bl);
}
@@ -947,6 +956,9 @@ void pg_pool_t::decode(bufferlist::iterator& bl)
::decode(read_tier, bl);
::decode(write_tier, bl);
}
+ if (struct_v >= 10) {
+ ::decode(properties, bl);
+ }
DECODE_FINISH(bl);
calc_pg_masks();
}
@@ -988,6 +1000,8 @@ void pg_pool_t::generate_test_instances(list<pg_pool_t*>& o)
a.cache_mode = CACHEMODE_WRITEBACK;
a.read_tier = 1;
a.write_tier = 1;
+ a.properties["p-1"] = "v-1";
+ a.properties["empty"] = string();
o.push_back(new pg_pool_t(a));
}
diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h
index da139b853b1..91ab89a63af 100644
--- a/src/osd/osd_types.h
+++ b/src/osd/osd_types.h
@@ -778,6 +778,7 @@ private:
public:
+ map<string,string> properties; /// interpreted according to the pool type
epoch_t last_change; /// most recent epoch changed, exclusing snapshot changes
snapid_t snap_seq; /// seq for per-pool snapshot
epoch_t snap_epoch; /// osdmap epoch of last snap