Skip to content

Commit

Permalink
test: reproducer for writeback CoW deadlock
Browse files Browse the repository at this point in the history
Refs: ceph#14988

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
Jason Dillaman committed Mar 9, 2016
1 parent cfed9b6 commit 16b6efd
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/test/librbd/test_librbd.cc
Expand Up @@ -4167,3 +4167,48 @@ TEST_F(TestLibRBD, Mirror) {

ASSERT_EQ(-EBUSY, rbd.mirror_mode_set(ioctx, RBD_MIRROR_MODE_DISABLED));
}

TEST_F(TestLibRBD, FlushCacheWithCopyupOnExternalSnapshot) {
REQUIRE_FEATURE(RBD_FEATURE_LAYERING);

librados::IoCtx ioctx;
ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx));

librbd::RBD rbd;
librbd::Image image;
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));
ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));

bufferlist bl;
bl.append(std::string(size, '1'));
ASSERT_EQ((int)size, image.write(0, size, bl));
ASSERT_EQ(0, image.snap_create("one"));
ASSERT_EQ(0, image.snap_protect("one"));

std::string clone_name = this->get_temp_image_name();
ASSERT_EQ(0, rbd.clone(ioctx, name.c_str(), "one", ioctx, clone_name.c_str(),
RBD_FEATURE_LAYERING, &order));
ASSERT_EQ(0, rbd.open(ioctx, image, clone_name.c_str(), NULL));

librbd::Image image2;
ASSERT_EQ(0, rbd.open(ioctx, image2, clone_name.c_str(), NULL));

// prepare CoW writeback that will be flushed on next op
bl.clear();
bl.append(std::string(1, '1'));
ASSERT_EQ(0, image.flush());
ASSERT_EQ(1, image.write(0, 1, bl));
ASSERT_EQ(0, image2.snap_create("snap1"));

librbd::RBD::AioCompletion *read_comp =
new librbd::RBD::AioCompletion(NULL, NULL);
bufferlist read_bl;
image.aio_read(0, 1024, read_bl, read_comp);
ASSERT_EQ(0, read_comp->wait_for_complete());
read_comp->release();
}

0 comments on commit 16b6efd

Please sign in to comment.