From 60876ccce4e9de7e138dc04cfac056b29a607b4c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 15 Nov 2018 16:26:48 -0600 Subject: [PATCH] mgr/ClusterState: add with_osdmap_and_pgmap Several call sites need to lock both Signed-off-by: Sage Weil --- src/mgr/ClusterState.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mgr/ClusterState.h b/src/mgr/ClusterState.h index 69fc92bfd02..c5d46fa1abf 100644 --- a/src/mgr/ClusterState.h +++ b/src/mgr/ClusterState.h @@ -127,6 +127,17 @@ public: return objecter->with_osdmap(std::forward(args)...); } + // call cb(osdmap, pg_map, ...args) with the appropriate locks + template + auto with_osdmap_and_pgmap(Callback&& cb, Args&& ...args) const { + ceph_assert(objecter != nullptr); + std::lock_guard l(lock); + return objecter->with_osdmap( + std::forward(cb), + pg_map, + std::forward(args)...); + } + }; #endif -- 2.39.5