From: Kefu Chai Date: Wed, 17 Jul 2019 13:18:40 +0000 (+0800) Subject: test/librados_test_stub: s/Mutex/ceph::mutex/ X-Git-Tag: v15.1.0~1971^2~10 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e3e65af1728649ffe3f8b37ce5d63255f422e48f;p=ceph-ci.git test/librados_test_stub: s/Mutex/ceph::mutex/ Signed-off-by: Kefu Chai --- diff --git a/src/test/librados_test_stub/TestMemCluster.h b/src/test/librados_test_stub/TestMemCluster.h index 4b9bb1cf1aa..ac215f98c97 100644 --- a/src/test/librados_test_stub/TestMemCluster.h +++ b/src/test/librados_test_stub/TestMemCluster.h @@ -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 diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.cc b/src/test/librados_test_stub/TestMemIoCtxImpl.cc index e47f3f76018..94b8c5aadf5 100644 --- a/src/test/librados_test_stub/TestMemIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestMemIoCtxImpl.cc @@ -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( diff --git a/src/test/librados_test_stub/TestRadosClient.cc b/src/test/librados_test_stub/TestRadosClient.cc index fcd5099af28..1b65c0fd30f 100644 --- a/src/test/librados_test_stub/TestRadosClient.cc +++ b/src/test/librados_test_stub/TestRadosClient.cc @@ -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(); } diff --git a/src/test/librados_test_stub/TestWatchNotify.cc b/src/test/librados_test_stub/TestWatchNotify.cc index bc2121f0c5a..2fa14400fc5 100644 --- a/src/test/librados_test_stub/TestWatchNotify.cc +++ b/src/test/librados_test_stub/TestWatchNotify.cc @@ -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; diff --git a/src/test/librados_test_stub/TestWatchNotify.h b/src/test/librados_test_stub/TestWatchNotify.h index 4d381373f09..aae6252580e 100644 --- a/src/test/librados_test_stub/TestWatchNotify.h +++ b/src/test/librados_test_stub/TestWatchNotify.h @@ -6,13 +6,12 @@ #include "include/rados/librados.hpp" #include "common/AsyncOpTracker.h" -#include "common/Mutex.h" +#include "common/ceph_mutex.h" #include #include #include #include -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;