From: Jason Dillaman Date: Wed, 8 Jul 2015 02:13:47 +0000 (-0400) Subject: tests: updates for AIO locking changes X-Git-Tag: v10.0.1~52^2~32 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=75240f12615ddc55644ef5a55e1cb7fdaab69e63;p=ceph.git tests: updates for AIO locking changes Signed-off-by: Jason Dillaman --- diff --git a/src/test/librbd/test_ImageWatcher.cc b/src/test/librbd/test_ImageWatcher.cc index 2bc72bf91809..d0a76e36a98a 100644 --- a/src/test/librbd/test_ImageWatcher.cc +++ b/src/test/librbd/test_ImageWatcher.cc @@ -163,10 +163,10 @@ public: int handle_restart_aio(librbd::ImageCtx *ictx, librbd::AioCompletion *aio_completion) { + assert(ictx->owner_lock.is_locked()); Mutex::Locker callback_locker(m_callback_lock); ++m_aio_completion_restarts; - RWLock::RLocker owner_locker(ictx->owner_lock); if (!ictx->image_watcher->is_lock_owner() && (m_expected_aio_restarts == 0 || m_aio_completion_restarts < m_expected_aio_restarts)) { diff --git a/src/test/librbd/test_internal.cc b/src/test/librbd/test_internal.cc index 1bf8bce4074b..5269005c4183 100644 --- a/src/test/librbd/test_internal.cc +++ b/src/test/librbd/test_internal.cc @@ -4,6 +4,7 @@ #include "test/librbd/test_support.h" #include "librbd/AioCompletion.h" #include "librbd/AioImageRequest.h" +#include "librbd/AioImageRequestWQ.h" #include "librbd/ImageWatcher.h" #include "librbd/internal.h" #include "librbd/ObjectMap.h" @@ -255,7 +256,11 @@ TEST_F(TestInternal, AioWriteRequestsLock) { librbd::AioCompletion *c = librbd::aio_create_completion_internal(ctx, librbd::rbd_ctx_cb); c->get(); - librbd::AioImageWrite(*ictx, c, 0, buffer.size(), buffer.c_str(), 0).send(); + { + RWLock::RLocker owner_lock(ictx->owner_lock); + librbd::AioImageRequest::write(ictx, c, 0, buffer.size(), buffer.c_str(), + 0); + } bool is_owner; ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner)); @@ -278,7 +283,10 @@ TEST_F(TestInternal, AioDiscardRequestsLock) { librbd::AioCompletion *c = librbd::aio_create_completion_internal(ctx, librbd::rbd_ctx_cb); c->get(); - librbd::AioImageDiscard(*ictx, c, 0, 256).send(); + { + RWLock::RLocker owner_lock(ictx->owner_lock); + librbd::AioImageRequest::discard(ictx, c, 0, 256); + } bool is_owner; ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner)); @@ -466,7 +474,7 @@ TEST_F(TestInternal, SnapshotCopyup) bufferlist bl; bl.append(std::string(256, '1')); - ASSERT_EQ(256, librbd::write(ictx, 0, bl.length(), bl.c_str(), 0)); + ASSERT_EQ(256, ictx->aio_work_queue->write(0, bl.length(), bl.c_str(), 0)); ASSERT_EQ(0, librbd::snap_create(ictx, "snap1")); ASSERT_EQ(0, librbd::snap_protect(ictx, "snap1")); @@ -485,7 +493,7 @@ TEST_F(TestInternal, SnapshotCopyup) ASSERT_EQ(0, librbd::snap_create(ictx2, "snap1")); ASSERT_EQ(0, librbd::snap_create(ictx2, "snap2")); - ASSERT_EQ(256, librbd::write(ictx2, 256, bl.length(), bl.c_str(), 0)); + ASSERT_EQ(256, ictx2->aio_work_queue->write(256, bl.length(), bl.c_str(), 0)); librados::IoCtx snap_ctx; snap_ctx.dup(m_ioctx); @@ -515,10 +523,10 @@ TEST_F(TestInternal, SnapshotCopyup) const char *snap_name = it->empty() ? NULL : it->c_str(); ASSERT_EQ(0, librbd::snap_set(ictx2, snap_name)); - ASSERT_EQ(256, librbd::read(ictx2, 0, 256, read_bl.c_str(), 0)); + ASSERT_EQ(256, ictx2->aio_work_queue->read(0, 256, read_bl.c_str(), 0)); ASSERT_TRUE(bl.contents_equal(read_bl)); - ASSERT_EQ(256, librbd::read(ictx2, 256, 256, read_bl.c_str(), 0)); + ASSERT_EQ(256, ictx2->aio_work_queue->read(256, 256, read_bl.c_str(), 0)); if (snap_name == NULL) { ASSERT_TRUE(bl.contents_equal(read_bl)); } else { @@ -557,7 +565,8 @@ TEST_F(TestInternal, ResizeCopyup) bufferlist bl; bl.append(std::string(4096, '1')); for (size_t i = 0; i < m_image_size; i += bl.length()) { - ASSERT_EQ(bl.length(), librbd::write(ictx, i, bl.length(), bl.c_str(), 0)); + ASSERT_EQ(bl.length(), ictx->aio_work_queue->write(i, bl.length(), + bl.c_str(), 0)); } ASSERT_EQ(0, librbd::snap_create(ictx, "snap1")); @@ -588,8 +597,8 @@ TEST_F(TestInternal, ResizeCopyup) } for (size_t i = 2 << order; i < m_image_size; i += bl.length()) { - ASSERT_EQ(bl.length(), librbd::read(ictx2, i, bl.length(), read_bl.c_str(), - 0)); + ASSERT_EQ(bl.length(), ictx2->aio_work_queue->read(i, bl.length(), + read_bl.c_str(), 0)); ASSERT_TRUE(bl.contents_equal(read_bl)); } } @@ -613,7 +622,8 @@ TEST_F(TestInternal, DiscardCopyup) bufferlist bl; bl.append(std::string(4096, '1')); for (size_t i = 0; i < m_image_size; i += bl.length()) { - ASSERT_EQ(bl.length(), librbd::write(ictx, i, bl.length(), bl.c_str(), 0)); + ASSERT_EQ(bl.length(), ictx->aio_work_queue->write(i, bl.length(), + bl.c_str(), 0)); } ASSERT_EQ(0, librbd::snap_create(ictx, "snap1")); @@ -633,7 +643,7 @@ TEST_F(TestInternal, DiscardCopyup) read_bl.push_back(read_ptr); ASSERT_EQ(static_cast(m_image_size - 64), - librbd::discard(ictx2, 32, m_image_size - 64)); + ictx2->aio_work_queue->discard(32, m_image_size - 64)); ASSERT_EQ(0, librbd::snap_set(ictx2, "snap1")); { @@ -643,8 +653,8 @@ TEST_F(TestInternal, DiscardCopyup) } for (size_t i = 0; i < m_image_size; i += bl.length()) { - ASSERT_EQ(bl.length(), librbd::read(ictx2, i, bl.length(), read_bl.c_str(), - 0)); + ASSERT_EQ(bl.length(), ictx2->aio_work_queue->read(i, bl.length(), + read_bl.c_str(), 0)); ASSERT_TRUE(bl.contents_equal(read_bl)); } } diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index 8309518a0e25..70d8391ee36a 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -3176,8 +3176,9 @@ TEST_F(TestLibRBD, BlockingAIO) ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL)); bufferlist bl; - bl.append(std::string(256, '1')); + ASSERT_EQ(0, image.write(0, bl.length(), bl)); + bl.append(std::string(256, '1')); librbd::RBD::AioCompletion *write_comp = new librbd::RBD::AioCompletion(NULL, NULL); ASSERT_EQ(0, image.aio_write(0, bl.length(), bl, write_comp));