From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/rgw/rgw_bucket_layout.h | 146 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 src/rgw/rgw_bucket_layout.h (limited to 'src/rgw/rgw_bucket_layout.h') diff --git a/src/rgw/rgw_bucket_layout.h b/src/rgw/rgw_bucket_layout.h new file mode 100644 index 000000000..a09215abc --- /dev/null +++ b/src/rgw/rgw_bucket_layout.h @@ -0,0 +1,146 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2020 Red Hat, Inc. + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#pragma once + +#include +#include +#include "include/encoding.h" + +namespace rgw { + +enum class BucketIndexType : uint8_t { + Normal, // normal hash-based sharded index layout + Indexless, // no bucket index, so listing is unsupported +}; + +enum class BucketHashType : uint8_t { + Mod, // rjenkins hash of object name, modulo num_shards +}; + +inline std::ostream& operator<<(std::ostream& out, const BucketIndexType &index_type) +{ + switch (index_type) { + case BucketIndexType::Normal: + return out << "Normal"; + case BucketIndexType::Indexless: + return out << "Indexless"; + default: + return out << "Unknown"; + } +} + +struct bucket_index_normal_layout { + uint32_t num_shards = 1; + + BucketHashType hash_type = BucketHashType::Mod; +}; + +void encode(const bucket_index_normal_layout& l, bufferlist& bl, uint64_t f=0); +void decode(bucket_index_normal_layout& l, bufferlist::const_iterator& bl); + + +struct bucket_index_layout { + BucketIndexType type = BucketIndexType::Normal; + + // TODO: variant of layout types? + bucket_index_normal_layout normal; +}; + +void encode(const bucket_index_layout& l, bufferlist& bl, uint64_t f=0); +void decode(bucket_index_layout& l, bufferlist::const_iterator& bl); + + +struct bucket_index_layout_generation { + uint64_t gen = 0; + bucket_index_layout layout; +}; + +void encode(const bucket_index_layout_generation& l, bufferlist& bl, uint64_t f=0); +void decode(bucket_index_layout_generation& l, bufferlist::const_iterator& bl); + + +enum class BucketLogType : uint8_t { + // colocated with bucket index, so the log layout matches the index layout + InIndex, +}; + +inline std::ostream& operator<<(std::ostream& out, const BucketLogType &log_type) +{ + switch (log_type) { + case BucketLogType::InIndex: + return out << "InIndex"; + default: + return out << "Unknown"; + } +} + +struct bucket_index_log_layout { + uint64_t gen = 0; + bucket_index_normal_layout layout; +}; + +void encode(const bucket_index_log_layout& l, bufferlist& bl, uint64_t f=0); +void decode(bucket_index_log_layout& l, bufferlist::const_iterator& bl); + +struct bucket_log_layout { + BucketLogType type = BucketLogType::InIndex; + + bucket_index_log_layout in_index; +}; + +void encode(const bucket_log_layout& l, bufferlist& bl, uint64_t f=0); +void decode(bucket_log_layout& l, bufferlist::const_iterator& bl); + + +struct bucket_log_layout_generation { + uint64_t gen = 0; + bucket_log_layout layout; +}; + +void encode(const bucket_log_layout_generation& l, bufferlist& bl, uint64_t f=0); +void decode(bucket_log_layout_generation& l, bufferlist::const_iterator& bl); + +// return a log layout that shares its layout with the index +inline bucket_log_layout_generation log_layout_from_index( + uint64_t gen, const bucket_index_normal_layout& index) +{ + return {gen, {BucketLogType::InIndex, {gen, index}}}; +} + +enum class BucketReshardState : uint8_t { + None, + InProgress, +}; + +// describes the layout of bucket index objects +struct BucketLayout { + BucketReshardState resharding = BucketReshardState::None; + + // current bucket index layout + bucket_index_layout_generation current_index; + + // target index layout of a resharding operation + std::optional target_index; + + // history of untrimmed bucket log layout generations, with the current + // generation at the back() + std::vector logs; +}; + +void encode(const BucketLayout& l, bufferlist& bl, uint64_t f=0); +void decode(BucketLayout& l, bufferlist::const_iterator& bl); + +} // namespace rgw -- cgit v1.2.3