]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_orphan.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rgw / rgw_orphan.cc
index 874061306b6580f90a59186c3dcd9a3e2ffd9d0f..a8b4f5296dd727d21a1828e93ad6a79ef421219f 100644 (file)
@@ -16,7 +16,6 @@
 #include "rgw_sal_rados.h"
 
 #include "services/svc_zone.h"
-#include "services/svc_sys_obj.h"
 
 #define dout_subsys ceph_subsys_rgw
 
@@ -150,7 +149,7 @@ int RGWOrphanStore::list_jobs(map <string,RGWOrphanSearchState>& job_list)
 
 int RGWOrphanStore::init(const DoutPrefixProvider *dpp)
 {
-  const rgw_pool& log_pool = store->get_zone()->get_params().log_pool;
+  const rgw_pool& log_pool = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->get_zone_params().log_pool;
   int r = rgw_init_ioctx(dpp, static_cast<rgw::sal::RadosStore*>(store)->getRados()->get_rados_handle(), log_pool, ioctx);
   if (r < 0) {
     cerr << "ERROR: failed to open log pool (" << log_pool << " ret=" << r << std::endl;
@@ -453,7 +452,7 @@ int RGWOrphanSearch::handle_stat_result(const DoutPrefixProvider *dpp, map<int,
 
     RGWObjManifest::obj_iterator miter;
     for (miter = manifest.obj_begin(dpp); miter != manifest.obj_end(dpp); ++miter) {
-      const rgw_raw_obj& loc = miter.get_location().get_raw_obj(static_cast<rgw::sal::RadosStore*>(store));
+      const rgw_raw_obj& loc = miter.get_location().get_raw_obj(store->getRados());
       string s = loc.oid;
       obj_oids.insert(obj_fingerprint(s));
     }
@@ -520,7 +519,7 @@ int RGWOrphanSearch::build_linked_oids_for_bucket(const DoutPrefixProvider *dpp,
     return 0;
   }
 
-  if (cur_bucket->get_info().reshard_status == cls_rgw_reshard_status::IN_PROGRESS) {
+  if (cur_bucket->get_info().layout.resharding != rgw::BucketReshardState::None) {
     ldpp_dout(dpp, 0) << __func__ << ": reshard in progress. Skipping "
                            << orphan_bucket.name << ": "
                            << orphan_bucket.bucket_id << dendl;
@@ -1043,7 +1042,7 @@ int RGWRadosList::handle_stat_result(const DoutPrefixProvider *dpp,
     RGWObjManifest::obj_iterator miter;
     for (miter = manifest.obj_begin(dpp); miter != manifest.obj_end(dpp); ++miter) {
       const rgw_raw_obj& loc =
-       miter.get_location().get_raw_obj(static_cast<rgw::sal::RadosStore*>(store));
+       miter.get_location().get_raw_obj(store->getRados());
       string s = loc.oid;
       obj_oids.insert(s);
     }
@@ -1171,9 +1170,7 @@ int RGWRadosList::process_bucket(
     ", entries_filter.size=" << entries_filter.size() << dendl;
 
   RGWBucketInfo bucket_info;
-  RGWSysObjectCtx sys_obj_ctx = store->svc()->sysobj->init_obj_ctx();
-  int ret = store->getRados()->get_bucket_instance_info(sys_obj_ctx,
-                                                       bucket_instance_id,
+  int ret = store->getRados()->get_bucket_instance_info(bucket_instance_id,
                                                        bucket_info,
                                                        nullptr,
                                                        nullptr,
@@ -1244,6 +1241,8 @@ int RGWRadosList::process_bucket(
        continue;
       }
 
+      std::unique_ptr<rgw::sal::Bucket> bucket;
+      store->get_bucket(nullptr, bucket_info, &bucket);
       // we need to do this in two cases below, so use a lambda
       auto do_stat_key =
        [&](const rgw_obj_key& key) -> int {
@@ -1319,7 +1318,8 @@ int RGWRadosList::process_bucket(
 }
 
 
-int RGWRadosList::run(const DoutPrefixProvider *dpp)
+int RGWRadosList::run(const DoutPrefixProvider *dpp,
+                     const bool yes_i_really_mean_it)
 {
   int ret;
   void* handle = nullptr;
@@ -1332,17 +1332,36 @@ int RGWRadosList::run(const DoutPrefixProvider *dpp)
     return ret;
   }
 
-  const int max_keys = 1000;
+  constexpr int max_keys = 1000;
   bool truncated = true;
+  bool warned_indexless = false;
 
   do {
     std::list<std::string> buckets;
     ret = store->meta_list_keys_next(dpp, handle, max_keys, buckets, &truncated);
 
     for (std::string& bucket_id : buckets) {
-      ret = run(dpp, bucket_id);
+      ret = run(dpp, bucket_id, true);
       if (ret == -ENOENT) {
        continue;
+      } else if (ret == -EINVAL) {
+       if (! warned_indexless) {
+         if (yes_i_really_mean_it) {
+           std::cerr <<
+             "WARNING: because there is at least one indexless bucket (" <<
+             bucket_id <<
+             ") the results of radoslist are *incomplete*; continuing due to --yes-i-really-mean-it" <<
+             std::endl;
+           warned_indexless = true;
+         } else {
+           std::cerr << "ERROR: because there is at least one indexless bucket (" <<
+             bucket_id <<
+             ") the results of radoslist are *incomplete*; use --yes-i-really-mean-it to bypass error" <<
+             std::endl;
+           return ret;
+         }
+       }
+       continue;
       } else if (ret < 0) {
        return ret;
       }
@@ -1350,13 +1369,13 @@ int RGWRadosList::run(const DoutPrefixProvider *dpp)
   } while (truncated);
 
   return 0;
-} // RGWRadosList::run()
+} // RGWRadosList::run(DoutPrefixProvider, bool)
 
 
-int RGWRadosList::run(const DoutPrefixProvider *dpp, const std::string& start_bucket_name)
+int RGWRadosList::run(const DoutPrefixProvider *dpp,
+                     const std::string& start_bucket_name,
+                     const bool silent_indexless)
 {
-  RGWObjectCtx obj_ctx(store);
-  std::unique_ptr<rgw::sal::Bucket> bucket;
   int ret;
 
   add_bucket_entire(start_bucket_name);
@@ -1380,6 +1399,12 @@ int RGWRadosList::run(const DoutPrefixProvider *dpp, const std::string& start_bu
       std::cerr << "ERROR: could not get info for bucket " << bucket_name <<
        " -- " << cpp_strerror(-ret) << std::endl;
       return ret;
+    } else if (bucket->get_info().is_indexless()) {
+      if (! silent_indexless) {
+       std::cerr << "ERROR: unable to run radoslist on indexless bucket " <<
+         bucket_name << std::endl;
+      }
+      return -EINVAL;
     }
 
     const std::string bucket_id = bucket->get_key().get_key();
@@ -1428,12 +1453,13 @@ int RGWRadosList::run(const DoutPrefixProvider *dpp, const std::string& start_bu
   } // while (! bucket_process_map.empty())
 
   if (include_rgw_obj_name) {
-    goto done;
+    return 0;
   }
 
   // now handle incomplete multipart uploads by going back to the
   // initial bucket
 
+  std::unique_ptr<rgw::sal::Bucket> bucket;
   ret = store->get_bucket(dpp, nullptr, tenant_name, start_bucket_name, &bucket, null_yield);
   if (ret == -ENOENT) {
     // bucket deletion race?
@@ -1451,10 +1477,8 @@ int RGWRadosList::run(const DoutPrefixProvider *dpp, const std::string& start_bu
     return ret;
   }
 
-done:
-
   return 0;
-} // RGWRadosList::run(string)
+} // RGWRadosList::run(DoutPrefixProvider, string, bool)
 
 
 int RGWRadosList::do_incomplete_multipart(const DoutPrefixProvider *dpp,
@@ -1512,7 +1536,7 @@ int RGWRadosList::do_incomplete_multipart(const DoutPrefixProvider *dpp,
                 obj_it != manifest.obj_end(dpp);
                 ++obj_it) {
              const rgw_raw_obj& loc =
-               obj_it.get_location().get_raw_obj(static_cast<rgw::sal::RadosStore*>(store));
+               obj_it.get_location().get_raw_obj(store->getRados());
              std::cout << loc.oid << std::endl;
            } // for (auto obj_it
          } // for (auto& p