]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/services/svc_bi_rados.h
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / services / svc_bi_rados.h
CommitLineData
9f95a23c
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab ft=cpp
3
4/*
5 * Ceph - scalable distributed file system
6 *
7 * Copyright (C) 2019 Red Hat, Inc.
8 *
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
13 *
14 */
15
16
17#pragma once
18
f67539c2 19#include "rgw/rgw_datalog.h"
9f95a23c
TL
20#include "rgw/rgw_service.h"
21#include "rgw/rgw_tools.h"
22
23#include "svc_bi.h"
24#include "svc_rados.h"
25
26struct rgw_bucket_dir_header;
27
28class RGWSI_BILog_RADOS;
9f95a23c
TL
29
30#define RGW_NO_SHARD -1
31
32#define RGW_SHARDS_PRIME_0 7877
33#define RGW_SHARDS_PRIME_1 65521
34
35class RGWSI_BucketIndex_RADOS : public RGWSI_BucketIndex
36{
37 friend class RGWSI_BILog_RADOS;
38
b3b6e05e
TL
39 int open_pool(const DoutPrefixProvider *dpp,
40 const rgw_pool& pool,
9f95a23c
TL
41 RGWSI_RADOS::Pool *index_pool,
42 bool mostly_omap);
43
b3b6e05e
TL
44 int open_bucket_index_pool(const DoutPrefixProvider *dpp,
45 const RGWBucketInfo& bucket_info,
9f95a23c 46 RGWSI_RADOS::Pool *index_pool);
b3b6e05e
TL
47 int open_bucket_index_base(const DoutPrefixProvider *dpp,
48 const RGWBucketInfo& bucket_info,
9f95a23c
TL
49 RGWSI_RADOS::Pool *index_pool,
50 string *bucket_oid_base);
51
52 void get_bucket_index_object(const string& bucket_oid_base,
53 uint32_t num_shards,
54 int shard_id,
f67539c2 55 uint64_t gen_id,
9f95a23c
TL
56 string *bucket_obj);
57 int get_bucket_index_object(const string& bucket_oid_base, const string& obj_key,
f67539c2 58 uint32_t num_shards, rgw::BucketHashType hash_type,
9f95a23c
TL
59 string *bucket_obj, int *shard_id);
60
b3b6e05e
TL
61 int cls_bucket_head(const DoutPrefixProvider *dpp,
62 const RGWBucketInfo& bucket_info,
9f95a23c
TL
63 int shard_id,
64 vector<rgw_bucket_dir_header> *headers,
65 map<int, string> *bucket_instance_ids,
66 optional_yield y);
67
68public:
69
70 struct Svc {
71 RGWSI_Zone *zone{nullptr};
72 RGWSI_RADOS *rados{nullptr};
73 RGWSI_BILog_RADOS *bilog{nullptr};
f67539c2 74 RGWDataChangesLog *datalog_rados{nullptr};
9f95a23c
TL
75 } svc;
76
77 RGWSI_BucketIndex_RADOS(CephContext *cct);
78
79 void init(RGWSI_Zone *zone_svc,
80 RGWSI_RADOS *rados_svc,
81 RGWSI_BILog_RADOS *bilog_svc,
f67539c2 82 RGWDataChangesLog *datalog_rados_svc);
9f95a23c
TL
83
84 static int shards_max() {
85 return RGW_SHARDS_PRIME_1;
86 }
87
88 static int shard_id(const string& key, int max_shards) {
89 return rgw_shard_id(key, max_shards);
90 }
91
92 static uint32_t bucket_shard_index(const std::string& key,
93 int num_shards) {
94 uint32_t sid = ceph_str_hash_linux(key.c_str(), key.size());
95 uint32_t sid2 = sid ^ ((sid & 0xFF) << 24);
96 return rgw_shards_mod(sid2, num_shards);
97 }
98
b3b6e05e
TL
99 int init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info);
100 int clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info);
9f95a23c
TL
101
102
103 /* RADOS specific */
104
b3b6e05e
TL
105 int read_stats(const DoutPrefixProvider *dpp,
106 const RGWBucketInfo& bucket_info,
9f95a23c
TL
107 RGWBucketEnt *stats,
108 optional_yield y) override;
109
b3b6e05e 110 int get_reshard_status(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info,
9f95a23c
TL
111 std::list<cls_rgw_bucket_instance_entry> *status);
112
b3b6e05e 113 int handle_overwrite(const DoutPrefixProvider *dpp, const RGWBucketInfo& info,
9f95a23c
TL
114 const RGWBucketInfo& orig_info) override;
115
b3b6e05e
TL
116 int open_bucket_index_shard(const DoutPrefixProvider *dpp,
117 const RGWBucketInfo& bucket_info,
9f95a23c
TL
118 const string& obj_key,
119 RGWSI_RADOS::Obj *bucket_obj,
120 int *shard_id);
121
b3b6e05e
TL
122 int open_bucket_index_shard(const DoutPrefixProvider *dpp,
123 const RGWBucketInfo& bucket_info,
9f95a23c 124 int shard_id,
f67539c2 125 const rgw::bucket_index_layout_generation& idx_layout,
9f95a23c
TL
126 RGWSI_RADOS::Obj *bucket_obj);
127
b3b6e05e
TL
128 int open_bucket_index(const DoutPrefixProvider *dpp,
129 const RGWBucketInfo& bucket_info,
9f95a23c
TL
130 RGWSI_RADOS::Pool *index_pool,
131 string *bucket_oid);
132
b3b6e05e
TL
133 int open_bucket_index(const DoutPrefixProvider *dpp,
134 const RGWBucketInfo& bucket_info,
9f95a23c
TL
135 std::optional<int> shard_id,
136 RGWSI_RADOS::Pool *index_pool,
137 map<int, string> *bucket_objs,
138 map<int, string> *bucket_instance_ids);
139};
140
141