Skip to content

Commit

Permalink
Merge pull request ceph#38653 from dillaman/wip-48647
Browse files Browse the repository at this point in the history
librbd: clear implicitly enabled feature bits when creating images

Reviewed-by: Mykola Golub <[email protected]>
  • Loading branch information
trociny committed Dec 21, 2020
2 parents b885dfe + e1dd693 commit 1e880b1
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/librbd/api/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ int Image<I>::deep_copy(I *src, librados::IoCtx& dest_md_ctx,
return -EBUSY;
}

features = (src->features & ~RBD_FEATURES_IMPLICIT_ENABLE);
features = src->features;
src_size = src->get_image_size(src->snap_id);
}
uint64_t format = 2;
Expand Down
9 changes: 0 additions & 9 deletions src/librbd/api/Migration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,6 @@ int Migration<I>::prepare(librados::IoCtx& io_ctx,
lderr(cct) << "librbd does not support requested features" << dendl;
return -ENOSYS;
}
features &= ~RBD_FEATURES_IMPLICIT_ENABLE;
features |= RBD_FEATURE_MIGRATING;
opts.set(RBD_IMAGE_OPTION_FEATURES, features);

uint64_t order = src_image_ctx->order;
Expand Down Expand Up @@ -512,9 +510,6 @@ int Migration<I>::prepare(librados::IoCtx& io_ctx,
opts, nullptr);
r = migration.prepare();

features &= ~RBD_FEATURE_MIGRATING;
opts.set(RBD_IMAGE_OPTION_FEATURES, features);

return r;
}

Expand Down Expand Up @@ -560,10 +555,6 @@ int Migration<I>::prepare_import(
return -EINVAL;
}

uint64_t features_set = 0;
opts.get(RBD_IMAGE_OPTION_FEATURES_SET, &features_set);
opts.set(RBD_IMAGE_OPTION_FEATURES_SET, features_set | RBD_FEATURE_MIGRATING);

ldout(cct, 20) << "updated opts=" << opts << dendl;

// use json-spirit to clean-up json formatting
Expand Down
1 change: 0 additions & 1 deletion src/librbd/image/CloneRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ void CloneRequest<I>::validate_parent() {
if (m_use_p_features) {
m_features = p_features;
}
m_features &= ~RBD_FEATURES_IMPLICIT_ENABLE;

if (r < 0) {
lderr(m_cct) << "unable to locate parent's snapshot" << dendl;
Expand Down
6 changes: 2 additions & 4 deletions src/librbd/image/CreateRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int validate_features(CephContext *cct, uint64_t features) {
lderr(cct) << "librbd does not support requested features." << dendl;
return -ENOSYS;
}
if ((features & RBD_FEATURE_OPERATIONS) != 0) {
if ((features & RBD_FEATURES_INTERNAL) != 0) {
lderr(cct) << "cannot use internally controlled features" << dendl;
return -EINVAL;
}
Expand Down Expand Up @@ -158,6 +158,7 @@ CreateRequest<I>::CreateRequest(const ConfigProxy& config, IoCtx &ioctx,
m_features |= features_set;
m_features &= ~features_clear;

m_features &= ~RBD_FEATURES_IMPLICIT_ENABLE;
if ((m_features & RBD_FEATURE_OBJECT_MAP) == RBD_FEATURE_OBJECT_MAP) {
m_features |= RBD_FEATURE_FAST_DIFF;
}
Expand Down Expand Up @@ -203,14 +204,11 @@ CreateRequest<I>::CreateRequest(const ConfigProxy& config, IoCtx &ioctx,
m_features |= RBD_FEATURE_DATA_POOL;
} else {
m_data_pool.clear();
m_features &= ~RBD_FEATURE_DATA_POOL;
}

if ((m_stripe_unit != 0 && m_stripe_unit != (1ULL << m_order)) ||
(m_stripe_count != 0 && m_stripe_count != 1)) {
m_features |= RBD_FEATURE_STRIPINGV2;
} else {
m_features &= ~RBD_FEATURE_STRIPINGV2;
}

ldout(m_cct, 10) << "name=" << m_image_name << ", "
Expand Down
1 change: 0 additions & 1 deletion src/test/librbd/test_DeepCopy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ struct TestDeepCopy : public TestFixture {
int order = m_src_ictx->order;
uint64_t features;
ASSERT_EQ(0, librbd::get_features(m_src_ictx, &features));
features &= ~RBD_FEATURES_IMPLICIT_ENABLE;

std::cout << "clone " << m_src_ictx->name << " -> " << clone_name
<< std::endl;
Expand Down
2 changes: 0 additions & 2 deletions src/test/librbd/test_Migration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ struct TestMigration : public TestFixture {
int order = m_ref_ictx->order;
uint64_t features;
ASSERT_EQ(0, librbd::get_features(m_ref_ictx, &features));
features &= ~RBD_FEATURES_IMPLICIT_ENABLE;

std::string ref_clone_name = get_temp_image_name();
std::string clone_name = get_temp_image_name();
Expand Down Expand Up @@ -407,7 +406,6 @@ struct TestMigration : public TestFixture {
int order = m_ictx->order;
uint64_t features;
ASSERT_EQ(0, librbd::get_features(m_ictx, &features));
features &= ~RBD_FEATURES_IMPLICIT_ENABLE;

std::string clone_name = get_temp_image_name();
ASSERT_EQ(0, librbd::clone(m_ictx->md_ctx, m_ictx->name.c_str(), "snap1",
Expand Down
3 changes: 1 addition & 2 deletions src/test/rbd_mirror/test_ImageDeleter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class TestImageDeleter : public TestFixture {

m_local_image_id = librbd::util::generate_image_id(m_local_io_ctx);
librbd::ImageOptions image_opts;
image_opts.set(RBD_IMAGE_OPTION_FEATURES,
(RBD_FEATURES_ALL & ~RBD_FEATURES_IMPLICIT_ENABLE));
image_opts.set(RBD_IMAGE_OPTION_FEATURES, RBD_FEATURES_ALL);
EXPECT_EQ(0, librbd::create(m_local_io_ctx, m_image_name, m_local_image_id,
1 << 20, image_opts, GLOBAL_IMAGE_ID,
m_remote_mirror_uuid, true));
Expand Down
4 changes: 1 addition & 3 deletions src/test/rbd_mirror/test_fixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ void TestFixture::TearDown() {
int TestFixture::create_image(librbd::RBD &rbd, librados::IoCtx &ioctx,
const std::string &name, uint64_t size) {
int order = 18;
return rbd.create2(ioctx, name.c_str(), size,
(RBD_FEATURES_ALL & ~RBD_FEATURES_IMPLICIT_ENABLE),
&order);
return rbd.create2(ioctx, name.c_str(), size, RBD_FEATURES_ALL, &order);
}

int TestFixture::open_image(librados::IoCtx &io_ctx,
Expand Down
3 changes: 1 addition & 2 deletions src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,7 @@ template <typename I>
void CreateImageRequest<I>::populate_image_options(
librbd::ImageOptions* image_options) {
image_options->set(RBD_IMAGE_OPTION_FEATURES,
(m_remote_image_ctx->features &
~RBD_FEATURES_IMPLICIT_ENABLE));
m_remote_image_ctx->features);
image_options->set(RBD_IMAGE_OPTION_ORDER, m_remote_image_ctx->order);
image_options->set(RBD_IMAGE_OPTION_STRIPE_UNIT,
m_remote_image_ctx->stripe_unit);
Expand Down

0 comments on commit 1e880b1

Please sign in to comment.