]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: acquire proper lock in split_cache() 40441/head
authorIgor Fedotov <ifedotov@suse.com>
Fri, 19 Mar 2021 09:53:20 +0000 (12:53 +0300)
committerNeha Ojha <nojha@redhat.com>
Fri, 26 Mar 2021 15:57:13 +0000 (15:57 +0000)
Fixes: https://tracker.ceph.com/issues/49900
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit 35a3f7be8f2f204ad3b5e720d0534ca3e2a8587c)

src/os/bluestore/BlueStore.cc

index 3dab8041fbe8e712003c1b3be9ea955b9cf64140..5a723876165fe0c613c59dce8cde4ce518b75bf6 100644 (file)
@@ -4028,10 +4028,15 @@ void BlueStore::Collection::split_cache(
 {
   ldout(store->cct, 10) << __func__ << " to " << dest << dendl;
 
-  // lock (one or both) cache shards
-  std::lock(cache->lock, dest->cache->lock);
-  std::lock_guard l(cache->lock, std::adopt_lock);
-  std::lock_guard l2(dest->cache->lock, std::adopt_lock);
+  auto *ocache = get_onode_cache();
+  auto *ocache_dest = dest->get_onode_cache();
+
+ // lock cache shards
+  std::lock(ocache->lock, ocache_dest->lock, cache->lock, dest->cache->lock);
+  std::lock_guard l(ocache->lock, std::adopt_lock);
+  std::lock_guard l2(ocache_dest->lock, std::adopt_lock);
+  std::lock_guard l3(cache->lock, std::adopt_lock);
+  std::lock_guard l4(dest->cache->lock, std::adopt_lock);
 
   int destbits = dest->cnode.bits;
   spg_t destpg;