]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: modify radoslist to better support the rgw-gap-list tool
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 18 Mar 2025 18:33:42 +0000 (14:33 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Thu, 20 Mar 2025 01:59:48 +0000 (21:59 -0400)
When the `radosgw-admin bucket radoslist ...` sub-command was
introduced, it was written specifically for finding orphans. It has
since been updated to work for finding gaps, that is indexed RGW
objects that are missing one or more supporting rados objects.

When a head object was not found, it was ignored. Now it does produce
output with the oid and related information for the missing head
object.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
src/rgw/radosgw-admin/orphan.cc

index 7808bf8ea61d31546f7ec0fd956245c13f4dac65..35865174deadddb1787fc9b297eea9b2da0d8f7e 100644 (file)
@@ -1066,18 +1066,30 @@ int RGWRadosList::pop_and_handle_stat_op(
   RGWRados::Object::Stat& front_op = ops.front();
 
   int ret = front_op.wait(dpp);
-  if (ret < 0) {
-    if (ret != -ENOENT) {
-      ldpp_dout(dpp, -1) << "ERROR: stat_async() returned error: " <<
-       cpp_strerror(-ret) << dendl;
-    }
-    goto done;
-  }
+  if (ret == -ENOENT) {
+    const auto& result = front_op.result;
+    const rgw_bucket& bucket = result.obj.bucket;
+    const std::string oid = bucket.marker + "_" + result.obj.get_oid();
+    obj_oids.insert(oid);
 
-  ret = handle_stat_result(dpp, front_op.result, bucket_name, obj_key, obj_oids);
-  if (ret < 0) {
-    ldpp_dout(dpp, -1) << "ERROR: handle_stat_result() returned error: " <<
+    // needed for the processing below
+    bucket_name = result.obj.bucket.name;
+    obj_key = result.obj.key;
+
+    ldpp_dout(dpp, -1) << "ERROR: " << __func__ <<
+      ": stat of head object resulted in ENOENT; oid=" << oid << dendl;
+  } else if (ret < 0) {
+    ldpp_dout(dpp, -1) << "ERROR: " << __func__ <<
+      ": stat_async() returned error: " <<
       cpp_strerror(-ret) << dendl;
+    goto done;
+  } else {
+    ret = handle_stat_result(dpp, front_op.result, bucket_name, obj_key, obj_oids);
+    if (ret < 0) {
+      ldpp_dout(dpp, -1) << "ERROR: " << __func__ <<
+       ": handle_stat_result() returned error: " <<
+       cpp_strerror(-ret) << dendl;
+    }
   }
 
   // output results
@@ -1099,6 +1111,7 @@ done:
   obj_ctx.invalidate(front_op.result.obj);
 
   ops.pop_front();
+
   return ret;
 }