]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: removed ManagedLock dependency from ancillary classes
authorJason Dillaman <dillaman@redhat.com>
Tue, 17 Jan 2017 18:42:43 +0000 (13:42 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 18 Jan 2017 21:44:43 +0000 (16:44 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
18 files changed:
src/librbd/CMakeLists.txt
src/librbd/ManagedLock.cc
src/librbd/ManagedLock.h
src/librbd/exclusive_lock/PostAcquireRequest.cc
src/librbd/exclusive_lock/PostAcquireRequest.h
src/librbd/exclusive_lock/PreReleaseRequest.cc
src/librbd/exclusive_lock/PreReleaseRequest.h
src/librbd/managed_lock/AcquireRequest.cc
src/librbd/managed_lock/GetLockerRequest.cc
src/librbd/managed_lock/ReacquireRequest.cc
src/librbd/managed_lock/Utils.cc [new file with mode: 0644]
src/librbd/managed_lock/Utils.h [new file with mode: 0644]
src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc
src/test/librbd/managed_lock/test_mock_AcquireRequest.cc
src/test/librbd/managed_lock/test_mock_BreakRequest.cc
src/test/librbd/managed_lock/test_mock_GetLockerRequest.cc
src/test/librbd/managed_lock/test_mock_ReacquireRequest.cc
src/test/librbd/managed_lock/test_mock_ReleaseRequest.cc

index 0b224ce15dff9a37399c2e9c3f4d9581f4d21269..e1739aa54af90801c19f6ebe2dd5e71d1f6f8fb8 100644 (file)
@@ -37,6 +37,7 @@ set(librbd_internal_srcs
   managed_lock/GetLockerRequest.cc
   managed_lock/ReleaseRequest.cc
   managed_lock/ReacquireRequest.cc
+  managed_lock/Utils.cc
   exclusive_lock/AutomaticPolicy.cc
   exclusive_lock/PreAcquireRequest.cc
   exclusive_lock/PostAcquireRequest.cc
index 18f33e184ab6ad870d428575247168e3b607edb3..67504a9b3eceb92796dfd03f2bc82403f1c3bb0a 100644 (file)
@@ -8,6 +8,7 @@
 #include "librbd/managed_lock/ReleaseRequest.h"
 #include "librbd/managed_lock/ReacquireRequest.h"
 #include "librbd/managed_lock/Types.h"
+#include "librbd/managed_lock/Utils.h"
 #include "librbd/Watcher.h"
 #include "librbd/ImageCtx.h"
 #include "cls/lock/cls_lock_client.h"
@@ -15,7 +16,6 @@
 #include "common/errno.h"
 #include "common/WorkQueue.h"
 #include "librbd/Utils.h"
-#include <sstream>
 
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
@@ -28,8 +28,6 @@ using namespace managed_lock;
 
 namespace {
 
-const std::string WATCHER_LOCK_COOKIE_PREFIX = "auto";
-
 template <typename R>
 struct C_SendLockRequest : public Context {
   R* request;
@@ -42,15 +40,17 @@ struct C_SendLockRequest : public Context {
 
 } // anonymous namespace
 
-template <typename I>
-const std::string ManagedLock<I>::WATCHER_LOCK_TAG("internal");
+using librbd::util::create_context_callback;
+using librbd::util::unique_lock_name;
+using managed_lock::util::decode_lock_cookie;
+using managed_lock::util::encode_lock_cookie;
 
 template <typename I>
 ManagedLock<I>::ManagedLock(librados::IoCtx &ioctx, ContextWQ *work_queue,
                             const string& oid, Watcher *watcher, Mode mode,
                             bool blacklist_on_break_lock,
                             uint32_t blacklist_expire_seconds)
-  : m_lock(util::unique_lock_name("librbd::ManagedLock<I>::m_lock", this)),
+  : m_lock(unique_lock_name("librbd::ManagedLock<I>::m_lock", this)),
     m_state(STATE_UNLOCKED),
     m_ioctx(ioctx), m_cct(reinterpret_cast<CephContext *>(ioctx.cct())),
     m_work_queue(work_queue),
@@ -253,25 +253,6 @@ void  ManagedLock<I>::post_release_lock_handler(bool shutting_down, int r,
   on_finish->complete(r);
 }
 
-template <typename I>
-bool ManagedLock<I>::decode_lock_cookie(const std::string &tag,
-                                        uint64_t *handle) {
-  std::string prefix;
-  std::istringstream ss(tag);
-  if (!(ss >> prefix >> *handle) || prefix != WATCHER_LOCK_COOKIE_PREFIX) {
-    return false;
-  }
-  return true;
-}
-
-template <typename I>
-string ManagedLock<I>::encode_lock_cookie(uint64_t watch_handle) {
-  assert(watch_handle != 0);
-  std::ostringstream ss;
-  ss << WATCHER_LOCK_COOKIE_PREFIX << " " << watch_handle;
-  return ss.str();
-}
-
 template <typename I>
 bool ManagedLock<I>::is_transition_state() const {
   switch (m_state) {
@@ -402,10 +383,10 @@ void ManagedLock<I>::send_acquire_lock() {
     m_state = STATE_WAITING_FOR_REGISTER;
     return;
   }
-  m_cookie = ManagedLock<I>::encode_lock_cookie(watch_handle);
+  m_cookie = encode_lock_cookie(watch_handle);
 
   m_work_queue->queue(new FunctionContext([this](int r) {
-    pre_acquire_lock_handler(util::create_context_callback<
+    pre_acquire_lock_handler(create_context_callback<
         ManagedLock<I>, &ManagedLock<I>::handle_pre_acquire_lock>(this));
   }));
 }
@@ -423,7 +404,7 @@ void ManagedLock<I>::handle_pre_acquire_lock(int r) {
   AcquireRequest<I>* req = AcquireRequest<I>::create(
     m_ioctx, m_watcher, m_work_queue, m_oid, m_cookie, m_mode == EXCLUSIVE,
     m_blacklist_on_break_lock, m_blacklist_expire_seconds,
-    util::create_context_callback<
+    create_context_callback<
         ManagedLock<I>, &ManagedLock<I>::handle_acquire_lock>(this));
   m_work_queue->queue(new C_SendLockRequest<AcquireRequest<I>>(req), 0);
 }
@@ -444,7 +425,7 @@ void ManagedLock<I>::handle_acquire_lock(int r) {
   m_post_next_state = (r < 0 ? STATE_UNLOCKED : STATE_LOCKED);
 
   m_work_queue->queue(new FunctionContext([this, r](int ret) {
-    post_acquire_lock_handler(r, util::create_context_callback<
+    post_acquire_lock_handler(r, create_context_callback<
         ManagedLock<I>, &ManagedLock<I>::handle_post_acquire_lock>(this));
   }));
 }
@@ -496,7 +477,7 @@ void ManagedLock<I>::send_reacquire_lock() {
      return;
   }
 
-  m_new_cookie = ManagedLock<I>::encode_lock_cookie(watch_handle);
+  m_new_cookie = encode_lock_cookie(watch_handle);
   if (m_cookie == m_new_cookie) {
     ldout(m_cct, 10) << ": skipping reacquire since cookie still valid"
                      << dendl;
@@ -510,7 +491,7 @@ void ManagedLock<I>::send_reacquire_lock() {
   using managed_lock::ReacquireRequest;
   ReacquireRequest<I>* req = ReacquireRequest<I>::create(m_ioctx, m_oid,
       m_cookie, m_new_cookie, m_mode == EXCLUSIVE,
-      util::create_context_callback<
+      create_context_callback<
         ManagedLock, &ManagedLock<I>::handle_reacquire_lock>(this));
   m_work_queue->queue(new C_SendLockRequest<ReacquireRequest<I>>(req));
 }
@@ -574,7 +555,7 @@ void ManagedLock<I>::send_release_lock() {
   m_state = STATE_PRE_RELEASING;
 
   m_work_queue->queue(new FunctionContext([this](int r) {
-    pre_release_lock_handler(false, util::create_context_callback<
+    pre_release_lock_handler(false, create_context_callback<
         ManagedLock<I>, &ManagedLock<I>::handle_pre_release_lock>(this));
   }));
 }
@@ -591,7 +572,7 @@ void ManagedLock<I>::handle_pre_release_lock(int r) {
   using managed_lock::ReleaseRequest;
   ReleaseRequest<I>* req = ReleaseRequest<I>::create(m_ioctx, m_watcher,
       m_work_queue, m_oid, m_cookie,
-      util::create_context_callback<
+      create_context_callback<
         ManagedLock<I>, &ManagedLock<I>::handle_release_lock>(this));
   m_work_queue->queue(new C_SendLockRequest<ReleaseRequest<I>>(req), 0);
 }
@@ -610,7 +591,7 @@ void ManagedLock<I>::handle_release_lock(int r) {
   m_post_next_state = r < 0 ? STATE_LOCKED : STATE_UNLOCKED;
 
   m_work_queue->queue(new FunctionContext([this, r](int ret) {
-    post_release_lock_handler(false, r, util::create_context_callback<
+    post_release_lock_handler(false, r, create_context_callback<
         ManagedLock<I>, &ManagedLock<I>::handle_post_release_lock>(this));
   }));
 }
@@ -630,7 +611,7 @@ void ManagedLock<I>::send_shutdown() {
   if (m_state == STATE_UNLOCKED) {
     m_state = STATE_SHUTTING_DOWN;
     m_work_queue->queue(new FunctionContext([this](int r) {
-      shutdown_handler(r, util::create_context_callback<
+      shutdown_handler(r, create_context_callback<
           ManagedLock<I>, &ManagedLock<I>::handle_shutdown>(this));
     }));
     return;
@@ -659,7 +640,7 @@ void ManagedLock<I>::send_shutdown_release() {
   Mutex::Locker locker(m_lock);
 
   m_work_queue->queue(new FunctionContext([this](int r) {
-    pre_release_lock_handler(true, util::create_context_callback<
+    pre_release_lock_handler(true, create_context_callback<
         ManagedLock<I>, &ManagedLock<I>::handle_shutdown_pre_release>(this));
   }));
 }
@@ -678,7 +659,7 @@ void ManagedLock<I>::handle_shutdown_pre_release(int r) {
   ReleaseRequest<I>* req = ReleaseRequest<I>::create(m_ioctx, m_watcher,
       m_work_queue, m_oid, cookie,
       new FunctionContext([this](int r) {
-        post_release_lock_handler(true, r, util::create_context_callback<
+        post_release_lock_handler(true, r, create_context_callback<
             ManagedLock<I>, &ManagedLock<I>::handle_shutdown_post_release>(this));
       }));
   req->send();
index 45f06b4978e25e00451c956dbc6bae04b91140a0..baa28fdd4dccc3088eae9f8069acb0c3932c42b8 100644 (file)
@@ -30,8 +30,6 @@ private:
   typedef typename TypeTraits::Watcher Watcher;
 
 public:
-  static const std::string WATCHER_LOCK_TAG;
-
   static ManagedLock *create(librados::IoCtx& ioctx, ContextWQ *work_queue,
                              const std::string& oid, Watcher *watcher,
                              managed_lock::Mode mode,
@@ -67,8 +65,6 @@ public:
     return m_state == STATE_LOCKED;
   }
 
-  static bool decode_lock_cookie(const std::string &tag, uint64_t *handle);
-
 protected:
 
   /**
@@ -174,8 +170,6 @@ private:
 
   ActionsContexts m_actions_contexts;
 
-  static std::string encode_lock_cookie(uint64_t watch_handle);
-
   bool is_lock_owner(Mutex &lock) const;
   bool is_transition_state() const;
 
index 0ac4056bb8164c10480e53d1e9ef04c7e24acc79..3e262e792910cf9696cfba6670124d26842fe469 100644 (file)
@@ -9,7 +9,6 @@
 #include "common/WorkQueue.h"
 #include "include/stringify.h"
 #include "librbd/ExclusiveLock.h"
-#include "librbd/ManagedLock.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/ImageState.h"
 #include "librbd/ImageWatcher.h"
index 92d2da9abcdf37adc0ca39d3f7384e01927a8364..06fdce394bcf1fefcccfd42fe34b17e680fd0988 100644 (file)
@@ -14,9 +14,6 @@ class Context;
 
 namespace librbd {
 
-template <typename> class Journal;
-template <typename> class ManagedLock;
-
 namespace exclusive_lock {
 
 template <typename ImageCtxT = ImageCtx>
index 7fecb8180492c56565a4ce4eceedb5deaab78364..5096ed8189c14b0f7126ba562995ce327a214899 100644 (file)
@@ -6,7 +6,6 @@
 #include "common/errno.h"
 #include "librbd/AioImageRequestWQ.h"
 #include "librbd/ExclusiveLock.h"
-#include "librbd/ManagedLock.h"
 #include "librbd/ImageState.h"
 #include "librbd/ImageWatcher.h"
 #include "librbd/Journal.h"
index 15f40b92254541aa651a8ec43a3da1514fb23a0d..0fda36a091ad868057bffd95a2096f96f82d7652 100644 (file)
@@ -12,8 +12,6 @@ class Context;
 namespace librbd {
 
 struct ImageCtx;
-template <typename> class ManagedLock;
-template <typename> class Journal;
 
 namespace exclusive_lock {
 
index d40b0c0dbfa56b9c3af1293936e088cc6c5f3424..b89f658275f4e6ca07be1c8d87583192c7399b3d 100644 (file)
@@ -3,18 +3,17 @@
 
 #include "librbd/managed_lock/AcquireRequest.h"
 #include "librbd/Watcher.h"
-#include "librbd/ManagedLock.h"
 #include "cls/lock/cls_lock_client.h"
 #include "cls/lock/cls_lock_types.h"
 #include "common/dout.h"
 #include "common/errno.h"
 #include "common/WorkQueue.h"
 #include "include/stringify.h"
+#include "librbd/ImageCtx.h"
 #include "librbd/Utils.h"
 #include "librbd/managed_lock/BreakRequest.h"
 #include "librbd/managed_lock/GetLockerRequest.h"
-
-#include "librbd/ImageCtx.h"
+#include "librbd/managed_lock/Utils.h"
 
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
@@ -25,10 +24,10 @@ using std::string;
 
 namespace librbd {
 
-using util::detail::C_AsyncCallback;
-using util::create_context_callback;
-using util::create_rados_safe_callback;
-using util::create_rados_ack_callback;
+using librbd::util::detail::C_AsyncCallback;
+using librbd::util::create_context_callback;
+using librbd::util::create_rados_safe_callback;
+using librbd::util::create_rados_ack_callback;
 
 namespace managed_lock {
 
@@ -110,7 +109,7 @@ void AcquireRequest<I>::send_lock() {
   librados::ObjectWriteOperation op;
   rados::cls::lock::lock(&op, RBD_LOCK_NAME,
                          m_exclusive ? LOCK_EXCLUSIVE : LOCK_SHARED, m_cookie,
-                         ManagedLock<I>::WATCHER_LOCK_TAG, "", utime_t(), 0);
+                         util::get_watcher_lock_tag(), "", utime_t(), 0);
 
   using klass = AcquireRequest;
   librados::AioCompletion *rados_completion =
index 9f93d305c04d641ac033b67436405bf812562c4d..2a37d95505fdfcfc35bfd0b9430b50cae6447260 100644 (file)
@@ -8,9 +8,9 @@
 #include "common/errno.h"
 #include "include/stringify.h"
 #include "librbd/ImageCtx.h"
-#include "librbd/ManagedLock.h"
 #include "librbd/Utils.h"
 #include "librbd/managed_lock/Types.h"
+#include "librbd/managed_lock/Utils.h"
 
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
@@ -20,7 +20,7 @@
 namespace librbd {
 namespace managed_lock {
 
-using util::create_rados_ack_callback;
+using librbd::util::create_rados_ack_callback;
 
 template <typename I>
 GetLockerRequest<I>::GetLockerRequest(librados::IoCtx& ioctx,
@@ -78,7 +78,7 @@ void GetLockerRequest<I>::handle_get_lockers(int r) {
     return;
   }
 
-  if (lock_tag != ManagedLock<>::WATCHER_LOCK_TAG) {
+  if (lock_tag != util::get_watcher_lock_tag()) {
     ldout(m_cct, 5) <<"locked by external mechanism: tag=" << lock_tag << dendl;
     finish(-EBUSY);
     return;
@@ -96,8 +96,7 @@ void GetLockerRequest<I>::handle_get_lockers(int r) {
 
   std::map<rados::cls::lock::locker_id_t,
            rados::cls::lock::locker_info_t>::iterator iter = lockers.begin();
-  if (!ManagedLock<>::decode_lock_cookie(iter->first.cookie,
-                                         &m_locker->handle)) {
+  if (!util::decode_lock_cookie(iter->first.cookie, &m_locker->handle)) {
     ldout(m_cct, 5) << "locked by external mechanism: "
                    << "cookie=" << iter->first.cookie << dendl;
     finish(-EBUSY);
index 02c564d7ff4bb15ae4da31c43fdee30165444408..83c39d85521d5b03868ceae9b068812421bd6051 100644 (file)
@@ -3,14 +3,13 @@
 
 #include "librbd/managed_lock/ReacquireRequest.h"
 #include "librbd/Watcher.h"
-#include "librbd/ManagedLock.h"
 #include "cls/lock/cls_lock_client.h"
 #include "cls/lock/cls_lock_types.h"
 #include "common/dout.h"
 #include "common/errno.h"
-#include "librbd/Utils.h"
-
 #include "librbd/ImageCtx.h"
+#include "librbd/Utils.h"
+#include "librbd/managed_lock/Utils.h"
 
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
@@ -49,7 +48,7 @@ void ReacquireRequest<I>::set_cookie() {
   librados::ObjectWriteOperation op;
   rados::cls::lock::set_cookie(&op, RBD_LOCK_NAME,
                                m_exclusive ? LOCK_EXCLUSIVE : LOCK_SHARED,
-                               m_old_cookie, ManagedLock<I>::WATCHER_LOCK_TAG,
+                               m_old_cookie, util::get_watcher_lock_tag(),
                                m_new_cookie);
 
   librados::AioCompletion *rados_completion = create_rados_safe_callback<
diff --git a/src/librbd/managed_lock/Utils.cc b/src/librbd/managed_lock/Utils.cc
new file mode 100644 (file)
index 0000000..64210be
--- /dev/null
@@ -0,0 +1,43 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "include/assert.h"
+#include "librbd/managed_lock/Utils.h"
+#include <sstream>
+
+namespace librbd {
+namespace managed_lock {
+namespace util {
+
+namespace {
+
+const std::string WATCHER_LOCK_COOKIE_PREFIX = "auto";
+const std::string WATCHER_LOCK_TAG("internal");
+
+} // anonymous namespace
+
+const std::string &get_watcher_lock_tag() {
+  return WATCHER_LOCK_TAG;
+}
+
+bool decode_lock_cookie(const std::string &tag, uint64_t *handle) {
+  std::string prefix;
+  std::istringstream ss(tag);
+  if (!(ss >> prefix >> *handle) || prefix != WATCHER_LOCK_COOKIE_PREFIX) {
+    return false;
+  }
+  return true;
+}
+
+std::string encode_lock_cookie(uint64_t watch_handle) {
+  assert(watch_handle != 0);
+  std::ostringstream ss;
+  ss << WATCHER_LOCK_COOKIE_PREFIX << " " << watch_handle;
+  return ss.str();
+}
+
+} // namespace util
+} // namespace managed_lock
+} // namespace librbd
+
+
diff --git a/src/librbd/managed_lock/Utils.h b/src/librbd/managed_lock/Utils.h
new file mode 100644 (file)
index 0000000..679cbfe
--- /dev/null
@@ -0,0 +1,23 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_LIBRBD_MANAGED_LOCK_UTILS_H
+#define CEPH_LIBRBD_MANAGED_LOCK_UTILS_H
+
+#include "include/int_types.h"
+#include <string>
+
+namespace librbd {
+namespace managed_lock {
+namespace util {
+
+const std::string &get_watcher_lock_tag();
+
+bool decode_lock_cookie(const std::string &tag, uint64_t *handle);
+std::string encode_lock_cookie(uint64_t watch_handle);
+
+} // namespace util
+} // namespace managed_lock
+} // namespace librbd
+
+#endif // CEPH_LIBRBD_MANAGED_LOCK_UTILS_H
index 45943aebcdc6fa777e73d17ac22dde0e0d28db12..b94ab914042eb10fc2444014d489db79d9e6873c 100644 (file)
@@ -18,8 +18,6 @@ template class librbd::exclusive_lock::PreReleaseRequest<librbd::MockImageCtx>;
 
 namespace librbd {
 
-using librbd::ManagedLock;
-
 namespace exclusive_lock {
 
 namespace {
index 5ea9ada6a04bc934c13197a11578e9279e91f1c1..4860b0385cb9ece0cca80027287dfac80c597eef 100644 (file)
@@ -81,9 +81,6 @@ GetLockerRequest<librbd::MockImageCtx> *GetLockerRequest<librbd::MockImageCtx>::
 #include "librbd/managed_lock/AcquireRequest.cc"
 template class librbd::managed_lock::AcquireRequest<librbd::MockImageCtx>;
 
-#include "librbd/ManagedLock.cc"
-template class librbd::ManagedLock<librbd::MockImageCtx>;
-
 namespace {
 
 MATCHER_P(IsLockType, exclusive, "") {
@@ -116,7 +113,6 @@ public:
   typedef AcquireRequest<MockImageCtx> MockAcquireRequest;
   typedef BreakRequest<MockImageCtx> MockBreakRequest;
   typedef GetLockerRequest<MockImageCtx> MockGetLockerRequest;
-  typedef ManagedLock<MockImageCtx> MockManagedLock;
 
   void expect_lock(MockImageCtx &mock_image_ctx, int r,
                              bool exclusive = true) {
index df6b04e5d485180e55afcb7817a4caa581500129..947ea1f731df58ca42c46b847c65d72546cc6f93 100644 (file)
@@ -7,7 +7,6 @@
 #include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
 #include "test/librados_test_stub/MockTestMemRadosClient.h"
 #include "cls/lock/cls_lock_ops.h"
-#include "librbd/ManagedLock.h"
 #include "librbd/managed_lock/BreakRequest.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
index e8b1ec76d3df8b7872b2459d3861cbe572d9caec..c339427106fb4f246dc67da6960279652a674303 100644 (file)
@@ -7,9 +7,9 @@
 #include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
 #include "test/librados_test_stub/MockTestMemRadosClient.h"
 #include "cls/lock/cls_lock_ops.h"
-#include "librbd/ManagedLock.h"
 #include "librbd/managed_lock/GetLockerRequest.h"
 #include "librbd/managed_lock/Types.h"
+#include "librbd/managed_lock/Utils.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include <arpa/inet.h>
@@ -89,7 +89,7 @@ TEST_F(TestMockManagedLockGetLockerRequest, SuccessExclusive) {
 
   InSequence seq;
   expect_get_lock_info(mock_image_ctx, 0, entity_name_t::CLIENT(1), "1.2.3.4",
-                       "auto 123", ManagedLock<>::WATCHER_LOCK_TAG,
+                       "auto 123", util::get_watcher_lock_tag(),
                        LOCK_EXCLUSIVE);
 
   C_SaferCond ctx;
@@ -116,7 +116,7 @@ TEST_F(TestMockManagedLockGetLockerRequest, SuccessShared) {
 
   InSequence seq;
   expect_get_lock_info(mock_image_ctx, 0, entity_name_t::CLIENT(1), "1.2.3.4",
-                       "auto 123", ManagedLock<>::WATCHER_LOCK_TAG,
+                       "auto 123", util::get_watcher_lock_tag(),
                        LOCK_SHARED);
 
   C_SaferCond ctx;
@@ -206,7 +206,7 @@ TEST_F(TestMockManagedLockGetLockerRequest, GetLockInfoIncompatibleShared) {
 
   InSequence seq;
   expect_get_lock_info(mock_image_ctx, 0, entity_name_t::CLIENT(1), "1.2.3.4",
-                       "auto 123", ManagedLock<>::WATCHER_LOCK_TAG,
+                       "auto 123", util::get_watcher_lock_tag(),
                        LOCK_SHARED);
 
   C_SaferCond ctx;
@@ -228,7 +228,7 @@ TEST_F(TestMockManagedLockGetLockerRequest, GetLockInfoIncompatibleExclusive) {
 
   InSequence seq;
   expect_get_lock_info(mock_image_ctx, 0, entity_name_t::CLIENT(1), "1.2.3.4",
-                       "auto 123", ManagedLock<>::WATCHER_LOCK_TAG,
+                       "auto 123", util::get_watcher_lock_tag(),
                        LOCK_EXCLUSIVE);
 
   C_SaferCond ctx;
@@ -250,7 +250,7 @@ TEST_F(TestMockManagedLockGetLockerRequest, GetLockInfoExternalCookie) {
 
   InSequence seq;
   expect_get_lock_info(mock_image_ctx, 0, entity_name_t::CLIENT(1), "1.2.3.4",
-                       "external cookie", ManagedLock<>::WATCHER_LOCK_TAG,
+                       "external cookie", util::get_watcher_lock_tag(),
                        LOCK_EXCLUSIVE);
 
   C_SaferCond ctx;
index 103078d252687b889a9f916c6ab7a0eb2c1caff2..76bac7d1474f86f4dbc3997a676565595a84ca25 100644 (file)
@@ -16,9 +16,6 @@
 #include "librbd/managed_lock/ReacquireRequest.cc"
 template class librbd::managed_lock::ReacquireRequest<librbd::MockImageCtx>;
 
-#include "librbd/ManagedLock.cc"
-template class librbd::ManagedLock<librbd::MockImageCtx>;
-
 namespace {
 
 MATCHER_P(IsLockType, exclusive, "") {
@@ -44,7 +41,6 @@ using ::testing::StrEq;
 class TestMockManagedLockReacquireRequest : public TestMockFixture {
 public:
   typedef ReacquireRequest<MockImageCtx> MockReacquireRequest;
-  typedef ManagedLock<MockImageCtx> MockManagedLock;
 
   void expect_set_cookie(MockImageCtx &mock_image_ctx, int r,
                          bool exclusive = true) {
index 5d94f90ee07be712f5961c202001c78c6f8c976a..af75f8f296365f1f52ebe41c065b765d15bf9557 100644 (file)
@@ -23,9 +23,6 @@ struct Traits<MockImageCtx> {
 #include "librbd/managed_lock/ReleaseRequest.cc"
 template class librbd::managed_lock::ReleaseRequest<librbd::MockImageCtx>;
 
-#include "librbd/ManagedLock.cc"
-template class librbd::ManagedLock<librbd::MockImageCtx>;
-
 namespace librbd {
 namespace managed_lock {
 
@@ -40,7 +37,6 @@ static const std::string TEST_COOKIE("auto 123");
 class TestMockManagedLockReleaseRequest : public TestMockFixture {
 public:
   typedef ReleaseRequest<MockImageCtx> MockReleaseRequest;
-  typedef ManagedLock<MockImageCtx> MockManagedLock;
 
   void expect_unlock(MockImageCtx &mock_image_ctx, int r) {
     EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),