]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: do not precalculate/cache shard keys 12634/head
authorSage Weil <sage@redhat.com>
Fri, 23 Dec 2016 20:48:50 +0000 (15:48 -0500)
committerSage Weil <sage@redhat.com>
Fri, 23 Dec 2016 20:48:50 +0000 (15:48 -0500)
Note that we are generating it on demand now.  We can
probably do better, especially when in a loop.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 54dd77f8b10cd17ea00a58791fd1ab56ac52b247..c27734c77dbca74d8a8dadd845178d3f15b44c05 100644 (file)
@@ -1629,7 +1629,7 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
   } else {
 
     struct dirty_shard_t{
-      string* key = nullptr;
+      uint32_t offset = 0;
       bufferlist bl;
       boost::intrusive::list_member_hook<> dirty_list_item;
     };
@@ -1683,7 +1683,7 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
        p->shard_info->bytes = len;
        p->shard_info->extents = nn;
         
-        encoded_shards[pos].key = &p->key;
+        encoded_shards[pos].offset = p->offset;
         dirty_shards.push_back(encoded_shards[pos]);
        p->dirty = false;
       }
@@ -1692,8 +1692,10 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
     }
     //schedule DB update for dirty shards
     auto it = dirty_shards.begin();
-    while(it != dirty_shards.end()) {
-      t->set(PREFIX_OBJ, *(it->key), it->bl);
+    while (it != dirty_shards.end()) {
+      string key;
+      get_extent_shard_key(onode->key, it->offset, &key);
+      t->set(PREFIX_OBJ, key, it->bl);
       ++it;
     }
   }
@@ -2049,7 +2051,6 @@ void BlueStore::ExtentMap::init_shards(bool loaded, bool dirty)
   shards.resize(onode->onode.extent_map_shards.size());
   unsigned i = 0;
   for (auto &s : onode->onode.extent_map_shards) {
-    get_extent_shard_key(onode->key, s.offset, &shards[i].key);
     shards[i].offset = s.offset;
     shards[i].shard_info = &s;
     shards[i].loaded = loaded;
@@ -4460,7 +4461,8 @@ int BlueStore::fsck(bool deep)
       }
       for (auto& s : o->extent_map.shards) {
        dout(20) << __func__ << "    shard " << *s.shard_info << dendl;
-       expecting_shards.push_back(s.key);
+       expecting_shards.push_back(string());
+       get_extent_shard_key(o->key, s.offset, &expecting_shards.back());
       }
       // lextents
       uint64_t pos = 0;
@@ -6432,7 +6434,9 @@ void BlueStore::_txc_write_nodes(TransContext *txc, KeyValueDB::Transaction t)
     if (reshard) {
       dout(20) << __func__ << "  resharding extents for " << o->oid << dendl;
       for (auto &s : o->extent_map.shards) {
-       t->rmkey(PREFIX_OBJ, s.key);
+       string key;
+       get_extent_shard_key(o->key, s.offset, &key);
+       t->rmkey(PREFIX_OBJ, key);
       }
       o->extent_map.fault_range(db, 0, o->onode.size);
       o->extent_map.reshard(min_alloc_size);
@@ -8393,7 +8397,9 @@ int BlueStore::_do_remove(
   o->onode = bluestore_onode_t();
   txc->removed(o);
   for (auto &s : o->extent_map.shards) {
-    txc->t->rmkey(PREFIX_OBJ, s.key);
+    string key;
+    get_extent_shard_key(o->key, s.offset, &key);
+    txc->t->rmkey(PREFIX_OBJ, key);
   }
   txc->t->rmkey(PREFIX_OBJ, o->key);
   o->extent_map.clear();
@@ -8935,8 +8941,9 @@ int BlueStore::_rename(TransContext *txc,
   oldo->extent_map.fault_range(db, 0, oldo->onode.size);
   get_object_key(new_oid, &new_okey);
   for (auto &s : oldo->extent_map.shards) {
-    txc->t->rmkey(PREFIX_OBJ, s.key);
-    get_extent_shard_key(new_okey, s.offset, &s.key);
+    string key;
+    get_extent_shard_key(oldo->key, s.offset, &key);
+    txc->t->rmkey(PREFIX_OBJ, key);
     s.dirty = true;
   }
 
index b5e217cfcd3dd1b34243c8763d99a9caccb7f58b..bdeeec43f28a502d0d92a2ddacc32f0d0c458cef 100644 (file)
@@ -644,9 +644,8 @@ public:
     blob_map_t spanning_blob_map;   ///< blobs that span shards
 
     struct Shard {
-      string key;            ///< kv key
-      uint32_t offset;       ///< starting logical offset
       bluestore_onode_t::shard_info *shard_info;
+      uint32_t offset = 0;   ///< starting logical offset
       bool loaded = false;   ///< true if shard is loaded
       bool dirty = false;    ///< true if shard is dirty and needs reencoding
     };