]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: acquire proper lock in split_cache() 40323/head
authorIgor Fedotov <ifedotov@suse.com>
Fri, 19 Mar 2021 09:53:20 +0000 (12:53 +0300)
committerAdam Kupczyk <akupczyk@redhat.com>
Tue, 23 Mar 2021 09:37:05 +0000 (10:37 +0100)
Fixes: https://tracker.ceph.com/issues/49900
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/BlueStore.cc

index 072d0c2aba5dbea00e2988d531d36bb5dc0425f4..aa864e3789a9aa25456240fa8d5eb569b1a7b04b 100644 (file)
@@ -4004,10 +4004,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;