From da25a861e30fdd04dfbbed40ef9eab7ffdd513fc Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Mon, 24 Jan 2022 16:08:01 -0500 Subject: [PATCH] rgw: add streamlined ways to handle indexless buckets correctly Determining whether a bucket is indexless starting with an RGWBucketInfo object requires traversing multiple data structures and "inside knowledge" blurring the line between interface and implementation. The same applies for retrieving the current index for non-indexless buckets. This commit adds to the RGWBucketInfo interface to make this information readily accessible. Signed-off-by: J. Eric Ivancich --- src/rgw/rgw_bucket_layout.h | 3 +++ src/rgw/rgw_common.h | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/rgw/rgw_bucket_layout.h b/src/rgw/rgw_bucket_layout.h index ccc1595f8138c..74d9fe12149a5 100644 --- a/src/rgw/rgw_bucket_layout.h +++ b/src/rgw/rgw_bucket_layout.h @@ -202,5 +202,8 @@ inline uint32_t num_shards(const bucket_index_layout_generation& index) { inline uint32_t current_num_shards(const BucketLayout& layout) { return num_shards(layout.current_index); } +inline bool is_layout_indexless(const bucket_index_layout_generation& layout) { + return layout.layout.type == BucketIndexType::Indexless; +} } // namespace rgw diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 870ea5d1c280d..9e682e2f2bc79 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1117,6 +1117,16 @@ struct RGWBucketInfo { bool empty_sync_policy() const; + bool is_indexless() const { + return rgw::is_layout_indexless(layout.current_index); + } + const rgw::bucket_index_layout_generation& get_current_index() const { + return layout.current_index; + } + rgw::bucket_index_layout_generation& get_current_index() { + return layout.current_index; + } + RGWBucketInfo(); ~RGWBucketInfo(); }; -- 2.39.5