rgw_arn.cc
rgw_basic_types.cc
rgw_bucket.cc
+ rgw_bucket_layout.cc
rgw_bucket_sync.cc
rgw_cache.cc
rgw_common.cc
--- /dev/null
+// -*- 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.
+ *
+ */
+
+#include "rgw_bucket_layout.h"
+
+namespace rgw {
+
+void encode(const bucket_index_normal_layout& l, bufferlist& bl, uint64_t f)
+{
+ ENCODE_START(1, 1, bl);
+ encode(l.num_shards, bl);
+ encode(l.hash_type, bl);
+ ENCODE_FINISH(bl);
+}
+void decode(bucket_index_normal_layout& l, bufferlist::const_iterator& bl)
+{
+ DECODE_START(1, bl);
+ decode(l.num_shards, bl);
+ decode(l.hash_type, bl);
+ DECODE_FINISH(bl);
+}
+
+void encode(const bucket_index_layout& l, bufferlist& bl, uint64_t f)
+{
+ ENCODE_START(1, 1, bl);
+ encode(l.type, bl);
+ switch (l.type) {
+ case BucketIndexType::Normal:
+ encode(l.normal, bl);
+ break;
+ case BucketIndexType::Indexless:
+ break;
+ }
+ ENCODE_FINISH(bl);
+}
+void decode(bucket_index_layout& l, bufferlist::const_iterator& bl)
+{
+ DECODE_START(1, bl);
+ decode(l.type, bl);
+ switch (l.type) {
+ case BucketIndexType::Normal:
+ decode(l.normal, bl);
+ break;
+ case BucketIndexType::Indexless:
+ break;
+ }
+ DECODE_FINISH(bl);
+}
+
+void encode(const bucket_index_layout_generation& l, bufferlist& bl, uint64_t f)
+{
+ ENCODE_START(1, 1, bl);
+ encode(l.gen, bl);
+ encode(l.layout, bl);
+ ENCODE_FINISH(bl);
+}
+void decode(bucket_index_layout_generation& l, bufferlist::const_iterator& bl)
+{
+ DECODE_START(1, bl);
+ decode(l.gen, bl);
+ decode(l.layout, bl);
+ DECODE_FINISH(bl);
+}
+
+void encode(const BucketLayout& l, bufferlist& bl, uint64_t f)
+{
+ ENCODE_START(1, 1, bl);
+ encode(l.resharding, bl);
+ encode(l.current_index, bl);
+ encode(l.target_index, bl);
+ ENCODE_FINISH(bl);
+}
+void decode(BucketLayout& l, bufferlist::const_iterator& bl)
+{
+ DECODE_START(1, bl);
+ decode(l.resharding, bl);
+ decode(l.current_index, bl);
+ decode(l.target_index, bl);
+ DECODE_FINISH(bl);
+}
+
+} // namespace rgw
--- /dev/null
+// -*- 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 <optional>
+#include <string>
+#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
+};
+
+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 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<bucket_index_layout_generation> target_index;
+};
+
+void encode(const BucketLayout& l, bufferlist& bl, uint64_t f=0);
+void decode(BucketLayout& l, bufferlist::const_iterator& bl);
+
+} // namespace rgw
}
void RGWBucketInfo::encode(bufferlist& bl) const {
- ENCODE_START(21, 4, bl);
+ ENCODE_START(22, 4, bl);
encode(bucket, bl);
encode(owner.id, bl);
encode(flags, bl);
if (has_sync_policy) {
encode(*sync_policy, bl);
}
+ encode(layout, bl);
ENCODE_FINISH(bl);
}
void RGWBucketInfo::decode(bufferlist::const_iterator& bl) {
- DECODE_START_LEGACY_COMPAT_LEN_32(21, 4, 4, bl);
+ DECODE_START_LEGACY_COMPAT_LEN_32(22, 4, 4, bl);
decode(bucket, bl);
if (struct_v >= 2) {
string s;
if (struct_v >= 21) {
decode(sync_policy, bl);
}
+ if (struct_v >= 22) {
+ decode(layout, bl);
+ }
DECODE_FINISH(bl);
}
#include "common/ceph_crypto.h"
#include "common/random_string.h"
#include "rgw_acl.h"
+#include "rgw_bucket_layout.h"
#include "rgw_cors.h"
#include "rgw_iam_policy.h"
#include "rgw_quota.h"
RGWObjVersionTracker objv_tracker; /* we don't need to serialize this, for runtime tracking */
RGWQuotaInfo quota;
+ // layout of bucket index objects
+ rgw::BucketLayout layout;
+
// Represents the number of bucket index object shards:
// - value of 0 indicates there is no sharding (this is by default
// before this feature is implemented).