]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: skip stale child with non-existent pool for list_descendants
authorsongweibin <song.weibin@zte.com.cn>
Wed, 14 Aug 2019 05:46:29 +0000 (13:46 +0800)
committersongweibin <song.weibin@zte.com.cn>
Mon, 26 Aug 2019 08:31:02 +0000 (16:31 +0800)
Fixes: https://tracker.ceph.com/issues/41241
Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/librbd/Utils.cc
src/librbd/api/Image.cc
src/tools/rbd/action/Children.cc

index 77b702c64362df14e7841d248c40c6078bdaaa25..c9d7b0413ab776516123e2975604ac4cec125ba1 100644 (file)
@@ -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
index 713042825e8a8c53290e01d0e984a69406a84967..cf5c289ef6ef1ea889d1acd3c4bc67ac238a1fa0 100644 (file)
@@ -450,7 +450,11 @@ int Image<I>::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;
index 1225862960b46615cb71d8d5da76dd3b3f69a334..f459e92b761c3a0e9b9456e3b9cdd2e28f38f356 100644 (file)
@@ -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;
     }