]> 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)
committerAdam C. Emerson <aemerson@redhat.com>
Tue, 1 Feb 2022 23:50:05 +0000 (18:50 -0500)
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 f5a9d572cd85aa8367dd8f5814cfe2224746c6ad..391979de2ec6235dbc2f5e2db21e27c98ee52de0 100644 (file)
@@ -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();
 };