]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/librados_test_stub: s/Mutex/ceph::mutex/
authorKefu Chai <kchai@redhat.com>
Wed, 17 Jul 2019 13:18:40 +0000 (21:18 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 3 Aug 2019 03:27:20 +0000 (11:27 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/librados_test_stub/TestMemCluster.h
src/test/librados_test_stub/TestMemIoCtxImpl.cc
src/test/librados_test_stub/TestRadosClient.cc
src/test/librados_test_stub/TestWatchNotify.cc
src/test/librados_test_stub/TestWatchNotify.h

index 4b9bb1cf1aaa462645ec53ed6dcb47b85e7addba..ac215f98c975301c5b5d9578bb6583c079462262 100644 (file)
@@ -8,8 +8,7 @@
 #include "include/buffer.h"
 #include "include/interval_set.h"
 #include "include/int_types.h"
-#include "common/Cond.h"
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
 #include "common/RefCountedObj.h"
 #include "common/RWLock.h"
 #include <boost/shared_ptr.hpp>
index e47f3f760187207e2e41ff6f6f3f433f0f0914a1..94b8c5aadf51654584334f8cd8034465159d18f0 100644 (file)
@@ -768,8 +768,9 @@ void TestMemIoCtxImpl::ensure_minimum_length(size_t len, bufferlist *bl) {
 
 TestMemCluster::SharedFile TestMemIoCtxImpl::get_file(
     const std::string &oid, bool write, const SnapContext &snapc) {
-  ceph_assert(m_pool->file_lock.is_locked() || m_pool->file_lock.is_wlocked());
-  ceph_assert(!write || m_pool->file_lock.is_wlocked());
+  ceph_assert(ceph_mutex_is_locked(m_pool->file_lock) ||
+             ceph_mutex_is_wlocked(m_pool->file_lock));
+  ceph_assert(!write || ceph_mutex_is_wlocked(m_pool->file_lock));
 
   TestMemCluster::SharedFile file;
   TestMemCluster::Files::iterator it = m_pool->files.find(
index fcd5099af28171dbf2d81b17fb6f119ab869c194..1b65c0fd30f9bb959b67764326d7720bc9cdd496 100644 (file)
@@ -32,10 +32,10 @@ static int get_concurrency() {
 namespace librados {
 
 static void finish_aio_completion(AioCompletionImpl *c, int r) {
-  c->lock.Lock();
+  c->lock.lock();
   c->complete = true;
   c->rval = r;
-  c->lock.Unlock();
+  c->lock.unlock();
 
   rados_callback_t cb_complete = c->callback_complete;
   void *cb_complete_arg = c->callback_complete_arg;
@@ -49,10 +49,10 @@ static void finish_aio_completion(AioCompletionImpl *c, int r) {
     cb_safe(c, cb_safe_arg);
   }
 
-  c->lock.Lock();
+  c->lock.lock();
   c->callback_complete = NULL;
   c->callback_safe = NULL;
-  c->cond.Signal();
+  c->cond.notify_all();
   c->put_unlock();
 }
 
index bc2121f0c5a86fe1f81d2aa54acda8296c1b8bb9..2fa14400fc51ce3f339e7ee14fa607c4f27b58b1 100644 (file)
@@ -50,7 +50,7 @@ struct TestWatchNotify::ObjectHandler : public TestCluster::ObjectHandler {
 };
 
 TestWatchNotify::TestWatchNotify(TestCluster* test_cluster)
-  : m_test_cluster(test_cluster), m_lock("librados::TestWatchNotify::m_lock") {
+  : m_test_cluster(test_cluster) {
 }
 
 void TestWatchNotify::flush(TestRadosClient *rados_client) {
@@ -171,10 +171,10 @@ void TestWatchNotify::execute_watch(TestRadosClient *rados_client,
                                     Context* on_finish) {
   CephContext *cct = rados_client->cct();
 
-  m_lock.Lock();
+  m_lock.lock();
   SharedWatcher watcher = get_watcher(pool_id, nspace, o);
   if (!watcher) {
-    m_lock.Unlock();
+    m_lock.unlock();
     on_finish->complete(-ENOENT);
     return;
   }
@@ -193,7 +193,7 @@ void TestWatchNotify::execute_watch(TestRadosClient *rados_client,
 
   ldout(cct, 20) << "oid=" << o << ", gid=" << gid << ": handle=" << *handle
                 << dendl;
-  m_lock.Unlock();
+  m_lock.unlock();
 
   on_finish->complete(0);
 }
@@ -222,7 +222,7 @@ void TestWatchNotify::execute_unwatch(TestRadosClient *rados_client,
 
 TestWatchNotify::SharedWatcher TestWatchNotify::get_watcher(
     int64_t pool_id, const std::string& nspace, const std::string& oid) {
-  ceph_assert(m_lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(m_lock));
 
   auto it = m_file_watchers.find({pool_id, nspace, oid});
   if (it == m_file_watchers.end()) {
@@ -243,7 +243,7 @@ TestWatchNotify::SharedWatcher TestWatchNotify::get_watcher(
 }
 
 void TestWatchNotify::maybe_remove_watcher(SharedWatcher watcher) {
-  ceph_assert(m_lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(m_lock));
 
   // TODO
   if (watcher->watch_handles.empty() && watcher->notify_handles.empty()) {
@@ -267,13 +267,13 @@ void TestWatchNotify::execute_notify(TestRadosClient *rados_client,
                                      Context *on_notify) {
   CephContext *cct = rados_client->cct();
 
-  m_lock.Lock();
+  m_lock.lock();
   uint64_t notify_id = ++m_notify_id;
 
   SharedWatcher watcher = get_watcher(pool_id, nspace, oid);
   if (!watcher) {
     ldout(cct, 1) << "oid=" << oid << ": not found" << dendl;
-    m_lock.Unlock();
+    m_lock.unlock();
     on_notify->complete(-ENOENT);
     return;
   }
@@ -316,7 +316,7 @@ void TestWatchNotify::execute_notify(TestRadosClient *rados_client,
   watcher->notify_handles[notify_id] = notify_handle;
 
   finish_notify(rados_client, pool_id, nspace, oid, notify_id);
-  m_lock.Unlock();
+  m_lock.unlock();
 }
 
 void TestWatchNotify::ack_notify(TestRadosClient *rados_client, int64_t pool_id,
@@ -326,7 +326,7 @@ void TestWatchNotify::ack_notify(TestRadosClient *rados_client, int64_t pool_id,
                                  const bufferlist &bl) {
   CephContext *cct = rados_client->cct();
 
-  ceph_assert(m_lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(m_lock));
   SharedWatcher watcher = get_watcher(pool_id, nspace, oid);
   if (!watcher) {
     ldout(cct, 1) << "oid=" << oid << ": not found" << dendl;
@@ -359,7 +359,7 @@ void TestWatchNotify::finish_notify(TestRadosClient *rados_client,
 
   ldout(cct, 20) << "oid=" << oid << ", notify_id=" << notify_id << dendl;
 
-  ceph_assert(m_lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(m_lock));
   SharedWatcher watcher = get_watcher(pool_id, nspace, oid);
   if (!watcher) {
     ldout(cct, 1) << "oid=" << oid << ": not found" << dendl;
index 4d381373f09e9afd3eb5112d8455dd2303790334..aae6252580e4ffc69b7c918b038eb8adbcb2400c 100644 (file)
@@ -6,13 +6,12 @@
 
 #include "include/rados/librados.hpp"
 #include "common/AsyncOpTracker.h"
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
 #include <boost/noncopyable.hpp>
 #include <boost/shared_ptr.hpp>
 #include <list>
 #include <map>
 
-class Cond;
 class Finisher;
 
 namespace librados {
@@ -109,7 +108,8 @@ private:
   uint64_t m_handle = 0;
   uint64_t m_notify_id = 0;
 
-  Mutex m_lock;
+  ceph::mutex m_lock =
+    ceph::make_mutex("librados::TestWatchNotify::m_lock");
   AsyncOpTracker m_async_op_tracker;
 
   FileWatchers m_file_watchers;