|
|
545b23 |
From c5fd5640879ab0fed0e3ac0009bb37dec43f7ad1 Mon Sep 17 00:00:00 2001
|
|
|
545b23 |
From: Jason Dillaman <dillaman@redhat.com>
|
|
|
545b23 |
Date: Tue, 2 Jun 2015 10:33:35 -0400
|
|
|
545b23 |
Subject: [PATCH 22/22] tests: verify librbd blocking aio code path
|
|
|
545b23 |
|
|
|
545b23 |
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
|
|
|
545b23 |
(cherry picked from commit 4cf41486e9c9e1efcb863960a8f3e0326ffca7e5)
|
|
|
545b23 |
(cherry picked from commit 0e668f6a278bf4d2c7a80dc7a30325e1c1645ce0)
|
|
|
545b23 |
|
|
|
545b23 |
Conflicts:
|
|
|
545b23 |
src/test/librbd/test_librbd.cc: removed refs to pending AIO
|
|
|
545b23 |
---
|
|
|
545b23 |
src/test/librbd/test_librbd.cc | 59 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
545b23 |
1 file changed, 59 insertions(+)
|
|
|
545b23 |
|
|
|
545b23 |
diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc
|
|
|
545b23 |
index a903dd2..0f3e857 100644
|
|
|
545b23 |
--- a/src/test/librbd/test_librbd.cc
|
|
|
545b23 |
+++ b/src/test/librbd/test_librbd.cc
|
|
|
545b23 |
@@ -1867,6 +1867,65 @@ TEST(LibRBD, ZeroLengthRead)
|
|
|
545b23 |
ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
|
|
|
545b23 |
}
|
|
|
545b23 |
|
|
|
545b23 |
+TEST(LibRBD, BlockingAIO)
|
|
|
545b23 |
+{
|
|
|
545b23 |
+ librados::Rados rados;
|
|
|
545b23 |
+ librados::IoCtx ioctx;
|
|
|
545b23 |
+ string pool_name = get_temp_pool_name();
|
|
|
545b23 |
+
|
|
|
545b23 |
+ ASSERT_EQ("", create_one_pool_pp(pool_name, rados));
|
|
|
545b23 |
+ ASSERT_EQ(0, rados.ioctx_create(pool_name.c_str(), ioctx));
|
|
|
545b23 |
+
|
|
|
545b23 |
+ librbd::RBD rbd;
|
|
|
545b23 |
+ std::string name = "testimg";
|
|
|
545b23 |
+ uint64_t size = 1 << 20;
|
|
|
545b23 |
+ int order = 18;
|
|
|
545b23 |
+ ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order);;
|
|
|
545b23 |
+
|
|
|
545b23 |
+ CephContext *cct = reinterpret_cast<CephContext*>(ioctx.cct());
|
|
|
545b23 |
+ cct->_conf->set_val_or_die("rbd_non_blocking_aio", "0");
|
|
|
545b23 |
+
|
|
|
545b23 |
+ librbd::Image image;
|
|
|
545b23 |
+ ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
|
|
|
545b23 |
+
|
|
|
545b23 |
+ bufferlist bl;
|
|
|
545b23 |
+ bl.append(std::string(256, '1'));
|
|
|
545b23 |
+
|
|
|
545b23 |
+ librbd::RBD::AioCompletion *write_comp =
|
|
|
545b23 |
+ new librbd::RBD::AioCompletion(NULL, NULL);
|
|
|
545b23 |
+ ASSERT_EQ(0, image.aio_write(0, bl.length(), bl, write_comp));
|
|
|
545b23 |
+
|
|
|
545b23 |
+ librbd::RBD::AioCompletion *flush_comp =
|
|
|
545b23 |
+ new librbd::RBD::AioCompletion(NULL, NULL);
|
|
|
545b23 |
+ ASSERT_EQ(0, image.aio_flush(flush_comp));
|
|
|
545b23 |
+ ASSERT_EQ(0, flush_comp->wait_for_complete());
|
|
|
545b23 |
+ ASSERT_EQ(0, flush_comp->get_return_value());
|
|
|
545b23 |
+ flush_comp->release();
|
|
|
545b23 |
+
|
|
|
545b23 |
+ ASSERT_EQ(1, write_comp->is_complete());
|
|
|
545b23 |
+ ASSERT_EQ(0, write_comp->get_return_value());
|
|
|
545b23 |
+ write_comp->release();
|
|
|
545b23 |
+
|
|
|
545b23 |
+ librbd::RBD::AioCompletion *discard_comp =
|
|
|
545b23 |
+ new librbd::RBD::AioCompletion(NULL, NULL);
|
|
|
545b23 |
+ ASSERT_EQ(0, image.aio_discard(128, 128, discard_comp));
|
|
|
545b23 |
+ ASSERT_EQ(0, discard_comp->wait_for_complete());
|
|
|
545b23 |
+ discard_comp->release();
|
|
|
545b23 |
+
|
|
|
545b23 |
+ librbd::RBD::AioCompletion *read_comp =
|
|
|
545b23 |
+ new librbd::RBD::AioCompletion(NULL, NULL);
|
|
|
545b23 |
+ bufferlist read_bl;
|
|
|
545b23 |
+ image.aio_read(0, bl.length(), read_bl, read_comp);
|
|
|
545b23 |
+ ASSERT_EQ(0, read_comp->wait_for_complete());
|
|
|
545b23 |
+ ASSERT_EQ(bl.length(), read_comp->get_return_value());
|
|
|
545b23 |
+ read_comp->release();
|
|
|
545b23 |
+
|
|
|
545b23 |
+ bufferlist expected_bl;
|
|
|
545b23 |
+ expected_bl.append(std::string(128, '1'));
|
|
|
545b23 |
+ expected_bl.append(std::string(128, '\0'));
|
|
|
545b23 |
+ ASSERT_TRUE(expected_bl.contents_equal(read_bl));
|
|
|
545b23 |
+}
|
|
|
545b23 |
+
|
|
|
545b23 |
int main(int argc, char **argv)
|
|
|
545b23 |
{
|
|
|
545b23 |
::testing::InitGoogleTest(&argc, argv);
|
|
|
545b23 |
--
|
|
|
545b23 |
2.1.0
|
|
|
545b23 |
|