From 54270aa09af1ffc87f78a73dcb469621598440da Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Fri, 19 Mar 2021 12:53:20 +0300 Subject: [PATCH] os/bluestore: acquire proper lock in split_cache() Fixes: https://tracker.ceph.com/issues/49900 Signed-off-by: Igor Fedotov (cherry picked from commit 35a3f7be8f2f204ad3b5e720d0534ca3e2a8587c) --- src/os/bluestore/BlueStore.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 3f4377463ff..67c2e9bf6c1 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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; -- 2.47.3