]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: templatize exclusive_lock::StandardPolicy
authorIlya Dryomov <idryomov@gmail.com>
Mon, 8 Feb 2021 15:49:35 +0000 (16:49 +0100)
committerJason Dillaman <dillaman@redhat.com>
Tue, 9 Mar 2021 21:50:00 +0000 (16:50 -0500)
This will be used by expect_set_exclusive_lock_policy() in
test_mock_PreRemoveRequest.cc.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 948f3c761dce4678b38d22e240da06434dbe10e4)

src/librbd/exclusive_lock/StandardPolicy.cc
src/librbd/exclusive_lock/StandardPolicy.h

index 227c40815f95b1a7dcfe0cebb05f39ce8825855a..519e9618ecc37aa6806a08876ce567b1619da44e 100644 (file)
@@ -12,7 +12,8 @@
 namespace librbd {
 namespace exclusive_lock {
 
-int StandardPolicy::lock_requested(bool force) {
+template <typename I>
+int StandardPolicy<I>::lock_requested(bool force) {
   ceph_assert(ceph_mutex_is_locked(m_image_ctx->owner_lock));
   ceph_assert(m_image_ctx->exclusive_lock != nullptr);
 
@@ -25,3 +26,4 @@ int StandardPolicy::lock_requested(bool force) {
 } // namespace exclusive_lock
 } // namespace librbd
 
+template class librbd::exclusive_lock::StandardPolicy<librbd::ImageCtx>;
index c756db4f94abd1ae7152190cbd3c10026746f21b..dd4e19050ce46727297f4a2f2aad0b3c95bd797d 100644 (file)
@@ -12,9 +12,10 @@ struct ImageCtx;
 
 namespace exclusive_lock {
 
+template <typename ImageCtxT = ImageCtx>
 class StandardPolicy : public Policy {
 public:
-  StandardPolicy(ImageCtx *image_ctx) : m_image_ctx(image_ctx) {
+  StandardPolicy(ImageCtxT* image_ctx) : m_image_ctx(image_ctx) {
   }
 
   bool may_auto_request_lock() override {
@@ -24,11 +25,13 @@ public:
   int lock_requested(bool force) override;
 
 private:
-  ImageCtx *m_image_ctx;
+  ImageCtxT* m_image_ctx;
 
 };
 
 } // namespace exclusive_lock
 } // namespace librbd
 
+extern template class librbd::exclusive_lock::StandardPolicy<librbd::ImageCtx>;
+
 #endif // CEPH_LIBRBD_EXCLUSIVE_LOCK_STANDARD_POLICY_H