]> 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>
Tue, 8 Feb 2022 21:32:24 +0000 (16:32 -0500)
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 a2f41becd3b0c144e5823d77ead95a5f702a3229..68da8bc761b344ab4e69527ebf973ed5cf0fa083 100644 (file)
@@ -1076,13 +1076,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);
@@ -1178,7 +1178,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,
@@ -1189,11 +1188,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)
@@ -1203,7 +1205,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 023b320e194eb503001782351d45e710f4ea07c5..1bc3bc099ae651e1c7baa579ed00650651cca7c4 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 1824a872ff8c55729c2accce25b854a429967f28..2d589cdf067a958b6cf1c7956aa3784536ab177f 100644 (file)
@@ -9108,10 +9108,10 @@ int RGWRados::remove_objs_from_index(const DoutPrefixProvider *dpp,
                                     const std::list<rgw_obj_index_key>& entry_key_list)
 {
   RGWSI_RADOS::Pool index_pool;
-  const auto& latest_log = bucket_info.layout.logs.back();
-  const rgw::bucket_index_layout_generation& current_index =
-    rgw::log_to_index_layout(latest_log);
-
+  const auto& current_index = bucket_info.get_current_index();
+  if (is_layout_indexless(current_index)) {
+    return 0;
+  }
   const uint32_t num_shards = current_index.layout.normal.num_shards;
 
   uint8_t suggest_flag = (svc.zone->get_zone().log_data ? CEPH_RGW_DIR_SUGGEST_LOG_OP : 0);
index 157f39980d21600c5d5c50815d298dd43640e650..513de3cddddf83ee8a5abbec511be10e32e9559f 100644 (file)
@@ -466,9 +466,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;