From: Sage Weil Date: Mon, 21 Dec 2015 21:17:47 +0000 (-0500) Subject: os/bluestore/BlueFS: get_usage() X-Git-Tag: v10.0.3~154^2~105 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cf5d139afb6879dce39f06ce9ca55487915e06e5;p=ceph.git os/bluestore/BlueFS: get_usage() Return (and log) usage for all bdevs. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index ca9ec1342fd5..bd79d12893a0 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -100,6 +100,29 @@ uint64_t BlueFS::get_free(unsigned id) return alloc[id]->get_free(); } +void BlueFS::get_usage(vector> *usage) +{ + Mutex::Locker l(lock); + usage->resize(bdev.size()); + for (unsigned id = 0; id < bdev.size(); ++id) { + uint64_t total = 0; + interval_set& p = block_all[id]; + for (interval_set::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 *extents) { Mutex::Locker l(lock); diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 0c9bb6dfc04a..e682dec1121e 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -242,6 +242,7 @@ public: uint64_t get_total(unsigned id); uint64_t get_free(unsigned id); + void get_usage(vector> *usage); // [ ...] /// get current extents that we own for given block device int get_block_extents(unsigned id, interval_set *extents);