]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: replace needs_reshard flag with a range
authorSage Weil <sage@redhat.com>
Fri, 27 Jan 2017 16:07:22 +0000 (11:07 -0500)
committerSage Weil <sage@redhat.com>
Thu, 2 Feb 2017 15:12:08 +0000 (10:12 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 965b5afc9175e122e6a89c477c66100545795655..0e081fe7e4fe237b6ace581e88c946ab558e982e 100644 (file)
@@ -1753,7 +1753,7 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
                                   bool force)
 {
   auto cct = onode->c->store->cct; //used by dout
-  assert(!needs_reshard);
+  assert(!needs_reshard());
   if (onode->onode.extent_map_shards.empty()) {
     if (inline_bl.length() == 0) {
       unsigned n;
@@ -1848,9 +1848,10 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
 
 void BlueStore::ExtentMap::reshard()
 {
-  auto cct = onode->c->store->cct; //used by dout
+  auto cct = onode->c->store->cct; // used by dout
 
-  needs_reshard = false;
+  dout(10) << __func__ << " 0x[" << std::hex << needs_reshard_begin << ","
+          << needs_reshard_end << ")" << std::dec << dendl;
 
   // un-span all blobs
   auto p = spanning_blob_map.begin();
@@ -1864,6 +1865,7 @@ void BlueStore::ExtentMap::reshard()
     dout(20) << __func__ << " <= 1 extent, going inline" << dendl;
     shards.clear();
     onode->onode.extent_map_shards.clear();
+    clear_needs_reshard();
     return;
   }
 
@@ -1989,6 +1991,8 @@ void BlueStore::ExtentMap::reshard()
       }
     }
   }
+
+  clear_needs_reshard();
 }
 
 bool BlueStore::ExtentMap::encode_some(
@@ -2482,8 +2486,8 @@ BlueStore::Extent *BlueStore::ExtentMap::set_lextent(
   }
   Extent *le = new Extent(logical_offset, blob_offset, length, b);
   extent_map.insert(*le);
-  if (!needs_reshard && spans_shard(logical_offset, length)) {
-    needs_reshard = true;
+  if (spans_shard(logical_offset, length)) {
+    request_reshard(logical_offset, logical_offset + length);
   }
   return le;
 }
@@ -6854,7 +6858,7 @@ void BlueStore::_txc_write_nodes(TransContext *txc, KeyValueDB::Transaction t)
   // finalize onodes
   for (auto o : txc->onodes) {
     // finalize extent_map shards
-    bool reshard = o->extent_map.needs_reshard;
+    bool reshard = o->extent_map.needs_reshard();
     if (!reshard) {
       reshard = o->extent_map.update(t, false);
     }
index 160a96f2754834673e3f2c7bfd3a67ece0138e0b..90260feb2068b85bfd14a53694626c759fa8469f 100644 (file)
@@ -671,7 +671,23 @@ public:
 
     bufferlist inline_bl;    ///< cached encoded map, if unsharded; empty=>dirty
 
-    bool needs_reshard = false;   ///< true if we must reshard
+    uint32_t needs_reshard_begin = 0;
+    uint32_t needs_reshard_end = 0;
+
+    bool needs_reshard() const {
+      return needs_reshard_end > needs_reshard_begin;
+    }
+    void clear_needs_reshard() {
+      needs_reshard_begin = needs_reshard_end = 0;
+    }
+    void request_reshard(uint32_t begin, uint32_t end) {
+      if (begin < needs_reshard_begin) {
+       needs_reshard_begin = begin;
+      }
+      if (end > needs_reshard_end) {
+       needs_reshard_end = end;
+      }
+    }
 
     struct DeleteDisposer {
       void operator()(Extent *e) { delete e; }
@@ -686,7 +702,7 @@ public:
       extent_map.clear_and_dispose(DeleteDisposer());
       shards.clear();
       inline_bl.clear();
-      needs_reshard = false;
+      clear_needs_reshard();
     }
 
     bool encode_some(uint32_t offset, uint32_t length, bufferlist& bl,