From: Sage Weil Date: Wed, 21 Feb 2018 19:40:07 +0000 (-0600) Subject: os/filestore: implement thin provisioning utilization stats for VDO X-Git-Tag: v13.1.0~386^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=88d655a7fac046de17e1304bddd2e619da903c51;p=ceph.git os/filestore: implement thin provisioning utilization stats for VDO Signed-off-by: Sage Weil --- diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index 6a0fd8603c63..a1db3ab4c7f7 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -735,8 +735,17 @@ int FileStore::statfs(struct store_statfs_t *buf0) assert(r != -ENOENT); return r; } - buf0->total = buf.f_blocks * buf.f_bsize; - buf0->available = buf.f_bavail * buf.f_bsize; + + uint64_t bfree = buf.f_bavail * buf.f_bsize; + uint64_t thin_total, thin_avail; + if (get_vdo_utilization(vdo_fd, &thin_total, &thin_avail)) { + buf0->total = thin_total; + bfree = std::min(bfree, thin_avail); + } else { + buf0->total = buf.f_blocks * buf.f_bsize; + } + buf0->available = bfree; + // Adjust for writes pending in the journal if (journal) { uint64_t estimate = journal->get_journal_size_estimate(); @@ -1223,6 +1232,20 @@ int FileStore::_detect_fs() return r; } + // vdo + { + char partition_path[PATH_MAX]; + char dev_node[PATH_MAX]; + int rc = get_device_by_fd(fsid_fd, partition_path, dev_node, PATH_MAX); + if (rc == 0) { + vdo_fd = get_vdo_stats_handle(dev_node, &vdo_name); + if (vdo_fd >= 0) { + dout(0) << __func__ << " VDO volume " << vdo_name << " for " << dev_node + << dendl; + } + } + } + // test xattrs char fn[PATH_MAX]; int x = rand(); @@ -1984,6 +2007,10 @@ int FileStore::umount() (*it)->stop(); } + if (vdo_fd >= 0) { + VOID_TEMP_FAILURE_RETRY(::close(vdo_fd)); + vdo_fd = -1; + } if (fsid_fd >= 0) { VOID_TEMP_FAILURE_RETRY(::close(fsid_fd)); fsid_fd = -1; diff --git a/src/os/filestore/FileStore.h b/src/os/filestore/FileStore.h index 9aeaefa7f3c5..23f730353f11 100644 --- a/src/os/filestore/FileStore.h +++ b/src/os/filestore/FileStore.h @@ -166,6 +166,9 @@ private: void create_backend(long f_type); + int vdo_fd = -1; + string vdo_name; + deque snaps; // Indexed Collections