From: Casey Bodley Date: Tue, 18 Jan 2022 21:43:42 +0000 (-0500) Subject: rgw: use get_current_index() instead of log_to_index_layout() X-Git-Tag: v18.0.0~787^2~43 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=165eae9bb6ac3f70a001060ecc35e766213c595b;p=ceph.git rgw: use get_current_index() instead of log_to_index_layout() 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 --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index e2966c0ad1877..fbd6379d3f436 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -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 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; { diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index d411cd93c4512..2d2cf13f25301 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -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 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; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index b2caaf9972aa3..7053a5c4ea240 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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 index_oids; diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 7717619bdea58..e11185b206b18 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -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;