From: songweibin Date: Wed, 14 Aug 2019 05:46:29 +0000 (+0800) Subject: librbd: skip stale child with non-existent pool for list_descendants X-Git-Tag: v15.1.0~1695^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a485eb827009b629c4c7804ec1b7191cfe6b6dd7;p=ceph.git librbd: skip stale child with non-existent pool for list_descendants Fixes: https://tracker.ceph.com/issues/41241 Signed-off-by: songweibin --- diff --git a/src/librbd/Utils.cc b/src/librbd/Utils.cc index 77b702c64362..c9d7b0413ab7 100644 --- a/src/librbd/Utils.cc +++ b/src/librbd/Utils.cc @@ -127,8 +127,8 @@ int create_ioctx(librados::IoCtx& src_io_ctx, const std::string& pool_desc, librados::Rados rados(src_io_ctx); int r = rados.ioctx_create2(pool_id, *dst_io_ctx); if (r == -ENOENT) { - lderr(cct) << pool_desc << " pool " << pool_id << " no longer exists" - << dendl; + ldout(cct, 1) << pool_desc << " pool " << pool_id << " no longer exists" + << dendl; return r; } else if (r < 0) { lderr(cct) << "error accessing " << pool_desc << " pool " << pool_id diff --git a/src/librbd/api/Image.cc b/src/librbd/api/Image.cc index 713042825e8a..cf5c289ef6ef 100644 --- a/src/librbd/api/Image.cc +++ b/src/librbd/api/Image.cc @@ -450,7 +450,11 @@ int Image::list_descendants( child_io_ctx.get_namespace() != image.pool_namespace) { r = util::create_ioctx(ictx->md_ctx, "child image", image.pool_id, image.pool_namespace, &child_io_ctx); - if (r < 0) { + if (r == -ENOENT) { + image.pool_name = ""; + image.image_name = ""; + continue; + } else if (r < 0) { return r; } child_pool_id = image.pool_id; diff --git a/src/tools/rbd/action/Children.cc b/src/tools/rbd/action/Children.cc index 1225862960b4..f459e92b761c 100644 --- a/src/tools/rbd/action/Children.cc +++ b/src/tools/rbd/action/Children.cc @@ -52,13 +52,21 @@ int do_list_children(librados::IoCtx &io_ctx, librbd::Image &image, f->close_section(); } } else if (all_flag || !trash) { - std::cout << child.pool_name << "/"; + if (child.pool_name.empty()) { + std::cout << "(child missing " << child.pool_id << "/"; + } else { + std::cout << child.pool_name << "/"; + } if (!child.pool_namespace.empty()) { std::cout << child.pool_namespace << "/"; } - std::cout << child.image_name; - if (trash) { - std::cout << " (trash " << child.image_id << ")"; + if (child.image_name.empty()) { + std::cout << child.image_id << ")"; + } else { + std::cout << child.image_name; + if (trash) { + std::cout << " (trash " << child.image_id << ")"; + } } std::cout << std::endl; }