]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: onode::finish_write
authorPere Diaz Bou <pere-altea@hotmail.com>
Tue, 2 Apr 2024 14:57:52 +0000 (16:57 +0200)
committerPere Diaz Bou <pere-altea@hotmail.com>
Thu, 25 Apr 2024 13:56:20 +0000 (15:56 +0200)
Use same finish_write->_finish_write tandem from blob->bufferspace now
with onode->bufferspace instead of a single finish_write function.

Signed-off-by: Pere Diaz Bou <pere-altea@hotmail.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index a6d503e037bf21155512a3f47ad8b607c07939a0..b26ea8c51724484bae9b93273888e1f27d34a039 100644 (file)
@@ -1810,50 +1810,37 @@ void BlueStore::BufferSpace::read(
   cache->logger->inc(l_bluestore_buffer_miss_bytes, miss_bytes);
 }
 
-void BlueStore::BufferSpace::_finish_write(OnodeRef onode, uint64_t seq)
+void BlueStore::BufferSpace::_finish_write(BufferCacheShard* cache,  uint64_t seq)
 {
-  while (true) {
-    BufferCacheShard *cache = onode->c->cache;
-    std::lock_guard l(cache->lock);
-    if (cache != onode->c->cache) {
-      ldout(cache->cct, 20) << __func__
-              << " raced with sb cache update, was " << cache
-              << ", now " << onode->c->cache << ", retrying"
-              << dendl;
+  ldout(cache->cct, 20) << __func__ << " seq=" << seq << dendl;
+  auto i = writing.begin();
+  while (i != writing.end()) {
+    if (i->seq > seq) {
+      break;
+    }
+    if (i->seq < seq) {
+      ++i;
       continue;
     }
-    ldout(cache->cct, 20) << __func__ << " seq=" << seq << dendl;
-    auto i = writing.begin();
-    while (i != writing.end()) {
-      if (i->seq > seq) {
-        break;
-      }
-      if (i->seq < seq) {
-        ++i;
-        continue;
-      }
 
-      Buffer *b = &*i;
-      ceph_assert(b->is_writing());
+    Buffer *b = &*i;
+    ceph_assert(b->is_writing());
 
-      if (b->flags & Buffer::FLAG_NOCACHE) {
-        writing.erase(i++);
-        ldout(cache->cct, 20) << __func__ << " discard " << *b << dendl;
-        buffer_map.erase(b->offset);
-      } else {
-        b->state = Buffer::STATE_CLEAN;
-        writing.erase(i++);
-        b->maybe_rebuild();
-        b->data.reassign_to_mempool(mempool::mempool_bluestore_cache_data);
-        cache->_add(b, 1, nullptr);
-        ldout(cache->cct, 20) << __func__ << " added " << *b << dendl;
-      }
+    if (b->flags & Buffer::FLAG_NOCACHE) {
+      writing.erase(i++);
+      ldout(cache->cct, 20) << __func__ << " discard " << *b << dendl;
+      buffer_map.erase(b->offset);
+    } else {
+      b->state = Buffer::STATE_CLEAN;
+      writing.erase(i++);
+      b->maybe_rebuild();
+      b->data.reassign_to_mempool(mempool::mempool_bluestore_cache_data);
+      cache->_add(b, 1, nullptr);
+      ldout(cache->cct, 20) << __func__ << " added " << *b << dendl;
     }
-    cache->_trim();
-    cache->_audit("finish_write end");
-
-    break;
   }
+  cache->_trim();
+  cache->_audit("finish_write end");
 }
 
 /*
@@ -4763,6 +4750,23 @@ void BlueStore::Onode::decode_omap_key(const string& key, string *user_key)
   *user_key = key.substr(pos);
 }
 
+void BlueStore::Onode::finish_write(uint64_t seq)
+{
+  while (true) {
+    BufferCacheShard *cache = c->cache;
+    std::lock_guard l(cache->lock);
+    if (cache != c->cache) {
+      ldout(cache->cct, 20) << __func__
+              << " raced with sb cache update, was " << cache
+              << ", now " << c->cache << ", retrying"
+              << dendl;
+      continue;
+    }
+    bc._finish_write(cache, seq);
+    break;
+  }
+}
+
 // =======================================================
 // WriteContext
  
@@ -13786,10 +13790,10 @@ void BlueStore::_txc_finish(TransContext *txc)
 
       }
       for (auto &dependent_onode : dependent_onodes) {
-        dependent_onode->bc._finish_write(dependent_onode, seq);
+        dependent_onode->finish_write(seq);
       }
     }
-    onode->bc._finish_write(onode, seq);
+    onode->finish_write(seq);
   }
   txc->buffers_written.clear();
 
@@ -18147,7 +18151,7 @@ void BlueStore::_shutdown_cache()
     std::unique_lock l(p.second->lock);
     for (auto &[seq, onodes] : p.second->deferred_seq_dependencies) {
       for (auto &onode : onodes) {
-        onode->bc._finish_write(onode, seq);
+        onode->finish_write(seq);
       }
     }
     p.second->deferred_seq_dependencies.clear();
index 21cf2fb395d907b71899e51983d418291e485296..91c5cc6177aee5b56271bfd02cfd01c649b8a17e 100644 (file)
@@ -499,7 +499,7 @@ public:
                   nullptr);
       cache->_trim();
     }
-    void _finish_write(OnodeRef onode, uint64_t seq);
+    void _finish_write(BufferCacheShard* cache, uint64_t seq);
     void did_read(BufferCacheShard* cache, uint32_t offset, ceph::buffer::list&& bl) {
       std::lock_guard l(cache->lock);
       uint16_t cache_private = _discard(cache, offset, bl.length());
@@ -1439,6 +1439,8 @@ public:
     void rewrite_omap_key(const std::string& old, std::string *out);
     void decode_omap_key(const std::string& key, std::string *user_key);
 
+    void finish_write(uint64_t seq);
+
 private:
     void _decode(const ceph::buffer::list& v);
   };