mon: make 'mon {add,remove}_data_pool ...' take pool name or id

Take either a pool name or an id.  Fix up the tests accordingly.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-10-14 16:46:58 -07:00
parent fea1e0e56c
commit e2602c549f
4 changed files with 48 additions and 21 deletions

View File

@ -147,7 +147,9 @@ ceph mds newfs 0 1 --yes-i-really-mean-it
ceph osd pool create data2 10
poolnum=$(ceph osd dump | grep 'pool.*data2' | awk '{print $2;}')
ceph mds add_data_pool $poolnum
ceph mds add_data_pool rbd
ceph mds remove_data_pool $poolnum
ceph mds remove_data_pool rbd
ceph osd pool delete data2 data2 --yes-i-really-really-mean-it
ceph mds set_max_mds 4
ceph mds set_max_mds 3

View File

@ -4,10 +4,12 @@ set -e
touch foo.$$
rados mkpool foo.$$
poolid=$(ceph osd dump | grep "^pool" | awk '{print $2}' | tail -n 1)
ceph mds add_data_pool ${poolid}
ceph mds add_data_pool foo.$$
setfattr -n ceph.file.layout.pool -v foo.$$ foo.$$
# cleanup
rados rmpool foo.$$ foo.$$ --yes-i-really-really-mean-it
rm foo.$$
ceph mds remove_data_pool foo.$$
rados rmpool foo.$$ foo.$$ --yes-i-really-really-mean-it
echo OK

View File

@ -951,21 +951,44 @@ bool MDSMonitor::prepare_command(MMonCommand *m)
}
}
} else if (prefix == "mds add_data_pool") {
int64_t poolid;
cmd_getval(g_ceph_context, cmdmap, "poolid", poolid);
pending_mdsmap.add_data_pool(poolid);
ss << "added data pool " << poolid << " to mdsmap";
r = 0;
} else if (prefix == "mds remove_data_pool") {
int64_t poolid;
cmd_getval(g_ceph_context, cmdmap, "poolid", poolid);
r = pending_mdsmap.remove_data_pool(poolid);
if (r == -ENOENT)
string poolname;
cmd_getval(g_ceph_context, cmdmap, "pool", poolname);
int64_t poolid = mon->osdmon()->osdmap.lookup_pg_pool_name(poolname);
if (poolid < 0) {
string err;
poolid = strict_strtol(poolname.c_str(), 10, &err);
if (err.length()) {
r = -ENOENT;
poolid = -1;
ss << "pool '" << poolname << "' does not exist";
}
}
if (poolid >= 0) {
pending_mdsmap.add_data_pool(poolid);
ss << "added data pool " << poolid << " to mdsmap";
r = 0;
if (r == 0)
ss << "removed data pool " << poolid << " from mdsmap";
}
} else if (prefix == "mds remove_data_pool") {
string poolname;
cmd_getval(g_ceph_context, cmdmap, "pool", poolname);
int64_t poolid = mon->osdmon()->osdmap.lookup_pg_pool_name(poolname);
if (poolid < 0) {
string err;
poolid = strict_strtol(poolname.c_str(), 10, &err);
if (err.length()) {
r = -ENOENT;
poolid = -1;
ss << "pool '" << poolname << "' does not exist";
}
}
if (poolid >= 0) {
cmd_getval(g_ceph_context, cmdmap, "poolid", poolid);
r = pending_mdsmap.remove_data_pool(poolid);
if (r == -ENOENT)
r = 0;
if (r == 0)
ss << "removed data pool " << poolid << " from mdsmap";
}
} else if (prefix == "mds newfs") {
MDSMap newmap;
int64_t metadata, data;

View File

@ -284,11 +284,11 @@ COMMAND("mds unset " \
"name=sure,type=CephString,req=false", \
"unset <key>", "mds", "w", "cli,rest")
COMMAND("mds add_data_pool " \
"name=poolid,type=CephInt,range=0", \
"add data pool <poolid>", "mds", "rw", "cli,rest")
"name=pool,type=CephString", \
"add data pool <pool>", "mds", "rw", "cli,rest")
COMMAND("mds remove_data_pool " \
"name=poolid,type=CephInt,range=0", \
"remove data pool <poolid>", "mds", "rw", "cli,rest")
"name=pool,type=CephString", \
"remove data pool <pool>", "mds", "rw", "cli,rest")
COMMAND("mds newfs " \
"name=metadata,type=CephInt,range=0 " \
"name=data,type=CephInt,range=0 " \