]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: OSDMonitor: add 'osd pool get-quota' command
authorJoao Eduardo Luis <joao.luis@inktank.com>
Fri, 27 Jun 2014 20:41:18 +0000 (21:41 +0100)
committerSage Weil <sage@redhat.com>
Sat, 16 Aug 2014 04:36:26 +0000 (21:36 -0700)
Enables us to obtain current quotas for a given pool.

Fixes: #8523
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
(cherry picked from commit 714a9bb5a058b2553f3be3e4cfb7e7f30150e75a)

src/mon/MonCommands.h
src/mon/OSDMonitor.cc

index 245ceee6cf26135e265b649ceb8d12fd9857acbe..bd9dd2e79d63c0890b706d416970613ff75a3e12 100644 (file)
@@ -568,6 +568,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",
index 6581517b8ccaeb3626d1f89c83b9c73011f73608..395df90b08473c88e91f20acfffc4724f4aee4ee 100644 (file)
@@ -2709,6 +2709,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;