]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: recalculate shared blob key instead of keeping it in memory
authorIgor Fedotov <ifedotov@mirantis.com>
Mon, 19 Dec 2016 12:55:09 +0000 (12:55 +0000)
committerIgor Fedotov <ifedotov@mirantis.com>
Mon, 19 Dec 2016 15:06:24 +0000 (15:06 +0000)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 7b6084fdd79c5b86cd6d0fb9d3553efbb469921a..2502e3be1bd9a935616ffd351a608fa9563a2fcc 100644 (file)
@@ -1291,7 +1291,6 @@ BlueStore::SharedBlob::SharedBlob(uint64_t i, Cache *c)
     bc(c)
 {
   assert(sbid > 0);
-  get_shared_blob_key(sbid, &key);
 }
 
 BlueStore::SharedBlob::~SharedBlob()
@@ -2340,10 +2339,12 @@ void BlueStore::Collection::load_shared_blob(SharedBlobRef sb)
 {
   assert(!sb->loaded);
   bufferlist v;
-  int r = store->db->get(PREFIX_SHARED_BLOB, sb->key, &v);
+  string key;
+  get_shared_blob_key(sb->sbid, &key);
+  int r = store->db->get(PREFIX_SHARED_BLOB, key, &v);
   if (r < 0) {
     derr << __func__ << " sbid 0x" << std::hex << sb->sbid << std::dec
-        << " not found at key " << pretty_binary_string(sb->key) << dendl;
+        << " not found at key " << pretty_binary_string(key) << dendl;
     assert(0 == "uh oh, missing shared_blob");
   }
 
@@ -2366,7 +2367,6 @@ void BlueStore::Collection::make_blob_shared(BlobRef b)
   // update shared blob
   b->shared_blob->loaded = true;  // we are new and therefore up to date
   b->shared_blob->sbid = blob.sbid;
-  get_shared_blob_key(blob.sbid, &b->shared_blob->key);
   shared_blob_set.add(b->shared_blob.get());
   for (auto p : blob.extents) {
     if (p.is_valid()) {
@@ -6414,16 +6414,18 @@ void BlueStore::_txc_write_nodes(TransContext *txc, KeyValueDB::Transaction t)
 
   // finalize shared_blobs
   for (auto sb : txc->shared_blobs) {
+    string key;
+    get_shared_blob_key(sb->sbid, &key);
     if (sb->shared_blob.empty()) {
       dout(20) << "  shared_blob 0x" << std::hex << sb->sbid << std::dec
               << " is empty" << dendl;
-      t->rmkey(PREFIX_SHARED_BLOB, sb->key);
+      t->rmkey(PREFIX_SHARED_BLOB, key);
     } else {
       bufferlist bl;
       ::encode(sb->shared_blob, bl);
       dout(20) << "  shared_blob 0x" << std::hex << sb->sbid << std::dec
               << " is " << bl.length() << dendl;
-      t->set(PREFIX_SHARED_BLOB, sb->key, bl);
+      t->set(PREFIX_SHARED_BLOB, key, bl);
     }
   }
 }
index 421f75e989b02db40f7dcff0305e132d1dc04aad..f951546ca10be9351bdf97e8a92a662bcf632760 100644 (file)
@@ -334,7 +334,6 @@ public:
 
     // these are defined/set if the blob is marked 'shared'
     uint64_t sbid = 0;          ///< shared blob id
-    string key;                 ///< key in kv store
     SharedBlobSet *parent_set = 0;  ///< containing SharedBlobSet
 
     BufferSpace bc;             ///< buffer cache