]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use get_current_index() instead of log_to_index_layout()
authorCasey Bodley <cbodley@redhat.com>
Tue, 18 Jan 2022 21:43:42 +0000 (16:43 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 27 May 2022 19:47:33 +0000 (15:47 -0400)
several places were getting the current index layout indirectly
with layout.logs.back() and rgw::log_to_index_layout(). use
get_current_index() instead so we don't rely on layout.logs, which may
be empty for indexless buckets

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_bucket.cc
src/rgw/rgw_quota.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_sal_rados.cc

index e2966c0ad1877bcf6b2c9d25db688151ddcc08dd..fbd6379d3f43621917d9a2dda5c0ac57f3338406 100644 (file)
@@ -1044,13 +1044,13 @@ static int bucket_stats(rgw::sal::Store* store,
     return ret;
   }
 
-  if (bucket->get_info().is_indexless()) {
+  const auto& index = bucket->get_info().get_current_index();
+  if (is_layout_indexless(index)) {
     cerr << "error, indexless buckets do not maintain stats; bucket=" <<
       bucket->get_name() << std::endl;
     return -EINVAL;
   }
 
-  const auto& index = bucket->get_info().get_current_index();
   std::string bucket_ver, master_ver;
   std::string max_marker;
   ret = bucket->read_stats(dpp, index, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, &max_marker);
@@ -1146,7 +1146,6 @@ int RGWBucketAdminOp::limit_check(rgw::sal::Store* store,
 
       for (const auto& iter : m_buckets) {
        auto& bucket = iter.second;
-       uint32_t num_shards = 1;
        uint64_t num_objects = 0;
 
        marker = bucket->get_name(); /* Casey's location for marker update,
@@ -1157,11 +1156,14 @@ int RGWBucketAdminOp::limit_check(rgw::sal::Store* store,
        if (ret < 0)
          continue;
 
+       const auto& index = bucket->get_info().get_current_index();
+       if (is_layout_indexless(index)) {
+         continue; // indexless buckets don't have stats
+       }
+
        /* need stats for num_entries */
        string bucket_ver, master_ver;
        std::map<RGWObjCategory, RGWStorageStats> stats;
-       const auto& latest_log = bucket->get_info().layout.logs.back();
-       const auto& index = log_to_index_layout(latest_log);
        ret = bucket->read_stats(dpp, index, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, nullptr);
 
        if (ret < 0)
@@ -1171,7 +1173,7 @@ int RGWBucketAdminOp::limit_check(rgw::sal::Store* store,
          num_objects += s.second.num_objects;
        }
 
-       num_shards = bucket->get_info().layout.current_index.layout.normal.num_shards;
+       const uint32_t num_shards = rgw::num_shards(index.layout.normal);
        uint64_t objs_per_shard =
          (num_shards) ? num_objects/num_shards : num_objects;
        {
index d411cd93c4512a95e1b5eeda20e51499996f4710..2d2cf13f253012be910c5255cee932c6dabb3b08 100644 (file)
@@ -273,8 +273,11 @@ int BucketAsyncRefreshHandler::init_fetch()
 
   ldpp_dout(&dp, 20) << "initiating async quota refresh for bucket=" << bucket << dendl;
 
-  const auto& latest_log = rbucket->get_info().layout.logs.back();
-  const auto& index = log_to_index_layout(latest_log);
+  const auto& index = rbucket->get_info().get_current_index();
+  if (is_layout_indexless(index)) {
+    return 0;
+  }
+
   r = rbucket->read_stats_async(&dp, index, RGW_NO_SHARD, this);
   if (r < 0) {
     ldpp_dout(&dp, 0) << "could not get bucket info for bucket=" << bucket.name << dendl;
@@ -343,12 +346,16 @@ int RGWBucketStatsCache::fetch_stats_from_storage(const rgw_user& _u, const rgw_
     return r;
   }
 
+  stats = RGWStorageStats();
+
+  const auto& index = bucket->get_info().get_current_index();
+  if (is_layout_indexless(index)) {
+    return 0;
+  }
+
   string bucket_ver;
   string master_ver;
 
-  const auto& latest_log = bucket->get_info().layout.logs.back();
-  const auto& index = log_to_index_layout(latest_log);
-
   map<RGWObjCategory, RGWStorageStats> bucket_stats;
   r = bucket->read_stats(dpp, index, RGW_NO_SHARD, &bucket_ver,
                         &master_ver, bucket_stats, nullptr);
@@ -358,8 +365,6 @@ int RGWBucketStatsCache::fetch_stats_from_storage(const rgw_user& _u, const rgw_
     return r;
   }
 
-  stats = RGWStorageStats();
-
   for (const auto& pair : bucket_stats) {
     const RGWStorageStats& s = pair.second;
 
index b2caaf9972aa324ce6eaea87beaaf0d00a2d963e..7053a5c4ea240a38426121acd81d02a3177f63fc 100644 (file)
@@ -9132,14 +9132,11 @@ int RGWRados::remove_objs_from_index(const DoutPrefixProvider *dpp,
     " entry_key_list.size()=" << entry_key_list.size() << dendl_bitx;
   ldout_bitx(bitx, dpp, 25) << "BACKTRACE: " << __func__ << ": " << ClibBackTrace(0) << dendl_bitx;
 
-  const rgw::bucket_index_layout_generation& latest_layout = bucket_info.layout.current_index;
-  if (latest_layout.layout.type != rgw::BucketIndexType::Normal ||
-      latest_layout.layout.normal.hash_type != rgw::BucketHashType::Mod) {
-    ldout_bitx(bitx, dpp, 0) << "ERROR: " << __func__ << " index for bucket=" <<
-      bucket_info.bucket << " is not a normal modulo index" << dendl_bitx;
+  const auto& current_index = bucket_info.get_current_index();
+  if (is_layout_indexless(current_index)) {
     return -EINVAL;
   }
-  const uint32_t num_shards = latest_layout.layout.normal.num_shards;
+  const uint32_t num_shards = current_index.layout.normal.num_shards;
 
   RGWSI_RADOS::Pool index_pool;
   std::map<int, std::string> index_oids;
index 7717619bdea5862790ba045f3293781aa67890e4..e11185b206b18f9595b17862df6d4a19635e7e45 100644 (file)
@@ -467,9 +467,7 @@ int RadosBucket::remove_bucket_bypass_gc(int concurrent_max, bool
   if (ret < 0)
     return ret;
 
-  const auto& latest_log = info.layout.logs.back();
-  const auto& index = log_to_index_layout(latest_log);
-
+  const auto& index = info.get_current_index();
   ret = read_stats(dpp, index, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, NULL);
   if (ret < 0)
     return ret;