]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add streamlined ways to handle indexless buckets correctly
authorJ. Eric Ivancich <ivancich@redhat.com>
Mon, 24 Jan 2022 21:08:01 +0000 (16:08 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 27 May 2022 19:47:33 +0000 (15:47 -0400)
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 <ivancich@redhat.com>
src/rgw/rgw_bucket_layout.h
src/rgw/rgw_common.h

index ccc1595f8138c4c6a9cfa82a0bae5b5a02a48c62..74d9fe12149a535d6d3c3133e140d4803c95a08c 100644 (file)
@@ -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
index baaa8d15dd43ff02a0b62e90a9e383c79a1747fd..711607b98eb11fc804849b49be6ee60e5031ea79 100644 (file)
@@ -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();
 };