From: Jason Dillaman Date: Mon, 9 Nov 2015 15:48:10 +0000 (-0500) Subject: tests: new test case to catch deadlock on RBD image refresh X-Git-Tag: v0.94.6~60^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b3b7877f9b4b3f43acab09d0dd6ee971b6aa1c29;p=ceph.git tests: new test case to catch deadlock on RBD image refresh Signed-off-by: Jason Dillaman (cherry picked from commit a9729d9553e7fb925509cad8d388cf52a9fede9c) --- diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index 442889657ba98..37c33f27d0b63 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -2677,7 +2677,13 @@ TEST_F(TestLibRBD, BlockingAIO) int order = 18; ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order)); + std::string non_blocking_aio; + ASSERT_EQ(0, _rados.conf_get("rbd_non_blocking_aio", non_blocking_aio)); ASSERT_EQ(0, _rados.conf_set("rbd_non_blocking_aio", "0")); + BOOST_SCOPE_EXIT( (non_blocking_aio) ) { + ASSERT_EQ(0, _rados.conf_set("rbd_non_blocking_aio", + non_blocking_aio.c_str())); + } BOOST_SCOPE_EXIT_END; librbd::Image image; ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL)); @@ -2826,3 +2832,34 @@ TEST_F(TestLibRBD, CacheMayCopyOnWrite) { ASSERT_EQ(1024, clone.read(offset + 2048, 1024, read_bl)); ASSERT_TRUE(expect_bl.contents_equal(read_bl)); } + +TEST_F(TestLibRBD, FlushEmptyOpsOnExternalSnapshot) { + std::string cache_enabled; + ASSERT_EQ(0, _rados.conf_get("rbd_cache", cache_enabled)); + ASSERT_EQ(0, _rados.conf_set("rbd_cache", "false")); + BOOST_SCOPE_EXIT( (cache_enabled) ) { + ASSERT_EQ(0, _rados.conf_set("rbd_cache", cache_enabled.c_str())); + } BOOST_SCOPE_EXIT_END; + + librados::IoCtx ioctx; + ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx)); + + librbd::RBD rbd; + std::string name = get_temp_image_name(); + uint64_t size = 1 << 18; + int order = 0; + ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order)); + + librbd::Image image1; + librbd::Image image2; + ASSERT_EQ(0, rbd.open(ioctx, image1, name.c_str(), NULL)); + ASSERT_EQ(0, rbd.open(ioctx, image2, name.c_str(), NULL)); + ASSERT_EQ(0, image1.snap_create("snap1")); + + librbd::RBD::AioCompletion *read_comp = + new librbd::RBD::AioCompletion(NULL, NULL); + bufferlist read_bl; + image2.aio_read(0, 1024, read_bl, read_comp); + ASSERT_EQ(0, read_comp->wait_for_complete()); + read_comp->release(); +}