mirror of
https://github.com/ceph/ceph
synced 2025-02-19 17:08:05 +00:00
Merge pull request #2029 from ceph/wip-8523
mon: OSDMonitor: add 'osd pool get-quota' command Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
a2164e73c0
@ -557,6 +557,52 @@ function test_mon_osd_pool()
|
||||
ceph osd pool delete replicated replicated --yes-i-really-really-mean-it
|
||||
}
|
||||
|
||||
function test_mon_osd_pool_quota()
|
||||
{
|
||||
#
|
||||
# test osd pool set/get quota
|
||||
#
|
||||
|
||||
# create tmp pool
|
||||
ceph osd pool create tmp-quota-pool 36
|
||||
#
|
||||
# set erroneous quotas
|
||||
#
|
||||
expect_false ceph osd pool set-quota tmp-quota-pool max_fooness 10
|
||||
expect_false ceph osd pool set-quota tmp-quota-pool max_bytes -1
|
||||
expect_false ceph osd pool set-quota tmp-quota-pool max_objects aaa
|
||||
#
|
||||
# set valid quotas
|
||||
#
|
||||
ceph osd pool set-quota tmp-quota-pool max_bytes 10
|
||||
ceph osd pool set-quota tmp-quota-pool max_objects 10M
|
||||
#
|
||||
# get quotas
|
||||
#
|
||||
ceph osd pool get-quota tmp-quota-pool | grep 'max bytes.*10B'
|
||||
ceph osd pool get-quota tmp-quota-pool | grep 'max objects.*10240k objects'
|
||||
#
|
||||
# get quotas in json-pretty format
|
||||
#
|
||||
ceph osd pool get-quota tmp-quota-pool --format=json-pretty | \
|
||||
grep '"quota_max_objects":.*10485760'
|
||||
ceph osd pool get-quota tmp-quota-pool --format=json-pretty | \
|
||||
grep '"quota_max_bytes":.*10'
|
||||
#
|
||||
# reset pool quotas
|
||||
#
|
||||
ceph osd pool set-quota tmp-quota-pool max_bytes 0
|
||||
ceph osd pool set-quota tmp-quota-pool max_objects 0
|
||||
#
|
||||
# test N/A quotas
|
||||
#
|
||||
ceph osd pool get-quota tmp-quota-pool | grep 'max bytes.*N/A'
|
||||
ceph osd pool get-quota tmp-quota-pool | grep 'max objects.*N/A'
|
||||
#
|
||||
# cleanup tmp pool
|
||||
ceph osd pool delete tmp-quota-pool tmp-quota-pool --yes-i-really-really-mean-it
|
||||
}
|
||||
|
||||
function test_mon_pg()
|
||||
{
|
||||
ceph pg debug unfound_objects_exist
|
||||
@ -827,6 +873,7 @@ TESTS=(
|
||||
mon_mon
|
||||
mon_osd
|
||||
mon_osd_pool
|
||||
mon_osd_pool_quota
|
||||
mon_pg
|
||||
mon_osd_pool_set
|
||||
mon_osd_erasure_code
|
||||
|
@ -587,6 +587,10 @@ COMMAND("osd pool set-quota " \
|
||||
"name=field,type=CephChoices,strings=max_objects|max_bytes " \
|
||||
"name=val,type=CephString",
|
||||
"set object or byte limit on pool", "osd", "rw", "cli,rest")
|
||||
COMMAND("osd pool get-quota " \
|
||||
"name=pool,type=CephPoolname ",
|
||||
"obtain object or byte limits for pool",
|
||||
"osd", "r", "cli,rest")
|
||||
COMMAND("osd pool stats " \
|
||||
"name=name,type=CephString,req=false",
|
||||
"obtain stats from all pools, or from specified pool",
|
||||
|
@ -2676,6 +2676,45 @@ stats_out:
|
||||
rdata.append("\n");
|
||||
r = 0;
|
||||
|
||||
} else if (prefix == "osd pool get-quota") {
|
||||
string pool_name;
|
||||
cmd_getval(g_ceph_context, cmdmap, "pool", pool_name);
|
||||
|
||||
int64_t poolid = osdmap.lookup_pg_pool_name(pool_name);
|
||||
if (poolid < 0) {
|
||||
assert(poolid == -ENOENT);
|
||||
ss << "unrecognized pool '" << pool_name << "'";
|
||||
r = -ENOENT;
|
||||
goto reply;
|
||||
}
|
||||
const pg_pool_t *p = osdmap.get_pg_pool(poolid);
|
||||
|
||||
if (f) {
|
||||
f->open_object_section("pool_quotas");
|
||||
f->dump_string("pool_name", pool_name);
|
||||
f->dump_unsigned("pool_id", poolid);
|
||||
f->dump_unsigned("quota_max_objects", p->quota_max_objects);
|
||||
f->dump_unsigned("quota_max_bytes", p->quota_max_bytes);
|
||||
f->close_section();
|
||||
f->flush(rdata);
|
||||
} else {
|
||||
stringstream rs;
|
||||
rs << "quotas for pool '" << pool_name << "':\n"
|
||||
<< " max objects: ";
|
||||
if (p->quota_max_objects == 0)
|
||||
rs << "N/A";
|
||||
else
|
||||
rs << si_t(p->quota_max_objects) << " objects";
|
||||
rs << "\n"
|
||||
<< " max bytes : ";
|
||||
if (p->quota_max_bytes == 0)
|
||||
rs << "N/A";
|
||||
else
|
||||
rs << si_t(p->quota_max_bytes) << "B";
|
||||
rdata.append(rs.str());
|
||||
}
|
||||
rdata.append("\n");
|
||||
r = 0;
|
||||
} else if (prefix == "osd crush rule list" ||
|
||||
prefix == "osd crush rule ls") {
|
||||
string format;
|
||||
|
Loading…
Reference in New Issue
Block a user