]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os: extend ObjectStore interface with per-pool statistics access method
authorIgor Fedotov <ifedotov@suse.com>
Wed, 6 Dec 2017 17:01:41 +0000 (20:01 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Thu, 6 Dec 2018 15:54:21 +0000 (18:54 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/ObjectStore.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/filestore/FileStore.cc
src/os/filestore/FileStore.h
src/os/kstore/KStore.cc
src/os/kstore/KStore.h
src/os/memstore/MemStore.cc
src/os/memstore/MemStore.h

index 9810c9630aa7bd3697ee3abcf7a4a4cfbc619e38..7cb53adf4486632c84b567d3500abc5492e7429a 100644 (file)
@@ -1551,6 +1551,7 @@ public:
   }
 
   virtual int statfs(struct store_statfs_t *buf) = 0;
+  virtual int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) = 0;
 
   virtual void collect_metadata(map<string,string> *pm) { }
 
index 960b668c526506ab3ab51b91375e53db2959ac50..1494af6f2bfcd8b573a9f82cf98c35c451609292 100644 (file)
@@ -7608,6 +7608,14 @@ int BlueStore::statfs(struct store_statfs_t *buf)
     if (shared_available > 0) {
       bfree += shared_available;
     }
+    // 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);
+    }
+    // call any non-omap bluefs space "internal metadata"
+    buf->internal_metadata =
+      std::max(bluefs->get_used(), (uint64_t)cct->_conf->bluestore_bluefs_min)
+      - buf->omap_allocated;
   }
 
   {
@@ -7629,23 +7637,34 @@ int BlueStore::statfs(struct store_statfs_t *buf)
 
     buf->allocated = thin_total - thin_avail;
   } else {
-    buf->total = bdev->get_size();
+    buf->total += bdev->get_size();
   }
-  buf->available += bfree;
+  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);
-    }
+  dout(20) << __func__ << " " << *buf << dendl;
+  return 0;
+}
 
-    // call any non-omap bluefs space "internal metadata"
-    buf->internal_metadata =
-      std::max(bluefs->get_used(), (uint64_t)cct->_conf->bluestore_bluefs_min)
-      - buf->omap_allocated;
+int BlueStore::pool_statfs(uint64_t pool_id, struct store_statfs_t *buf)
+{
+  dout(20) << __func__ << " pool " << pool_id<< dendl;
+  if (!per_pool_stat_collection) {
+    dout(20) << __func__ << " not supported in a legacy mode " << dendl;
+    return -ENOTSUP;
   }
+  buf->reset();
 
-  dout(20) << __func__ << " " << *buf << dendl;
+  {
+    std::lock_guard l(vstatfs_lock);
+    auto& pool_stat = osd_pools[pool_id];
+    buf->allocated = pool_stat.allocated();
+    buf->data_stored = pool_stat.stored();
+    buf->data_compressed = pool_stat.compressed();
+    buf->data_compressed_original = pool_stat.compressed_original();
+    buf->data_compressed_allocated = pool_stat.compressed_allocated();
+  }
+
+  dout(20) << __func__ << *buf << dendl;
   return 0;
 }
 
@@ -10472,7 +10491,6 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
   for (vector<coll_t>::iterator p = i.colls.begin(); p != i.colls.end();
        ++p, ++j) {
     cvec[j] = _get_collection(*p);
-    
   }
   
   vector<OnodeRef> ovec(i.objects.size());
@@ -10488,6 +10506,7 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
 
     // collection operations
     CollectionRef &c = cvec[op->cid];
+
     // initialize osd_pool_id and do a smoke test that all collections belong
     // to the same pool
     spg_t pgid;
@@ -10496,6 +10515,7 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
                   txc->osd_pool_id == (int64_t)pgid.pool());
       txc->osd_pool_id = (int64_t)pgid.pool();
     }
+
     switch (op->op) {
     case Transaction::OP_RMCOLL:
       {
index 511da1390a33c2fac71b7ed7743f7c061789ff0f..4f89ceeae763b51544bb5da6c12b0f89938607db 100644 (file)
@@ -2410,6 +2410,7 @@ public:
 
 public:
   int statfs(struct store_statfs_t *buf) override;
+  int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) override;
 
   void collect_metadata(map<string,string> *pm) override;
 
index bb32cc33fcb5f225d666ecd619a956e3ef58afb3..211b26fc09f9c307defcfec7e0657026eaf9bea9 100644 (file)
@@ -778,6 +778,10 @@ int FileStore::statfs(struct store_statfs_t *buf0)
   return 0;
 }
 
+int FileStore::pool_statfs(uint64_t pool_id, struct store_statfs_t *buf)
+{
+  return -ENOTSUP;
+}
 
 void FileStore::new_journal()
 {
index 50343607c7f26c1d7842c79d84b5be9fc50fc38a..0687fcd5c503c65b27c30943e64d62736a6ebeaf 100644 (file)
@@ -518,6 +518,7 @@ public:
   int get_devices(set<string> *ls) override;
 
   int statfs(struct store_statfs_t *buf) override;
+  int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) override;
 
   int _do_transactions(
     vector<Transaction> &tls, uint64_t op_seq,
index 616ca1b6a25eed8c290efb1bfd8536aa9e5ac27d..39071f481d3d4d555fcd65655e9b21a593805c48 100644 (file)
@@ -1099,7 +1099,6 @@ int KStore::statfs(struct store_statfs_t* buf0)
   return 0;
 }
 
-
 ObjectStore::CollectionHandle KStore::open_collection(const coll_t& cid)
 {
   return _get_collection(cid);
@@ -1113,6 +1112,11 @@ ObjectStore::CollectionHandle KStore::create_new_collection(const coll_t& cid)
   return c;
 }
 
+int KStore::pool_statfs(uint64_t pool_id, struct store_statfs_t *buf)
+{
+  return -ENOTSUP;
+}
+
 // ---------------
 // cache
 
index 3ac7d2dd88e88196a3aa5ba0e81ac3d7ca867f84..01abaa0b375847f2e6405961679b72b440f47d54 100644 (file)
@@ -440,6 +440,7 @@ public:
     db->get_statistics(f);
   }
   int statfs(struct store_statfs_t *buf) override;
+  int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) override;
 
   CollectionHandle open_collection(const coll_t& c) override;
   CollectionHandle create_new_collection(const coll_t& c) override;
index f3a7e39abbbe890484e9d7024dd3b32ff026b798..d37f7c7ef617d9dae128c65e2c89d131a38561b2 100644 (file)
@@ -231,6 +231,11 @@ int MemStore::statfs(struct store_statfs_t *st)
   return 0;
 }
 
+int MemStore::pool_statfs(uint64_t pool_id, struct store_statfs_t *buf)
+{
+  return -ENOTSUP;
+}
+
 objectstore_perf_stat_t MemStore::get_cur_stats()
 {
   // fixme
index 5c716138ec1b2272dfd9bc38c0dc0b773b1b33a2..77b2a32c6e7d51dc069b7d10d6124b26815ae4c6 100644 (file)
@@ -291,6 +291,7 @@ public:
   }
 
   int statfs(struct store_statfs_t *buf) override;
+  int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) override;
 
   bool exists(CollectionHandle &c, const ghobject_t& oid) override;
   int stat(CollectionHandle &c, const ghobject_t& oid,