]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: simplify dirty shard handling in ExtentMap::update
authorSage Weil <sage@redhat.com>
Thu, 2 Feb 2017 21:05:14 +0000 (16:05 -0500)
committerSage Weil <sage@redhat.com>
Thu, 2 Feb 2017 22:25:55 +0000 (17:25 -0500)
We can do this with a single allocation with a simple vector<>.

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

index bafede6298190f896d612a66a1cd23066edc858f..61e82b3de5664f8a98455af0734fdc1abdd68492 100644 (file)
@@ -1770,26 +1770,16 @@ void BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
     }
     // will persist in the onode key.
   } else {
-
+    // pending shard update
     struct dirty_shard_t {
-      Shard *shard = nullptr;
+      Shard *shard;
       bufferlist bl;
-      boost::intrusive::list_member_hook<> dirty_list_item;
+      dirty_shard_t(Shard *s) : shard(s) {}
     };
-
-    typedef boost::intrusive::list<
-      dirty_shard_t,
-      boost::intrusive::member_hook<
-        dirty_shard_t,
-        boost::intrusive::list_member_hook<>,
-        &dirty_shard_t::dirty_list_item> > dirty_shard_list_t;
-
     vector<dirty_shard_t> encoded_shards;
     // allocate slots for all shards in a single call instead of
     // doing multiple allocations - one per each dirty shard
-    encoded_shards.resize(shards.size()); 
-
-    dirty_shard_list_t dirty_shards;
+    encoded_shards.reserve(shards.size());
 
     auto p = shards.begin();
     unsigned pos = 0;
@@ -1804,7 +1794,8 @@ void BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
        } else {
          endoff = n->offset;
        }
-        bufferlist& bl = encoded_shards[pos].bl;
+       encoded_shards.emplace_back(dirty_shard_t(&(*p)));
+        bufferlist& bl = encoded_shards.back().bl;
        if (encode_some(p->offset, endoff - p->offset, bl, &p->extents)) {
          if (force) {
            derr << __func__ << "  encode_some needs reshard" << dendl;
@@ -1849,9 +1840,6 @@ void BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
          }
         }
        assert(p->shard_info->offset == p->offset);
-        
-       encoded_shards[pos].shard = &(*p);
-        dirty_shards.push_back(encoded_shards[pos]);
       }
       prev_p = p;
       p = n;
@@ -1862,17 +1850,15 @@ void BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
     }
 
     // schedule DB update for dirty shards
-    auto it = dirty_shards.begin();
     string key;
-    while (it != dirty_shards.end()) {
-      it->shard->dirty = false;
-      it->shard->shard_info->bytes = it->bl.length();
-      generate_extent_shard_key_and_apply(onode->key, it->shard->offset, &key,
+    for (auto& it : encoded_shards) {
+      it.shard->dirty = false;
+      it.shard->shard_info->bytes = it.bl.length();
+      generate_extent_shard_key_and_apply(onode->key, it.shard->offset, &key,
         [&](const string& final_key) {
-          t->set(PREFIX_OBJ, final_key, it->bl);
+          t->set(PREFIX_OBJ, final_key, it.bl);
         }
       );
-      ++it;
     }
   }
 }