]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: hook to expose utilization of thinly-provisioned device
authorSage Weil <sage@redhat.com>
Tue, 20 Feb 2018 22:47:21 +0000 (16:47 -0600)
committerSage Weil <sage@redhat.com>
Mon, 2 Apr 2018 20:19:19 +0000 (15:19 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlockDevice.h
src/os/bluestore/BlueStore.cc

index 012b31d7e9ceb33f1590a78beaad40a9a61201db..d3ae6872ea599bcb6cc281e52040173e4b982bd6 100644 (file)
@@ -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<std::string,std::string> *pm) const = 0;
 
   virtual int get_devname(std::string *out) {
index e4cc918219e70c3ebe24bfb13d8b73dcd8563ca3..14f53dac33f06261e8511ee829c7730187c4b928 100644 (file)
@@ -6404,9 +6404,8 @@ int BlueStore::get_devices(set<string> *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<std::mutex> 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;
 }