diff options
author | Lu Shi <shi.lu@h3c.com> | 2015-09-24 10:02:41 +0200 |
---|---|---|
committer | Lu Shi <shi.lu@h3c.com> | 2015-09-24 10:06:52 +0200 |
commit | 9c8200bb5d1ac9359803a182df03298b565b8479 (patch) | |
tree | 180b29bd5ce209ea61703ac5bf080e82805d7363 /src/test/librbd | |
parent | Merge pull request #6053 from ceph/wip-cmake-dang (diff) | |
download | ceph-9c8200bb5d1ac9359803a182df03298b565b8479.tar.xz ceph-9c8200bb5d1ac9359803a182df03298b565b8479.zip |
librbd:reads larger than cache size hang.
Fixes:#13164
Signed-off-by: Lu Shi <shi.lu@h3c.com>
Diffstat (limited to 'src/test/librbd')
-rw-r--r-- | src/test/librbd/test_librbd.cc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index 99d272a0d3d..5dc5c66da47 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -2570,7 +2570,7 @@ TEST_F(TestLibRBD, LargeCacheRead) rados_ioctx_t ioctx; rados_ioctx_create(_cluster, m_pool_name.c_str(), &ioctx); - uint32_t new_cache_size = 16777216; + uint32_t new_cache_size = 1 << 20; std::string orig_cache_size; ASSERT_EQ(0, _rados.conf_get("rbd_cache_size", orig_cache_size)); ASSERT_EQ(0, _rados.conf_set("rbd_cache_size", @@ -2582,24 +2582,22 @@ TEST_F(TestLibRBD, LargeCacheRead) } BOOST_SCOPE_EXIT_END; rbd_image_t image; - int order = 0; - const char *name = "testimg"; - uint64_t size = new_cache_size + 1; + int order = 21; + std::string name = get_temp_image_name(); + uint64_t size = 1 << order; - ASSERT_EQ(0, create_image(ioctx, name, size, &order)); - ASSERT_EQ(0, rbd_open(ioctx, name, &image, NULL)); + ASSERT_EQ(0, create_image(ioctx, name.c_str(), size, &order)); + ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL)); std::string buffer(1 << order, '1'); - for (size_t offs = 0; offs < size; offs += buffer.size()) { - size_t len = std::min<uint64_t>(buffer.size(), size - offs); - ASSERT_EQ(static_cast<ssize_t>(len), - rbd_write(image, offs, len, buffer.c_str())); - } + + ASSERT_EQ(static_cast<ssize_t>(buffer.size()), + rbd_write(image, 0, buffer.size(), buffer.c_str())); ASSERT_EQ(0, rbd_invalidate_cache(image)); - buffer.resize(size); - ASSERT_EQ(static_cast<ssize_t>(size-1024), rbd_read(image, 1024, size, &buffer[0])); + ASSERT_EQ(static_cast<ssize_t>(buffer.size()), + rbd_read(image, 0, buffer.size(), &buffer[0])); ASSERT_EQ(0, rbd_close(image)); |