From: Jason Dillaman Date: Thu, 7 Nov 2019 15:58:35 +0000 (-0500) Subject: Revert "nautilus: librbd: behave more gracefully when data pool removed" X-Git-Tag: v14.2.5~146^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F31468%2Fhead;p=ceph.git Revert "nautilus: librbd: behave more gracefully when data pool removed" Signed-off-by: Jason Dillaman --- diff --git a/qa/workunits/rbd/rbd_mirror.sh b/qa/workunits/rbd/rbd_mirror.sh index e534f537bcb2..80d7b5deafd9 100755 --- a/qa/workunits/rbd/rbd_mirror.sh +++ b/qa/workunits/rbd/rbd_mirror.sh @@ -305,35 +305,6 @@ for i in ${image2} ${image4}; do compare_images ${POOL} ${i} done -testlog "TEST: remove mirroring pool" -pool=pool_to_remove -for cluster in ${CLUSTER1} ${CLUSTER2}; do - CEPH_ARGS='' ceph --cluster ${cluster} osd pool create ${pool} 16 16 - CEPH_ARGS='' rbd --cluster ${cluster} pool init ${pool} - rbd --cluster ${cluster} mirror pool enable ${pool} pool -done -rbd --cluster ${CLUSTER1} mirror pool peer add ${pool} ${CLUSTER2} -rbd --cluster ${CLUSTER2} mirror pool peer add ${pool} ${CLUSTER1} -rdp_image=test_remove_data_pool -create_image ${CLUSTER2} ${pool} ${image} 128 -create_image ${CLUSTER2} ${POOL} ${rdp_image} 128 --data-pool ${pool} -write_image ${CLUSTER2} ${pool} ${image} 100 -write_image ${CLUSTER2} ${POOL} ${rdp_image} 100 -wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${pool} ${image} -wait_for_status_in_pool_dir ${CLUSTER1} ${pool} ${image} 'up+replaying' 'master_position' -wait_for_replay_complete ${CLUSTER1} ${CLUSTER2} ${POOL} ${rdp_image} -wait_for_status_in_pool_dir ${CLUSTER1} ${POOL} ${rdp_image} 'up+replaying' 'master_position' -for cluster in ${CLUSTER1} ${CLUSTER2}; do - CEPH_ARGS='' ceph --cluster ${cluster} osd pool rm ${pool} ${pool} --yes-i-really-really-mean-it -done -remove_image_retry ${CLUSTER2} ${POOL} ${rdp_image} -wait_for_image_present ${CLUSTER1} ${POOL} ${rdp_image} 'deleted' -for i in 0 1 2 4 8 8 8 8 16 16; do - sleep $i - admin_daemons "${CLUSTER2}" rbd mirror status ${pool}/${image} || break -done -admin_daemons "${CLUSTER2}" rbd mirror status ${pool}/${image} && false - testlog "TEST: snapshot rename" snap_name='snap_rename' create_snapshot ${CLUSTER2} ${POOL} ${image2} "${snap_name}_0" diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 4eb622e6b4d3..539777153c88 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -719,8 +719,6 @@ inline namespace v14_2_0 { ~IoCtx(); - bool is_valid() const; - // Close our pool handle void close(); diff --git a/src/librados/librados_cxx.cc b/src/librados/librados_cxx.cc index 63e22987924b..77190788a678 100644 --- a/src/librados/librados_cxx.cc +++ b/src/librados/librados_cxx.cc @@ -1056,10 +1056,6 @@ librados::IoCtx::~IoCtx() close(); } -bool librados::IoCtx::is_valid() const { - return io_ctx_impl != nullptr; -} - void librados::IoCtx::close() { if (io_ctx_impl) diff --git a/src/librbd/DeepCopyRequest.cc b/src/librbd/DeepCopyRequest.cc index 1d56b255d4cb..45191158e38c 100644 --- a/src/librbd/DeepCopyRequest.cc +++ b/src/librbd/DeepCopyRequest.cc @@ -50,18 +50,6 @@ DeepCopyRequest::~DeepCopyRequest() { template void DeepCopyRequest::send() { - if (!m_src_image_ctx->data_ctx.is_valid()) { - lderr(m_cct) << "missing data pool for source image" << dendl; - finish(-ENODEV); - return; - } - - if (!m_dst_image_ctx->data_ctx.is_valid()) { - lderr(m_cct) << "missing data pool for destination image" << dendl; - finish(-ENODEV); - return; - } - int r = validate_copy_points(); if (r < 0) { finish(r); diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 6ad3b7455e47..19d3ce70c9be 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -172,9 +172,7 @@ public: delete[] format_string; md_ctx.aio_flush(); - if (data_ctx.is_valid()) { - data_ctx.aio_flush(); - } + data_ctx.aio_flush(); io_work_queue->drain(); delete io_object_dispatcher; @@ -193,7 +191,7 @@ public: asok_hook = new LibrbdAdminSocketHook(this); string pname = string("librbd-") + id + string("-") + - md_ctx.get_pool_name() + string("-") + name; + data_ctx.get_pool_name() + string("-") + name; if (!snap_name.empty()) { pname += "-"; pname += snap_name; @@ -214,7 +212,7 @@ public: asok_hook = nullptr; } - void ImageCtx::init_layout(int64_t pool_id) + void ImageCtx::init_layout() { if (stripe_unit == 0 || stripe_count == 0) { stripe_unit = 1ull << order; @@ -231,7 +229,7 @@ public: layout.stripe_unit = stripe_unit; layout.stripe_count = stripe_count; layout.object_size = 1ull << order; - layout.pool_id = pool_id; // FIXME: pool id overflow? + layout.pool_id = data_ctx.get_id(); // FIXME: pool id overflow? delete[] format_string; size_t len = object_prefix.length() + 16; @@ -331,9 +329,7 @@ public: snap_namespace = it->second.snap_namespace; snap_name = it->second.name; snap_exists = true; - if (data_ctx.is_valid()) { - data_ctx.snap_set_read(snap_id); - } + data_ctx.snap_set_read(snap_id); return 0; } return -ENOENT; @@ -346,9 +342,7 @@ public: snap_namespace = {}; snap_name = ""; snap_exists = true; - if (data_ctx.is_valid()) { - data_ctx.snap_set_read(snap_id); - } + data_ctx.snap_set_read(snap_id); } snap_t ImageCtx::get_snap_id(const cls::rbd::SnapshotNamespace& in_snap_namespace, diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index f60dec988640..fe1c4828cabb 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -223,7 +223,7 @@ namespace librbd { ~ImageCtx(); void init(); void shutdown(); - void init_layout(int64_t pool_id); + void init_layout(); void perf_start(std::string name); void perf_stop(); void set_read_flag(unsigned flag); diff --git a/src/librbd/api/DiffIterate.cc b/src/librbd/api/DiffIterate.cc index 55fefcc211e7..148734b7e50a 100644 --- a/src/librbd/api/DiffIterate.cc +++ b/src/librbd/api/DiffIterate.cc @@ -238,10 +238,6 @@ int DiffIterate::diff_iterate(I *ictx, ldout(ictx->cct, 20) << "diff_iterate " << ictx << " off = " << off << " len = " << len << dendl; - if (!ictx->data_ctx.is_valid()) { - return -ENODEV; - } - // ensure previous writes are visible to listsnaps C_SaferCond flush_ctx; { @@ -280,8 +276,6 @@ template int DiffIterate::execute() { CephContext* cct = m_image_ctx.cct; - ceph_assert(m_image_ctx.data_ctx.is_valid()); - librados::IoCtx head_ctx; librados::snap_t from_snap_id = 0; librados::snap_t end_snap_id; diff --git a/src/librbd/api/Image.cc b/src/librbd/api/Image.cc index ac781390b974..3339909350e4 100644 --- a/src/librbd/api/Image.cc +++ b/src/librbd/api/Image.cc @@ -76,23 +76,6 @@ int pre_remove_image(librados::IoCtx& io_ctx, const std::string& image_id) { } // anonymous namespace -template -int64_t Image::get_data_pool_id(I *ictx) { - if (ictx->data_ctx.is_valid()) { - return ictx->data_ctx.get_id(); - } - - int64_t pool_id; - int r = cls_client::get_data_pool(&ictx->md_ctx, ictx->header_oid, &pool_id); - if (r < 0) { - CephContext *cct = ictx->cct; - lderr(cct) << "error getting data pool ID: " << cpp_strerror(r) << dendl; - return r; - } - - return pool_id; -} - template int Image::get_op_features(I *ictx, uint64_t *op_features) { CephContext *cct = ictx->cct; diff --git a/src/librbd/api/Image.h b/src/librbd/api/Image.h index af928c84c06c..8bfadae70de9 100644 --- a/src/librbd/api/Image.h +++ b/src/librbd/api/Image.h @@ -24,8 +24,6 @@ template struct Image { typedef std::map ImageNameToIds; - static int64_t get_data_pool_id(ImageCtxT *ictx); - static int get_op_features(ImageCtxT *ictx, uint64_t *op_features); static int list_images(librados::IoCtx& io_ctx, diff --git a/src/librbd/api/Snapshot.cc b/src/librbd/api/Snapshot.cc index 3d29cfb263a2..99010bf4d353 100644 --- a/src/librbd/api/Snapshot.cc +++ b/src/librbd/api/Snapshot.cc @@ -111,7 +111,7 @@ int Snapshot::get_group_namespace(I *ictx, uint64_t snap_id, return -ENOENT; } - GetGroupVisitor ggv = GetGroupVisitor(ictx->cct, &ictx->md_ctx, group_snap); + GetGroupVisitor ggv = GetGroupVisitor(ictx->cct, &ictx->data_ctx, group_snap); r = boost::apply_visitor(ggv, snap_info->snap_namespace); if (r < 0) { return r; diff --git a/src/librbd/cache/ObjectCacherObjectDispatch.cc b/src/librbd/cache/ObjectCacherObjectDispatch.cc index 5bced71bfdf3..f108247b2542 100644 --- a/src/librbd/cache/ObjectCacherObjectDispatch.cc +++ b/src/librbd/cache/ObjectCacherObjectDispatch.cc @@ -78,7 +78,6 @@ ObjectCacherObjectDispatch::ObjectCacherObjectDispatch( : m_image_ctx(image_ctx), m_cache_lock(util::unique_lock_name( "librbd::cache::ObjectCacherObjectDispatch::cache_lock", this)) { - ceph_assert(m_image_ctx->data_ctx.is_valid()); } template diff --git a/src/librbd/deep_copy/ObjectCopyRequest.cc b/src/librbd/deep_copy/ObjectCopyRequest.cc index 92a1750f1152..14acda37edfb 100644 --- a/src/librbd/deep_copy/ObjectCopyRequest.cc +++ b/src/librbd/deep_copy/ObjectCopyRequest.cc @@ -50,8 +50,6 @@ ObjectCopyRequest::ObjectCopyRequest(I *src_image_ctx, m_dst_image_ctx(dst_image_ctx), m_cct(dst_image_ctx->cct), m_snap_map(snap_map), m_dst_object_number(dst_object_number), m_flatten(flatten), m_on_finish(on_finish) { - ceph_assert(src_image_ctx->data_ctx.is_valid()); - ceph_assert(dst_image_ctx->data_ctx.is_valid()); ceph_assert(!m_snap_map.empty()); m_src_async_op = new io::AsyncOperation(); diff --git a/src/librbd/image/OpenRequest.cc b/src/librbd/image/OpenRequest.cc index 7d4625aea1c2..dd9e603dc98b 100644 --- a/src/librbd/image/OpenRequest.cc +++ b/src/librbd/image/OpenRequest.cc @@ -473,19 +473,13 @@ Context *OpenRequest::handle_v2_get_data_pool(int *result) { *result = util::create_ioctx(m_image_ctx->md_ctx, "data pool", data_pool_id, {}, &m_image_ctx->data_ctx); if (*result < 0) { - if (*result != -ENOENT) { - send_close_image(*result); - return nullptr; - } - m_image_ctx->data_ctx.close(); - } else { - m_image_ctx->data_ctx.set_namespace(m_image_ctx->md_ctx.get_namespace()); + send_close_image(*result); + return nullptr; } - } else { - data_pool_id = m_image_ctx->md_ctx.get_id(); + m_image_ctx->data_ctx.set_namespace(m_image_ctx->md_ctx.get_namespace()); } - m_image_ctx->init_layout(data_pool_id); + m_image_ctx->init_layout(); send_refresh(); return nullptr; } @@ -522,8 +516,7 @@ Context *OpenRequest::handle_refresh(int *result) { template Context *OpenRequest::send_init_cache(int *result) { // cache is disabled or parent image context - if (!m_image_ctx->cache || m_image_ctx->child != nullptr || - !m_image_ctx->data_ctx.is_valid()) { + if (!m_image_ctx->cache || m_image_ctx->child != nullptr) { return send_register_watch(result); } diff --git a/src/librbd/image/RefreshRequest.cc b/src/librbd/image/RefreshRequest.cc index 7ec565d6cafc..664f5b8b793e 100644 --- a/src/librbd/image/RefreshRequest.cc +++ b/src/librbd/image/RefreshRequest.cc @@ -1313,7 +1313,7 @@ void RefreshRequest::apply() { m_image_ctx.op_features = 0; m_image_ctx.operations_disabled = false; m_image_ctx.object_prefix = std::move(m_object_prefix); - m_image_ctx.init_layout(m_image_ctx.md_ctx.get_id()); + m_image_ctx.init_layout(); } else { // HEAD revision doesn't have a defined overlap so it's only // applicable to snapshots @@ -1396,10 +1396,8 @@ void RefreshRequest::apply() { if (m_refresh_parent != nullptr) { m_refresh_parent->apply(); } - if (m_image_ctx.data_ctx.is_valid()) { - m_image_ctx.data_ctx.selfmanaged_snap_set_write_ctx(m_image_ctx.snapc.seq, - m_image_ctx.snaps); - } + m_image_ctx.data_ctx.selfmanaged_snap_set_write_ctx(m_image_ctx.snapc.seq, + m_image_ctx.snaps); // handle dynamically enabled / disabled features if (m_image_ctx.exclusive_lock != nullptr && diff --git a/src/librbd/image/RemoveRequest.cc b/src/librbd/image/RemoveRequest.cc index 8e029f8b9122..1cff51b3eae5 100644 --- a/src/librbd/image/RemoveRequest.cc +++ b/src/librbd/image/RemoveRequest.cc @@ -126,11 +126,6 @@ void RemoveRequest::handle_pre_remove_image(int r) { return; } - if (!m_image_ctx->data_ctx.is_valid()) { - detach_child(); - return; - } - trim_image(); } diff --git a/src/librbd/image/RemoveRequest.h b/src/librbd/image/RemoveRequest.h index 98d597645a49..40a571e5aab8 100644 --- a/src/librbd/image/RemoveRequest.h +++ b/src/librbd/image/RemoveRequest.h @@ -63,7 +63,7 @@ private: * PRE REMOVE IMAGE * * * | * | * | * v * | - * (skip if invalid data pool) TRIM IMAGE * * * * * | + * TRIM IMAGE * * * * * | * | * | * v * | * DETACH CHILD * | diff --git a/src/librbd/io/CopyupRequest.cc b/src/librbd/io/CopyupRequest.cc index 06ef47ca8650..3ab44d0ec859 100644 --- a/src/librbd/io/CopyupRequest.cc +++ b/src/librbd/io/CopyupRequest.cc @@ -114,7 +114,6 @@ CopyupRequest::CopyupRequest(I *ictx, const std::string &oid, m_trace(util::create_trace(*m_image_ctx, "copy-up", parent_trace)), m_lock("CopyupRequest", false, false) { - ceph_assert(m_image_ctx->data_ctx.is_valid()); m_async_op.start_op(*util::get_image_ctx(m_image_ctx)); } diff --git a/src/librbd/io/ImageRequestWQ.cc b/src/librbd/io/ImageRequestWQ.cc index 34f2c2cf2bae..32584640d7dd 100644 --- a/src/librbd/io/ImageRequestWQ.cc +++ b/src/librbd/io/ImageRequestWQ.cc @@ -844,15 +844,6 @@ int ImageRequestWQ::start_in_flight_io(AioCompletion *c) { return false; } - if (!m_image_ctx.data_ctx.is_valid()) { - CephContext *cct = m_image_ctx.cct; - lderr(cct) << "missing data pool" << dendl; - - c->get(); - c->fail(-ENODEV); - return false; - } - m_in_flight_ios++; return true; } diff --git a/src/librbd/io/ObjectRequest.cc b/src/librbd/io/ObjectRequest.cc index 58b1708455eb..57bd7291c682 100644 --- a/src/librbd/io/ObjectRequest.cc +++ b/src/librbd/io/ObjectRequest.cc @@ -115,7 +115,6 @@ ObjectRequest::ObjectRequest(I *ictx, const std::string &oid, : m_ictx(ictx), m_oid(oid), m_object_no(objectno), m_object_off(off), m_object_len(len), m_snap_id(snap_id), m_completion(completion), m_trace(util::create_trace(*ictx, "", trace)) { - ceph_assert(m_ictx->data_ctx.is_valid()); if (m_trace.valid()) { m_trace.copy_name(trace_name + std::string(" ") + oid); m_trace.event("start"); diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc index 5f0136bdc8c8..09019012cbad 100644 --- a/src/librbd/librbd.cc +++ b/src/librbd/librbd.cc @@ -1457,7 +1457,7 @@ namespace librbd { int64_t Image::get_data_pool_id() { ImageCtx *ictx = reinterpret_cast(ctx); - return librbd::api::Image<>::get_data_pool_id(ictx); + return ictx->data_ctx.get_id(); } int Image::parent_info(string *parent_pool_name, string *parent_name, @@ -4228,7 +4228,7 @@ extern "C" int rbd_get_block_name_prefix(rbd_image_t image, char *prefix, extern "C" int64_t rbd_get_data_pool_id(rbd_image_t image) { librbd::ImageCtx *ictx = reinterpret_cast(image); - return librbd::api::Image<>::get_data_pool_id(ictx); + return ictx->data_ctx.get_id(); } extern "C" int rbd_get_parent_info(rbd_image_t image, diff --git a/src/librbd/operation/ObjectMapIterate.cc b/src/librbd/operation/ObjectMapIterate.cc index 669584164902..658dbb4a7376 100644 --- a/src/librbd/operation/ObjectMapIterate.cc +++ b/src/librbd/operation/ObjectMapIterate.cc @@ -194,11 +194,6 @@ private: template void ObjectMapIterateRequest::send() { - if (!m_image_ctx.data_ctx.is_valid()) { - this->async_complete(-ENODEV); - return; - } - send_verify_objects(); } @@ -206,12 +201,6 @@ template bool ObjectMapIterateRequest::should_complete(int r) { CephContext *cct = m_image_ctx.cct; ldout(cct, 5) << this << " should_complete: " << " r=" << r << dendl; - - if (r == -ENODEV) { - lderr(cct) << "missing data pool" << dendl; - return true; - } - if (r < 0) { lderr(cct) << "object map operation encountered an error: " << cpp_strerror(r) << dendl; diff --git a/src/librbd/operation/SnapshotCreateRequest.cc b/src/librbd/operation/SnapshotCreateRequest.cc index 66293609166e..31553177306f 100644 --- a/src/librbd/operation/SnapshotCreateRequest.cc +++ b/src/librbd/operation/SnapshotCreateRequest.cc @@ -36,15 +36,6 @@ SnapshotCreateRequest::SnapshotCreateRequest(I &image_ctx, template void SnapshotCreateRequest::send_op() { - I &image_ctx = this->m_image_ctx; - CephContext *cct = image_ctx.cct; - - if (!image_ctx.data_ctx.is_valid()) { - lderr(cct) << "missing data pool" << dendl; - this->async_complete(-ENODEV); - return; - } - send_suspend_requests(); } diff --git a/src/librbd/operation/SnapshotRemoveRequest.cc b/src/librbd/operation/SnapshotRemoveRequest.cc index fde41a5f363d..8c34ebf6c534 100644 --- a/src/librbd/operation/SnapshotRemoveRequest.cc +++ b/src/librbd/operation/SnapshotRemoveRequest.cc @@ -263,11 +263,6 @@ template void SnapshotRemoveRequest::release_snap_id() { I &image_ctx = this->m_image_ctx; - if (!image_ctx.data_ctx.is_valid()) { - remove_snap(); - return; - } - CephContext *cct = image_ctx.cct; ldout(cct, 5) << "snap_name=" << m_snap_name << ", " << "snap_id=" << m_snap_id << dendl; diff --git a/src/librbd/operation/SparsifyRequest.cc b/src/librbd/operation/SparsifyRequest.cc index 53049f886e7a..4dc6bde7e324 100644 --- a/src/librbd/operation/SparsifyRequest.cc +++ b/src/librbd/operation/SparsifyRequest.cc @@ -124,11 +124,6 @@ public: ldout(m_cct, 20) << dendl; - if (!image_ctx.data_ctx.is_valid()) { - lderr(m_cct) << "missing data pool" << dendl; - return -ENODEV; - } - if (image_ctx.exclusive_lock != nullptr && !image_ctx.exclusive_lock->is_lock_owner()) { ldout(m_cct, 1) << "lost exclusive lock during sparsify" << dendl; diff --git a/src/librbd/operation/TrimRequest.cc b/src/librbd/operation/TrimRequest.cc index 15f6a5dfd818..cecf37b3e613 100644 --- a/src/librbd/operation/TrimRequest.cc +++ b/src/librbd/operation/TrimRequest.cc @@ -174,15 +174,6 @@ bool TrimRequest::should_complete(int r) template void TrimRequest::send() { - I &image_ctx = this->m_image_ctx; - CephContext *cct = image_ctx.cct; - - if (!image_ctx.data_ctx.is_valid()) { - lderr(cct) << "missing data pool" << dendl; - send_finish(-ENODEV); - return; - } - send_pre_trim(); } diff --git a/src/test/librbd/image/test_mock_RefreshRequest.cc b/src/test/librbd/image/test_mock_RefreshRequest.cc index a920948fb11e..5ce1feda777d 100644 --- a/src/test/librbd/image/test_mock_RefreshRequest.cc +++ b/src/test/librbd/image/test_mock_RefreshRequest.cc @@ -378,7 +378,7 @@ public: } void expect_init_layout(MockRefreshImageCtx &mock_image_ctx) { - EXPECT_CALL(mock_image_ctx, init_layout(_)); + EXPECT_CALL(mock_image_ctx, init_layout()); } void expect_test_features(MockRefreshImageCtx &mock_image_ctx) { diff --git a/src/test/librbd/mock/MockImageCtx.h b/src/test/librbd/mock/MockImageCtx.h index 5c0db6a8fc16..4c45011d3ce5 100644 --- a/src/test/librbd/mock/MockImageCtx.h +++ b/src/test/librbd/mock/MockImageCtx.h @@ -139,7 +139,7 @@ struct MockImageCtx { ctx.wait(); } - MOCK_METHOD1(init_layout, void(int64_t)); + MOCK_METHOD0(init_layout, void()); MOCK_CONST_METHOD1(get_object_name, std::string(uint64_t)); MOCK_CONST_METHOD0(get_object_size, uint64_t()); diff --git a/src/test/librbd/test_internal.cc b/src/test/librbd/test_internal.cc index 0caf9ffff431..e95be0b8a9f2 100644 --- a/src/test/librbd/test_internal.cc +++ b/src/test/librbd/test_internal.cc @@ -1683,72 +1683,3 @@ TEST_F(TestInternal, SparsifyClone) { ASSERT_EQ(0, ictx->data_ctx.stat(oid, &size, NULL)); ASSERT_EQ(0, ictx->data_ctx.read(oid, read_bl, 4096, 0)); } - -TEST_F(TestInternal, MissingDataPool) { - REQUIRE_FORMAT_V2(); - - librbd::ImageCtx *ictx; - ASSERT_EQ(0, open_image(m_image_name, &ictx)); - ASSERT_EQ(0, snap_create(*ictx, "snap1")); - std::string header_oid = ictx->header_oid; - close_image(ictx); - - // emulate non-existent data pool - int64_t pool_id = 1234; - std::string pool_name; - int r; - while ((r = _rados.pool_reverse_lookup(pool_id, &pool_name)) == 0) { - pool_id++; - } - ASSERT_EQ(r, -ENOENT); - bufferlist bl; - using ceph::encode; - encode(pool_id, bl); - ASSERT_EQ(0, m_ioctx.omap_set(header_oid, {{"data_pool_id", bl}})); - - ASSERT_EQ(0, open_image(m_image_name, &ictx)); - - ASSERT_FALSE(ictx->data_ctx.is_valid()); - ASSERT_EQ(pool_id, librbd::api::Image<>::get_data_pool_id(ictx)); - - librbd::image_info_t info; - ASSERT_EQ(0, librbd::info(ictx, info, sizeof(info))); - - vector snaps; - EXPECT_EQ(0, librbd::snap_list(ictx, snaps)); - EXPECT_EQ(1U, snaps.size()); - EXPECT_EQ("snap1", snaps[0].name); - - bufferptr read_ptr(256); - bufferlist read_bl; - read_bl.push_back(read_ptr); - librbd::io::ReadResult read_result{&read_bl}; - ASSERT_EQ(-ENODEV, - ictx->io_work_queue->read(0, 256, - librbd::io::ReadResult{read_result}, 0)); - ASSERT_EQ(-ENODEV, - ictx->io_work_queue->write(0, bl.length(), bufferlist{bl}, 0)); - ASSERT_EQ(-ENODEV, ictx->io_work_queue->discard(0, 1, 256)); - ASSERT_EQ(-ENODEV, - ictx->io_work_queue->writesame(0, bl.length(), bufferlist{bl}, 0)); - uint64_t mismatch_off; - ASSERT_EQ(-ENODEV, - ictx->io_work_queue->compare_and_write(0, bl.length(), - bufferlist{bl}, - bufferlist{bl}, - &mismatch_off, 0)); - ASSERT_EQ(-ENODEV, ictx->io_work_queue->flush()); - - ASSERT_EQ(-ENODEV, snap_create(*ictx, "snap2")); - ASSERT_EQ(0, ictx->operations->snap_remove(cls::rbd::UserSnapshotNamespace(), - "snap1")); - - librbd::NoOpProgressContext no_op; - ASSERT_EQ(-ENODEV, ictx->operations->resize(0, true, no_op)); - - close_image(ictx); - - ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, m_image_name, no_op)); - - ASSERT_EQ(0, create_image_pp(m_rbd, m_ioctx, m_image_name, m_image_size)); -}