]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/KeyValueDB: take key_prefix for estimate_prefix_size()
authorSage Weil <sage@redhat.com>
Tue, 23 Jul 2019 22:11:04 +0000 (17:11 -0500)
committerSage Weil <sage@redhat.com>
Tue, 6 Aug 2019 14:24:14 +0000 (09:24 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/kv/KeyValueDB.h
src/kv/RocksDBStore.cc
src/kv/RocksDBStore.h
src/os/bluestore/BlueStore.cc

index b7c3722cc177669f802cef5b64118c705d6cc0fb..2ac43e7daac85c312b74cfec3126e09e55be3fad 100644 (file)
@@ -367,7 +367,8 @@ public:
   virtual ~KeyValueDB() {}
 
   /// estimate space utilization for a prefix (in bytes)
-  virtual int64_t estimate_prefix_size(const string& prefix) {
+  virtual int64_t estimate_prefix_size(const string& prefix,
+                                      const string& key_prefix) {
     return 0;
   }
 
index 4756697f270c4de0b3996cb65bfde3d067be2ed3..df5a2ef0d7bb2f9d055b37816722582ab33376dc 100644 (file)
@@ -691,7 +691,8 @@ void RocksDBStore::split_stats(const std::string &s, char delim, std::vector<std
     }
 }
 
-int64_t RocksDBStore::estimate_prefix_size(const string& prefix)
+int64_t RocksDBStore::estimate_prefix_size(const string& prefix,
+                                          const string& key_prefix)
 {
   auto cf = get_cf_handle(prefix);
   uint64_t size = 0;
@@ -699,15 +700,15 @@ int64_t RocksDBStore::estimate_prefix_size(const string& prefix)
     //rocksdb::DB::INCLUDE_MEMTABLES |  // do not include memtables...
     rocksdb::DB::INCLUDE_FILES;
   if (cf) {
-    string start(1, '\x00');
-    string limit("\xff\xff\xff\xff");
+    string start = key_prefix + string(1, '\x00');
+    string limit = key_prefix + string("\xff\xff\xff\xff");
     rocksdb::Range r(start, limit);
     db->GetApproximateSizes(cf, &r, 1, &size, flags);
   } else {
-    string limit = prefix + "\xff\xff\xff\xff";
-    rocksdb::Range r(prefix, limit);
-    db->GetApproximateSizes(default_cf,
-                           &r, 1, &size, flags);
+    string start = prefix + key_prefix;
+    string limit = prefix + key_prefix + "\xff\xff\xff\xff";
+    rocksdb::Range r(start, limit);
+    db->GetApproximateSizes(default_cf, &r, 1, &size, flags);
   }
   return size;
 }
index ea7c77d3c767ed01c955ba51f2ab3b4db761a911..5eb9549c28628873917029b29d7dda9dc679453f 100644 (file)
@@ -197,7 +197,8 @@ public:
     return logger;
   }
 
-  int64_t estimate_prefix_size(const string& prefix) override;
+  int64_t estimate_prefix_size(const string& prefix,
+                              const string& key_prefix) override;
 
   struct  RocksWBHandler: public rocksdb::WriteBatch::Handler {
     std::string seen ;
index 7190a6e4a22990fde804477ca2031eed3d81698f..8d443fd895deec844f683b15a0f56c4115906842 100644 (file)
@@ -8211,7 +8211,7 @@ void BlueStore::_get_statfs_overall(struct store_statfs_t *buf)
 {
   buf->reset();
 
-  buf->omap_allocated = db->estimate_prefix_size(PREFIX_OMAP);
+  buf->omap_allocated = db->estimate_prefix_size(PREFIX_OMAP, string());
 
   uint64_t bfree = alloc->get_free();