]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/migration/NativeFormat: do pool lookup instead of creating io_ctx
authorIlya Dryomov <idryomov@gmail.com>
Wed, 17 Jul 2024 18:05:08 +0000 (20:05 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sat, 10 Aug 2024 20:56:20 +0000 (22:56 +0200)
A Rados instance is sufficient to map the pool name to the pool ID,
no need to involve an IoCtx instance as well.  While at it, report
distinctive errors for a non-existing pool and an invalid JSON value
for pool_name key cases.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 1ba9a32598f50073b574b4649736d76b678a1c58)

src/librbd/migration/NativeFormat.cc

index a7682619c1908711bf9cf3eba43dbf18778b0814..600c16c137194806bb4b0fb3ba65c01e649ce65f 100644 (file)
@@ -65,15 +65,12 @@ void NativeFormat<I>::open(Context* on_finish) {
   auto& pool_name_val = m_json_object[POOL_NAME_KEY];
   if (pool_name_val.type() == json_spirit::str_type) {
     librados::Rados rados(m_image_ctx->md_ctx);
-    librados::IoCtx io_ctx;
-    int r = rados.ioctx_create(pool_name_val.get_str().c_str(), io_ctx);
-    if (r < 0 ) {
-      lderr(cct) << "invalid pool name" << dendl;
-      on_finish->complete(r);
+    m_pool_id = rados.pool_lookup(pool_name_val.get_str().c_str());
+    if (m_pool_id < 0) {
+      lderr(cct) << "failed to lookup pool" << dendl;
+      on_finish->complete(static_cast<int>(m_pool_id));
       return;
     }
-
-    m_pool_id = io_ctx.get_id();
   } else if (pool_name_val.type() != json_spirit::null_type) {
     lderr(cct) << "invalid pool name" << dendl;
     on_finish->complete(-EINVAL);