]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueFS: get_usage()
authorSage Weil <sage@redhat.com>
Mon, 21 Dec 2015 21:17:47 +0000 (16:17 -0500)
committerSage Weil <sage@redhat.com>
Fri, 1 Jan 2016 18:07:20 +0000 (13:07 -0500)
Return (and log) usage for all bdevs.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index ca9ec1342fd5cafa21eb57b1192da9c66a2f2725..bd79d12893a06eed4fffb6bda329770d6d215109 100644 (file)
@@ -100,6 +100,29 @@ uint64_t BlueFS::get_free(unsigned id)
   return alloc[id]->get_free();
 }
 
+void BlueFS::get_usage(vector<pair<uint64_t,uint64_t>> *usage)
+{
+  Mutex::Locker l(lock);
+  usage->resize(bdev.size());
+  for (unsigned id = 0; id < bdev.size(); ++id) {
+    uint64_t total = 0;
+    interval_set<uint64_t>& p = block_all[id];
+    for (interval_set<uint64_t>::iterator q = p.begin(); q != p.end(); ++q) {
+      total += q.get_len();
+    }
+    (*usage)[id].first = alloc[id]->get_free();
+    (*usage)[id].second = total;
+    uint64_t used = (total - (*usage)[id].first) * 100 / total;
+    dout(10) << __func__ << " bdev " << id
+            << " free " << (*usage)[id].first
+            << " (" << pretty_si_t((*usage)[id].first) << "B)"
+            << " / " << (*usage)[id].second
+            << " (" << pretty_si_t((*usage)[id].second) << "B)"
+            << ", used " << used << "%"
+            << dendl;
+  }
+}
+
 int BlueFS::get_block_extents(unsigned id, interval_set<uint64_t> *extents)
 {
   Mutex::Locker l(lock);
index 0c9bb6dfc04a97f46dbd5644128b67387b0e3de8..e682dec1121ebe32b25df13bf7359b4207ea67de 100644 (file)
@@ -242,6 +242,7 @@ public:
 
   uint64_t get_total(unsigned id);
   uint64_t get_free(unsigned id);
+  void get_usage(vector<pair<uint64_t,uint64_t>> *usage); // [<free,total> ...]
 
   /// get current extents that we own for given block device
   int get_block_extents(unsigned id, interval_set<uint64_t> *extents);