]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Add lock in ExtentMap::dup
authorAdam Kupczyk <akupczyk@ibm.com>
Thu, 25 May 2023 19:20:51 +0000 (19:20 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Thu, 25 May 2023 19:20:51 +0000 (19:20 +0000)
_dup_writing requires locking of BufferCacheShard

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/os/bluestore/BlueStore.cc

index 0378dbf555f06c68f0529ebc5e8c19b9abe8db0c..060b6e2f3f06d5601279eb7ffe5f48c38ce0f836 100644 (file)
@@ -2551,6 +2551,16 @@ void BlueStore::ExtentMap::dump(Formatter* f) const
 void BlueStore::ExtentMap::dup(BlueStore* b, TransContext* txc,
   CollectionRef& c, OnodeRef& oldo, OnodeRef& newo, uint64_t& srcoff,
   uint64_t& length, uint64_t& dstoff) {
+  //_dup_writing needs cache lock
+  BufferCacheShard* coll_cache;
+  do {
+    coll_cache = c->cache;
+    coll_cache->lock.lock();
+    if (coll_cache == c->cache) {
+      break;
+    }
+    coll_cache->lock.unlock();
+  } while (true);
 
   auto cct = onode->c->store->cct;
   bool inject_21040 =
@@ -2662,6 +2672,8 @@ void BlueStore::ExtentMap::dup(BlueStore* b, TransContext* txc,
     newo->onode.size = dstoff + length;
   }
   newo->extent_map.dirty_range(dstoff, length);
+  //_dup_writing needs cache lock
+  coll_cache->lock.unlock();
 }
 void BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
                                   bool force)