]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/ClusterState: add with_osdmap_and_pgmap
authorSage Weil <sage@redhat.com>
Thu, 15 Nov 2018 22:26:48 +0000 (16:26 -0600)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sun, 28 Apr 2019 10:14:50 +0000 (18:14 +0800)
Several call sites need to lock both

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 60876ccce4e9de7e138dc04cfac056b29a607b4c)

Conflicts:
        - drop c++14 -> c++11 feature
        - Mutex::Locker -> std::lock_guard(948635a)

src/mgr/ClusterState.h

index 9513c763bd0ad2790a5b01e2ba810fc281f3032b..65dfd583fc243eb0af5e3f0cb5a9e0d173ece0d9 100644 (file)
@@ -129,6 +129,21 @@ public:
     return objecter->with_osdmap(std::forward<Args>(args)...);
   }
 
+  // call cb(osdmap, pg_map, ...args) with the appropriate locks
+  template <typename Callback, typename ...Args>
+  auto with_osdmap_and_pgmap(Callback&& cb, Args&& ...args) const ->
+    decltype(objecter->with_osdmap(std::forward<Callback>(cb),
+                                   pg_map,
+                                   std::forward<Args>(args)...))
+  {
+    ceph_assert(objecter != nullptr);
+    Mutex::Locker l(lock);
+    return objecter->with_osdmap(
+      std::forward<Callback>(cb),
+      pg_map,
+      std::forward<Args>(args)...);
+  }
+
 };
 
 #endif