]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: vector -> interval set in GC to track extents to collect.
authorIgor Fedotov <ifedotov@suse.com>
Wed, 22 May 2019 21:51:47 +0000 (00:51 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Thu, 23 May 2019 14:08:19 +0000 (17:08 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/test/objectstore/test_bluestore_types.cc

index b623eeb4cc88b6e7fe1c3fcf06003beedc908b30..be0867580f8a311c300777a11bbd9b44a9e32f46 100644 (file)
@@ -812,7 +812,7 @@ void BlueStore::GarbageCollector::process_protrusive_extents(
           bool bExit = false;
           do {
             if (it->blob.get() == b) {
-              extents_to_collect.emplace_back(it->logical_offset, it->length);
+              extents_to_collect.insert(it->logical_offset, it->length);
             }
             bExit = it == bi.last_lextent;
             ++it;
@@ -11522,7 +11522,9 @@ void BlueStore::_do_write_small(
 
     if (ep != end && ep->logical_offset < offset + max_bsize) {
       BlobRef b = ep->blob;
+
       auto bstart = ep->blob_start();
+
       dout(20) << __func__ << " considering " << *b
               << " bstart 0x" << std::hex << bstart << std::dec << dendl;
       if (bstart >= end_offs) {
@@ -11727,6 +11729,7 @@ void BlueStore::_do_write_small(
     // check extent for reuse in reverse order
     if (prev_ep != end && prev_ep->logical_offset >= min_off) {
       BlobRef b = prev_ep->blob;
+
       auto bstart = prev_ep->blob_start();
       dout(20) << __func__ << " considering " << *b
               << " bstart 0x" << std::hex << bstart << std::dec << dendl;
@@ -12405,19 +12408,22 @@ int BlueStore::_do_gc(
        it != extents_to_collect.end();
        ++it) {
     bufferlist bl;
-    int r = _do_read(c.get(), o, it->offset, it->length, bl, 0);
-    ceph_assert(r == (int)it->length);
+    auto offset = (*it).first;
+    auto length = (*it).second;
+
+    int r = _do_read(c.get(), o, offset, length, bl, 0);
+    ceph_assert(r == (int)length);
 
-    _do_write_data(txc, c, o, it->offset, it->length, bl, &wctx_gc);
-    logger->inc(l_bluestore_gc_merged, it->length);
+    _do_write_data(txc, c, o, offset, length, bl, &wctx_gc);
+    logger->inc(l_bluestore_gc_merged, length);
 
-    if (*dirty_start > it->offset) {
-      *dirty_start = it->offset;
+    if (*dirty_start > offset) {
+      *dirty_start = offset;
       dirty_range_updated = true;
     }
 
-    if (*dirty_end < it->offset + it->length) {
-      *dirty_end = it->offset + it->length;
+    if (*dirty_end < offset + length) {
+      *dirty_end = offset + length;
       dirty_range_updated = true;
     }
   }
index b74a873cd5241982b8c38ba2cc3c6330ac055497..c570ea8b0a7151071114789bc5cee0d022c76887 100644 (file)
@@ -968,7 +968,7 @@ public:
       uint64_t min_alloc_size);
 
     /// return a collection of extents to perform GC on
-    const vector<bluestore_pextent_t>& get_extents_to_collect() const {
+    const interval_set<uint64_t>& get_extents_to_collect() const {
       return extents_to_collect;
     }
     GarbageCollector(CephContext* _cct) : cct(_cct) {}
@@ -999,7 +999,7 @@ public:
                                          ///< specific write
 
     ///< protrusive extents that should be collected if GC takes place
-    vector<bluestore_pextent_t> extents_to_collect;
+    interval_set<uint64_t> extents_to_collect;
 
     boost::optional<uint64_t > used_alloc_unit; ///< last processed allocation
                                                 ///<  unit when traversing 
index 4e8c21a8d70e677427ca36f746ee2ec9213346ff..37b0e8455e58f2f5b56f21e5b8b260127399c6cc 100644 (file)
@@ -1241,8 +1241,8 @@ TEST(GarbageCollector, BasicTest)
     saving = gc.estimate(300, 100, em, old_extents, 4096);
     ASSERT_EQ(saving, 1);
     auto& to_collect = gc.get_extents_to_collect();
-    ASSERT_EQ(to_collect.size(), 1u);
-    ASSERT_EQ(to_collect[0], bluestore_pextent_t(100,10) );
+    ASSERT_EQ(to_collect.num_intervals(), 1u);
+    ASSERT_EQ(*to_collect.begin(), std::make_pair(100ul, 10ul));
 
     em.clear();
     old_extents.clear();
@@ -1311,11 +1311,11 @@ TEST(GarbageCollector, BasicTest)
     saving = gc.estimate(0x30000, 0xf000, em, old_extents, 0x10000);
     ASSERT_EQ(saving, 2);
     auto& to_collect = gc.get_extents_to_collect();
-    ASSERT_EQ(to_collect.size(), 2u);
-    ASSERT_TRUE(to_collect[0] == bluestore_pextent_t(0x0,0x8000) ||
-                 to_collect[1] == bluestore_pextent_t(0x0,0x8000));
-    ASSERT_TRUE(to_collect[0] == bluestore_pextent_t(0x3f000,0x1000) ||
-                 to_collect[1] == bluestore_pextent_t(0x3f000,0x1000));
+    ASSERT_EQ(to_collect.num_intervals(), 2u);
+    ASSERT_TRUE((*to_collect.begin()) == std::make_pair(0x0ul ,0x8000ul) ||
+                 *(++to_collect.begin()) == std::make_pair(0x0ul, 0x8000ul));
+    ASSERT_TRUE((*to_collect.begin()) == std::make_pair(0x3f000ul, 0x1000ul) ||
+                 *(++to_collect.begin()) == std::make_pair(0x3f000ul, 0x1000ul));
 
     em.clear();
     old_extents.clear();
@@ -1357,7 +1357,7 @@ TEST(GarbageCollector, BasicTest)
     saving = gc.estimate(0x3000, 0x4000, em, old_extents, 0x1000);
     ASSERT_EQ(saving, 0);
     auto& to_collect = gc.get_extents_to_collect();
-    ASSERT_EQ(to_collect.size(), 0u);
+    ASSERT_EQ(to_collect.num_intervals(), 0u);
     em.clear();
     old_extents.clear();
   }
@@ -1432,11 +1432,11 @@ TEST(GarbageCollector, BasicTest)
     saving = gc.estimate(0x30000, 0xf000, em, old_extents, 0x10000);
     ASSERT_EQ(saving, 2);
     auto& to_collect = gc.get_extents_to_collect();
-    ASSERT_EQ(to_collect.size(), 2u);
-    ASSERT_TRUE(to_collect[0] == bluestore_pextent_t(0x0,0x8000) ||
-                 to_collect[1] == bluestore_pextent_t(0x0,0x8000));
-    ASSERT_TRUE(to_collect[0] == bluestore_pextent_t(0x3f000,0x1000) ||
-                 to_collect[1] == bluestore_pextent_t(0x3f000,0x1000));
+    ASSERT_EQ(to_collect.num_intervals(), 2u);
+    ASSERT_TRUE(*to_collect.begin() == std::make_pair(0x0ul, 0x8000ul) ||
+                 *(++to_collect.begin()) == std::make_pair(0x0ul, 0x8000ul));
+    ASSERT_TRUE(*to_collect.begin() == std::make_pair(0x3f000ul, 0x1000ul) ||
+                 *(++to_collect.begin()) == std::make_pair(0x3f000ul, 0x1000ul));
 
     em.clear();
     old_extents.clear();