]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore: implement thin provisioning utilization stats for VDO
authorSage Weil <sage@redhat.com>
Wed, 21 Feb 2018 19:40:07 +0000 (13:40 -0600)
committerSage Weil <sage@redhat.com>
Mon, 2 Apr 2018 20:19:35 +0000 (15:19 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/filestore/FileStore.cc
src/os/filestore/FileStore.h

index 6a0fd8603c6387a8f6bf55b2db43c40201f9d895..a1db3ab4c7f71cf9b449578252c15cb67bc73714 100644 (file)
@@ -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;
index 9aeaefa7f3c5a9994cbd70ca4b5ce65e60124241..23f730353f113d870b07518a3045b62de5bd090f 100644 (file)
@@ -166,6 +166,9 @@ private:
 
   void create_backend(long f_type);
 
+  int vdo_fd = -1;
+  string vdo_name;
+
   deque<uint64_t> snaps;
 
   // Indexed Collections