From: Sage Weil Date: Wed, 21 Feb 2018 17:13:06 +0000 (-0600) Subject: os/bluestore/KernelDevice: implement thin utilization stats for VDO X-Git-Tag: v13.1.0~386^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97ca41ce1806c32e56fab74e50c58d5f939e8713;p=ceph.git os/bluestore/KernelDevice: implement thin utilization stats for VDO Detect if we are a VDO device. If so, pull the stats out of sysfs so that we can report meaningful utilization numbers. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index dbc384eebb16..bbd1a0badb87 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -138,6 +138,8 @@ int KernelDevice::open(const string& p) dout(20) << __func__ << " devname " << devname << dendl; rotational = block_device_is_rotational(devname); this->devname = devname; + + _detect_vdo(); } } @@ -192,6 +194,11 @@ void KernelDevice::close() delete fs; fs = NULL; + if (vdo_fd >= 0) { + VOID_TEMP_FAILURE_RETRY(::close(vdo_fd)); + vdo_fd = -1; + } + assert(fd_direct >= 0); VOID_TEMP_FAILURE_RETRY(::close(fd_direct)); fd_direct = -1; @@ -269,6 +276,26 @@ int KernelDevice::collect_metadata(const string& prefix, map *pm) return 0; } +void KernelDevice::_detect_vdo() +{ + vdo_fd = get_vdo_stats_handle(devname.c_str(), &vdo_name); + if (vdo_fd >= 0) { + dout(1) << __func__ << " VDO volume " << vdo_name + << " maps to " << devname << dendl; + } else { + dout(20) << __func__ << " no VDO volume maps to " << devname << dendl; + } + return; +} + +bool KernelDevice::get_thin_utilization(uint64_t *total, uint64_t *avail) const +{ + if (vdo_fd < 0) { + return false; + } + return get_vdo_utilization(vdo_fd, total, avail); +} + int KernelDevice::flush() { // protect flush with a mutex. note that we are not really protecting diff --git a/src/os/bluestore/KernelDevice.h b/src/os/bluestore/KernelDevice.h index c0c797f04618..2fa40a9b781c 100644 --- a/src/os/bluestore/KernelDevice.h +++ b/src/os/bluestore/KernelDevice.h @@ -29,6 +29,9 @@ class KernelDevice : public BlockDevice { FS *fs; bool aio, dio; + int vdo_fd = -1; ///< fd for vdo sysfs directory + string vdo_name; + std::string devname; ///< kernel dev name (/sys/block/$devname), if any Mutex debug_lock; @@ -72,6 +75,8 @@ class KernelDevice : public BlockDevice { void debug_aio_link(aio_t& aio); void debug_aio_unlink(aio_t& aio); + void _detect_vdo(); + public: KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv); @@ -87,6 +92,8 @@ public: } int get_devices(std::set *ls) override; + bool get_thin_utilization(uint64_t *total, uint64_t *avail) const override; + int read(uint64_t off, uint64_t len, bufferlist *pbl, IOContext *ioc, bool buffered) override;