From: Sage Weil Date: Tue, 20 Feb 2018 22:47:21 +0000 (-0600) Subject: os/bluestore: hook to expose utilization of thinly-provisioned device X-Git-Tag: v13.1.0~386^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=266d1649cf1d57ab32a71a39347bb418a4490c78;p=ceph.git os/bluestore: hook to expose utilization of thinly-provisioned device Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 012b31d7e9ce..d3ae6872ea59 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -138,6 +138,11 @@ public: uint64_t get_size() const { return size; } uint64_t get_block_size() const { return block_size; } + /// hook to provide utilization of thinly-provisioned device + virtual bool get_thin_utilization(uint64_t *total, uint64_t *avail) const { + return false; + } + virtual int collect_metadata(const std::string& prefix, std::map *pm) const = 0; virtual int get_devname(std::string *out) { diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e4cc918219e7..14f53dac33f0 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -6404,9 +6404,8 @@ int BlueStore::get_devices(set *ls) int BlueStore::statfs(struct store_statfs_t *buf) { buf->reset(); - buf->total = bdev->get_size(); - buf->available = alloc->get_free(); + uint64_t bfree = alloc->get_free(); if (bluefs) { // part of our shared device is "free" according to BlueFS, but we // can't touch bluestore_bluefs_min of it. @@ -6414,13 +6413,31 @@ int BlueStore::statfs(struct store_statfs_t *buf) bluefs->get_free(bluefs_shared_bdev), bluefs->get_total(bluefs_shared_bdev) - cct->_conf->bluestore_bluefs_min); if (shared_available > 0) { - buf->available += shared_available; + bfree += shared_available; + } + } + + uint64_t thin_total, thin_avail; + if (bdev->get_thin_utilization(&thin_total, &thin_avail)) { + buf->total += thin_total; + + // we are limited by both the size of the virtual device and the + // underlying physical device. + bfree = std::min(bfree, thin_avail); + } else { + buf->total = bdev->get_size(); + } + buf->available += bfree; + + if (bluefs) { + // include dedicated db, too, if that isn't the shared device. + if (bluefs_shared_bdev != BlueFS::BDEV_DB) { + buf->total += bluefs->get_total(BlueFS::BDEV_DB); } } { std::lock_guard l(vstatfs_lock); - buf->allocated = vstatfs.allocated(); buf->stored = vstatfs.stored(); buf->compressed = vstatfs.compressed(); @@ -6428,7 +6445,7 @@ int BlueStore::statfs(struct store_statfs_t *buf) buf->compressed_allocated = vstatfs.compressed_allocated(); } - dout(20) << __func__ << *buf << dendl; + dout(20) << __func__ << " " << *buf << dendl; return 0; }