From: J. Eric Ivancich Date: Mon, 24 Jan 2022 21:08:01 +0000 (-0500) Subject: rgw: add streamlined ways to handle indexless buckets correctly X-Git-Tag: v18.0.0~787^2~54 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=177bb80cd58d989adbf59ea343c540abc6aaeae8;p=ceph.git 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 --- diff --git a/src/rgw/rgw_bucket_layout.h b/src/rgw/rgw_bucket_layout.h index ccc1595f8138..74d9fe12149a 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 baaa8d15dd43..711607b98eb1 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1116,6 +1116,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(); };