From: Sage Weil Date: Thu, 15 Nov 2018 22:26:48 +0000 (-0600) Subject: mgr/ClusterState: add with_osdmap_and_pgmap X-Git-Tag: v12.2.13~169^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f8f52cdb619847513e142911e3a2d17cf2415faa;p=ceph.git mgr/ClusterState: add with_osdmap_and_pgmap Several call sites need to lock both Signed-off-by: Sage Weil (cherry picked from commit 60876ccce4e9de7e138dc04cfac056b29a607b4c) Conflicts: - drop c++14 -> c++11 feature - Mutex::Locker -> std::lock_guard(948635a) --- diff --git a/src/mgr/ClusterState.h b/src/mgr/ClusterState.h index 9513c763bd0..65dfd583fc2 100644 --- a/src/mgr/ClusterState.h +++ b/src/mgr/ClusterState.h @@ -129,6 +129,21 @@ 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 -> + decltype(objecter->with_osdmap(std::forward(cb), + pg_map, + std::forward(args)...)) + { + ceph_assert(objecter != nullptr); + Mutex::Locker l(lock); + return objecter->with_osdmap( + std::forward(cb), + pg_map, + std::forward(args)...); + } + }; #endif