Skip to content

Commit

Permalink
librbd: assert failure when using data pool
Browse files Browse the repository at this point in the history
This fixes a silly assert that's hit during image creation
(cli/api) when the data pool specified is same as the pool
specified by -p/--pool option (or the default).

Signed-off-by: Venky Shankar <vshankar@redhat.com>
  • Loading branch information
vshankar committed Oct 26, 2016
1 parent 0919de2 commit a5fff40
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librbd/image/CreateRequest.cc
Expand Up @@ -190,6 +190,7 @@ CreateRequest<I>::CreateRequest(IoCtx &ioctx, const std::string &image_name,
if (!m_data_pool.empty() && m_data_pool != ioctx.get_pool_name()) {
m_features |= RBD_FEATURE_DATA_POOL;
} else {
m_data_pool.clear();
m_features &= ~RBD_FEATURE_DATA_POOL;
}

Expand Down
37 changes: 37 additions & 0 deletions src/test/librbd/test_librbd.cc
Expand Up @@ -254,6 +254,43 @@ TEST_F(TestLibRBD, CreateAndStat)
rados_ioctx_destroy(ioctx);
}

TEST_F(TestLibRBD, CreateWithSameDataPool)
{
REQUIRE_FORMAT_V2();

rados_ioctx_t ioctx;
ASSERT_EQ(0, rados_ioctx_create(_cluster, m_pool_name.c_str(), &ioctx));

rbd_image_t image;
std::string name = get_temp_image_name();
uint64_t size = 2 << 20;

bool old_format;
uint64_t features;
ASSERT_EQ(0, get_features(&old_format, &features));
ASSERT_FALSE(old_format);

rbd_image_options_t image_options;
rbd_image_options_create(&image_options);
BOOST_SCOPE_EXIT( (&image_options) ) {
rbd_image_options_destroy(image_options);
} BOOST_SCOPE_EXIT_END;

ASSERT_EQ(0, rbd_image_options_set_uint64(image_options,
RBD_IMAGE_OPTION_FEATURES,
features));
ASSERT_EQ(0, rbd_image_options_set_string(image_options,
RBD_IMAGE_OPTION_DATA_POOL,
m_pool_name.c_str()));

ASSERT_EQ(0, rbd_create4(ioctx, name.c_str(), size, image_options));
ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));

ASSERT_EQ(0, rbd_close(image));

rados_ioctx_destroy(ioctx);
}

TEST_F(TestLibRBD, CreateAndStatPP)
{
librados::IoCtx ioctx;
Expand Down

0 comments on commit a5fff40

Please sign in to comment.