]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: assert failure when using data pool 11641/head
authorVenky Shankar <vshankar@redhat.com>
Mon, 24 Oct 2016 13:16:42 +0000 (18:46 +0530)
committerVenky Shankar <vshankar@redhat.com>
Wed, 26 Oct 2016 02:41:17 +0000 (08:11 +0530)
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>
src/librbd/image/CreateRequest.cc
src/test/librbd/test_librbd.cc

index fd9e21427b1edddd2fb565c633cea108e7a42211..e0448561b4873325a59ae4a2f0888a2223f783a7 100644 (file)
@@ -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;
   }
 
index 35a1815b98ea4ca73d2af09c546baa7dbb22b6d9..65598c3e4f2bb3c40967c0331aef77f9dd829cfa 100644 (file)
@@ -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;