]>
Commit | Line | Data |
---|---|---|
1e59de90 | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
f67539c2 TL |
2 | // vim: ts=8 sw=2 smarttab ft=cpp |
3 | ||
4 | /* | |
5 | * Ceph - scalable distributed file system | |
6 | * | |
7 | * Copyright (C) 2020 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 | #pragma once | |
17 | ||
1e59de90 | 18 | #include "rgw_sal_store.h" |
f67539c2 | 19 | #include "rgw_rados.h" |
20effc67 TL |
20 | #include "rgw_notify.h" |
21 | #include "rgw_oidc_provider.h" | |
22 | #include "rgw_role.h" | |
23 | #include "rgw_multi.h" | |
24 | #include "rgw_putobj_processor.h" | |
25 | #include "services/svc_tier_rados.h" | |
f67539c2 TL |
26 | #include "cls/lock/cls_lock_client.h" |
27 | ||
28 | namespace rgw { namespace sal { | |
29 | ||
20effc67 TL |
30 | class RadosMultipartUpload; |
31 | ||
32 | class RadosCompletions : public Completions { | |
33 | public: | |
34 | std::list<librados::AioCompletion*> handles; | |
35 | RadosCompletions() {} | |
36 | ~RadosCompletions() = default; | |
37 | virtual int drain() override; | |
38 | }; | |
f67539c2 | 39 | |
1e59de90 TL |
40 | class RadosPlacementTier: public StorePlacementTier { |
41 | RadosStore* store; | |
42 | RGWZoneGroupPlacementTier tier; | |
43 | public: | |
44 | RadosPlacementTier(RadosStore* _store, const RGWZoneGroupPlacementTier& _tier) : store(_store), tier(_tier) {} | |
45 | virtual ~RadosPlacementTier() = default; | |
46 | ||
47 | virtual const std::string& get_tier_type() { return tier.tier_type; } | |
48 | virtual const std::string& get_storage_class() { return tier.storage_class; } | |
49 | virtual bool retain_head_object() { return tier.retain_head_object; } | |
50 | RGWZoneGroupPlacementTier& get_rt() { return tier; } | |
51 | }; | |
52 | ||
53 | class RadosZoneGroup : public StoreZoneGroup { | |
54 | RadosStore* store; | |
55 | const RGWZoneGroup group; | |
56 | std::string empty; | |
57 | public: | |
58 | RadosZoneGroup(RadosStore* _store, const RGWZoneGroup& _group) : store(_store), group(_group) {} | |
59 | virtual ~RadosZoneGroup() = default; | |
60 | ||
61 | virtual const std::string& get_id() const override { return group.get_id(); }; | |
62 | virtual const std::string& get_name() const override { return group.get_name(); }; | |
63 | virtual int equals(const std::string& other_zonegroup) const override { | |
64 | return group.equals(other_zonegroup); | |
65 | }; | |
66 | /** Get the endpoint from zonegroup, or from master zone if not set */ | |
67 | virtual const std::string& get_endpoint() const override; | |
68 | virtual bool placement_target_exists(std::string& target) const override; | |
69 | virtual bool is_master_zonegroup() const override { | |
70 | return group.is_master_zonegroup(); | |
71 | }; | |
72 | virtual const std::string& get_api_name() const override { return group.api_name; }; | |
aee94f69 | 73 | virtual void get_placement_target_names(std::set<std::string>& names) const override; |
1e59de90 TL |
74 | virtual const std::string& get_default_placement_name() const override { |
75 | return group.default_placement.name; }; | |
76 | virtual int get_hostnames(std::list<std::string>& names) const override { | |
77 | names = group.hostnames; | |
78 | return 0; | |
79 | }; | |
80 | virtual int get_s3website_hostnames(std::list<std::string>& names) const override { | |
81 | names = group.hostnames_s3website; | |
82 | return 0; | |
83 | }; | |
84 | virtual int get_zone_count() const override { | |
85 | return group.zones.size(); | |
86 | } | |
87 | virtual int get_placement_tier(const rgw_placement_rule& rule, std::unique_ptr<PlacementTier>* tier); | |
88 | virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) override; | |
89 | virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override; | |
90 | virtual int list_zones(std::list<std::string>& zone_ids) override; | |
05a536ef TL |
91 | bool supports(std::string_view feature) const override { |
92 | return group.supports(feature); | |
93 | } | |
1e59de90 TL |
94 | virtual std::unique_ptr<ZoneGroup> clone() override { |
95 | return std::make_unique<RadosZoneGroup>(store, group); | |
96 | } | |
97 | const RGWZoneGroup& get_group() const { return group; } | |
98 | }; | |
99 | ||
100 | class RadosZone : public StoreZone { | |
101 | protected: | |
102 | RadosStore* store; | |
103 | std::unique_ptr<ZoneGroup> group; | |
104 | RGWZone rgw_zone; | |
105 | bool local_zone{false}; | |
106 | public: | |
107 | RadosZone(RadosStore* _store, std::unique_ptr<ZoneGroup> _zg) : store(_store), group(std::move(_zg)), local_zone(true) {} | |
108 | RadosZone(RadosStore* _store, std::unique_ptr<ZoneGroup> _zg, RGWZone& z) : store(_store), group(std::move(_zg)), rgw_zone(z) {} | |
109 | ~RadosZone() = default; | |
110 | ||
111 | virtual std::unique_ptr<Zone> clone() override; | |
112 | virtual ZoneGroup& get_zonegroup() override { return *(group.get()); } | |
113 | virtual const std::string& get_id() override; | |
114 | virtual const std::string& get_name() const override; | |
115 | virtual bool is_writeable() override; | |
116 | virtual bool get_redirect_endpoint(std::string* endpoint) override; | |
117 | virtual bool has_zonegroup_api(const std::string& api) const override; | |
118 | virtual const std::string& get_current_period_id() override; | |
119 | virtual const RGWAccessKey& get_system_key() override; | |
120 | virtual const std::string& get_realm_name() override; | |
121 | virtual const std::string& get_realm_id() override; | |
122 | virtual const std::string_view get_tier_type() override; | |
123 | virtual RGWBucketSyncPolicyHandlerRef get_sync_policy_handler() override; | |
124 | }; | |
125 | ||
126 | class RadosStore : public StoreDriver { | |
127 | private: | |
128 | RGWRados* rados; | |
129 | RGWUserCtl* user_ctl; | |
130 | std::unique_ptr<RadosZone> zone; | |
131 | std::string topics_oid(const std::string& tenant) const; | |
132 | ||
133 | public: | |
134 | RadosStore() | |
135 | : rados(nullptr) { | |
136 | } | |
137 | ~RadosStore() { | |
138 | delete rados; | |
139 | } | |
140 | ||
141 | virtual int initialize(CephContext *cct, const DoutPrefixProvider *dpp) override; | |
142 | virtual const std::string get_name() const override { | |
143 | return "rados"; | |
144 | } | |
145 | virtual std::string get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y) override; | |
146 | virtual std::unique_ptr<User> get_user(const rgw_user& u) override; | |
147 | virtual int get_user_by_access_key(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y, std::unique_ptr<User>* user) override; | |
148 | virtual int get_user_by_email(const DoutPrefixProvider* dpp, const std::string& email, optional_yield y, std::unique_ptr<User>* user) override; | |
149 | virtual int get_user_by_swift(const DoutPrefixProvider* dpp, const std::string& user_str, optional_yield y, std::unique_ptr<User>* user) override; | |
150 | virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) override; | |
151 | virtual int get_bucket(const DoutPrefixProvider* dpp, User* u, const rgw_bucket& b, std::unique_ptr<Bucket>* bucket, optional_yield y) override; | |
152 | virtual int get_bucket(User* u, const RGWBucketInfo& i, std::unique_ptr<Bucket>* bucket) override; | |
153 | virtual int get_bucket(const DoutPrefixProvider* dpp, User* u, const std::string& tenant, const std::string&name, std::unique_ptr<Bucket>* bucket, optional_yield y) override; | |
154 | virtual bool is_meta_master() override; | |
155 | virtual int forward_request_to_master(const DoutPrefixProvider *dpp, User* user, obj_version* objv, | |
156 | bufferlist& in_data, JSONParser* jp, req_info& info, | |
157 | optional_yield y) override; | |
158 | virtual int forward_iam_request_to_master(const DoutPrefixProvider *dpp, const RGWAccessKey& key, obj_version* objv, | |
159 | bufferlist& in_data, | |
160 | RGWXMLDecoder::XMLParser* parser, req_info& info, | |
161 | optional_yield y) override; | |
162 | virtual Zone* get_zone() { return zone.get(); } | |
163 | virtual std::string zone_unique_id(uint64_t unique_num) override; | |
164 | virtual std::string zone_unique_trans_id(const uint64_t unique_num) override; | |
165 | virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override; | |
166 | virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list<std::string>& zone_ids) override; | |
167 | virtual int cluster_stat(RGWClusterStat& stats) override; | |
168 | virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override; | |
169 | virtual std::unique_ptr<Completions> get_completions(void) override; | |
170 | virtual std::unique_ptr<Notification> get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, req_state* s, rgw::notify::EventType event_type, optional_yield y, const std::string* object_name=nullptr) override; | |
171 | virtual std::unique_ptr<Notification> get_notification( | |
172 | const DoutPrefixProvider* dpp, rgw::sal::Object* obj, rgw::sal::Object* src_obj, | |
173 | rgw::notify::EventType event_type, rgw::sal::Bucket* _bucket, std::string& _user_id, std::string& _user_tenant, | |
174 | std::string& _req_id, optional_yield y) override; | |
175 | int read_topics(const std::string& tenant, rgw_pubsub_topics& topics, RGWObjVersionTracker* objv_tracker, | |
176 | optional_yield y, const DoutPrefixProvider *dpp) override; | |
177 | int write_topics(const std::string& tenant, const rgw_pubsub_topics& topics, RGWObjVersionTracker* objv_tracker, | |
178 | optional_yield y, const DoutPrefixProvider *dpp) override; | |
179 | int remove_topics(const std::string& tenant, RGWObjVersionTracker* objv_tracker, | |
180 | optional_yield y, const DoutPrefixProvider *dpp) override; | |
181 | virtual RGWLC* get_rgwlc(void) override { return rados->get_lc(); } | |
182 | virtual RGWCoroutinesManagerRegistry* get_cr_registry() override { return rados->get_cr_registry(); } | |
183 | ||
184 | virtual int log_usage(const DoutPrefixProvider *dpp, std::map<rgw_user_bucket, RGWUsageBatch>& usage_info) override; | |
185 | virtual int log_op(const DoutPrefixProvider *dpp, std::string& oid, bufferlist& bl) override; | |
186 | virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type, | |
187 | const std::map<std::string, std::string>& meta) override; | |
188 | virtual void get_quota(RGWQuota& quota) override; | |
189 | virtual void get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit) override; | |
190 | virtual int set_buckets_enabled(const DoutPrefixProvider* dpp, std::vector<rgw_bucket>& buckets, bool enabled) override; | |
191 | virtual int get_sync_policy_handler(const DoutPrefixProvider* dpp, | |
192 | std::optional<rgw_zone_id> zone, | |
193 | std::optional<rgw_bucket> bucket, | |
194 | RGWBucketSyncPolicyHandlerRef* phandler, | |
195 | optional_yield y) override; | |
196 | virtual RGWDataSyncStatusManager* get_data_sync_manager(const rgw_zone_id& source_zone) override; | |
197 | virtual void wakeup_meta_sync_shards(std::set<int>& shard_ids) override { rados->wakeup_meta_sync_shards(shard_ids); } | |
198 | virtual void wakeup_data_sync_shards(const DoutPrefixProvider *dpp, const rgw_zone_id& source_zone, boost::container::flat_map<int, boost::container::flat_set<rgw_data_notify_entry>>& shard_ids) override { rados->wakeup_data_sync_shards(dpp, source_zone, shard_ids); } | |
199 | virtual int clear_usage(const DoutPrefixProvider *dpp) override { return rados->clear_usage(dpp); } | |
200 | virtual int read_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, | |
201 | uint32_t max_entries, bool* is_truncated, | |
202 | RGWUsageIter& usage_iter, | |
203 | std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) override; | |
204 | virtual int trim_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) override; | |
205 | virtual int get_config_key_val(std::string name, bufferlist* bl) override; | |
206 | virtual int meta_list_keys_init(const DoutPrefixProvider *dpp, const std::string& section, const std::string& marker, void** phandle) override; | |
207 | virtual int meta_list_keys_next(const DoutPrefixProvider *dpp, void* handle, int max, std::list<std::string>& keys, bool* truncated) override; | |
208 | virtual void meta_list_keys_complete(void* handle) override; | |
209 | virtual std::string meta_get_marker(void* handle) override; | |
210 | virtual int meta_remove(const DoutPrefixProvider* dpp, std::string& metadata_key, optional_yield y) override; | |
211 | virtual const RGWSyncModuleInstanceRef& get_sync_module() { return rados->get_sync_module(); } | |
212 | virtual std::string get_host_id() { return rados->host_id; } | |
213 | virtual std::unique_ptr<LuaManager> get_lua_manager() override; | |
214 | virtual std::unique_ptr<RGWRole> get_role(std::string name, | |
215 | std::string tenant, | |
216 | std::string path="", | |
217 | std::string trust_policy="", | |
218 | std::string max_session_duration_str="", | |
219 | std::multimap<std::string,std::string> tags={}) override; | |
220 | virtual std::unique_ptr<RGWRole> get_role(std::string id) override; | |
221 | virtual std::unique_ptr<RGWRole> get_role(const RGWRoleInfo& info) override; | |
222 | virtual int get_roles(const DoutPrefixProvider *dpp, | |
223 | optional_yield y, | |
224 | const std::string& path_prefix, | |
225 | const std::string& tenant, | |
226 | std::vector<std::unique_ptr<RGWRole>>& roles) override; | |
227 | virtual std::unique_ptr<RGWOIDCProvider> get_oidc_provider() override; | |
228 | virtual int get_oidc_providers(const DoutPrefixProvider *dpp, | |
229 | const std::string& tenant, | |
230 | std::vector<std::unique_ptr<RGWOIDCProvider>>& providers) override; | |
231 | virtual std::unique_ptr<Writer> get_append_writer(const DoutPrefixProvider *dpp, | |
232 | optional_yield y, | |
233 | rgw::sal::Object* obj, | |
234 | const rgw_user& owner, | |
235 | const rgw_placement_rule *ptail_placement_rule, | |
236 | const std::string& unique_tag, | |
237 | uint64_t position, | |
238 | uint64_t *cur_accounted_size) override; | |
239 | virtual std::unique_ptr<Writer> get_atomic_writer(const DoutPrefixProvider *dpp, | |
240 | optional_yield y, | |
241 | rgw::sal::Object* obj, | |
242 | const rgw_user& owner, | |
243 | const rgw_placement_rule *ptail_placement_rule, | |
244 | uint64_t olh_epoch, | |
245 | const std::string& unique_tag) override; | |
246 | virtual const std::string& get_compression_type(const rgw_placement_rule& rule) override; | |
247 | virtual bool valid_placement(const rgw_placement_rule& rule) override; | |
248 | ||
249 | virtual void finalize(void) override; | |
250 | ||
251 | virtual CephContext* ctx(void) override { return rados->ctx(); } | |
252 | ||
253 | virtual void register_admin_apis(RGWRESTMgr* mgr) override; | |
254 | ||
255 | /* Unique to RadosStore */ | |
256 | int get_obj_head_ioctx(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw_obj& obj, | |
257 | librados::IoCtx* ioctx); | |
258 | int delete_raw_obj(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj); | |
259 | int delete_raw_obj_aio(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, Completions* aio); | |
260 | void get_raw_obj(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj* raw_obj); | |
261 | int get_raw_chunk_size(const DoutPrefixProvider* dpp, const rgw_raw_obj& obj, uint64_t* chunk_size); | |
262 | ||
263 | void setRados(RGWRados * st) { rados = st; } | |
264 | RGWRados* getRados(void) { return rados; } | |
265 | ||
266 | RGWServices* svc() { return &rados->svc; } | |
267 | const RGWServices* svc() const { return &rados->svc; } | |
268 | RGWCtl* ctl() { return &rados->ctl; } | |
269 | const RGWCtl* ctl() const { return &rados->ctl; } | |
270 | ||
271 | void setUserCtl(RGWUserCtl *_ctl) { user_ctl = _ctl; } | |
272 | }; | |
273 | ||
274 | class RadosUser : public StoreUser { | |
f67539c2 | 275 | private: |
20effc67 | 276 | RadosStore* store; |
f67539c2 TL |
277 | |
278 | public: | |
1e59de90 TL |
279 | RadosUser(RadosStore *_st, const rgw_user& _u) : StoreUser(_u), store(_st) { } |
280 | RadosUser(RadosStore *_st, const RGWUserInfo& _i) : StoreUser(_i), store(_st) { } | |
20effc67 TL |
281 | RadosUser(RadosStore *_st) : store(_st) { } |
282 | RadosUser(RadosUser& _o) = default; | |
20effc67 TL |
283 | |
284 | virtual std::unique_ptr<User> clone() override { | |
285 | return std::unique_ptr<User>(new RadosUser(*this)); | |
286 | } | |
287 | int list_buckets(const DoutPrefixProvider* dpp, const std::string& marker, const std::string& end_marker, | |
288 | uint64_t max, bool need_stats, BucketList& buckets, | |
f67539c2 | 289 | optional_yield y) override; |
20effc67 TL |
290 | virtual int create_bucket(const DoutPrefixProvider* dpp, |
291 | const rgw_bucket& b, | |
292 | const std::string& zonegroup_id, | |
293 | rgw_placement_rule& placement_rule, | |
294 | std::string& swift_ver_location, | |
295 | const RGWQuotaInfo * pquota_info, | |
296 | const RGWAccessControlPolicy& policy, | |
297 | Attrs& attrs, | |
298 | RGWBucketInfo& info, | |
299 | obj_version& ep_objv, | |
300 | bool exclusive, | |
301 | bool obj_lock_enabled, | |
302 | bool* existed, | |
303 | req_info& req_info, | |
304 | std::unique_ptr<Bucket>* bucket, | |
305 | optional_yield y) override; | |
306 | virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y) override; | |
307 | virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y) override; | |
308 | virtual int read_stats(const DoutPrefixProvider *dpp, | |
309 | optional_yield y, RGWStorageStats* stats, | |
310 | ceph::real_time* last_stats_sync = nullptr, | |
311 | ceph::real_time* last_stats_update = nullptr) override; | |
312 | virtual int read_stats_async(const DoutPrefixProvider *dpp, RGWGetUserStats_CB* cb) override; | |
313 | virtual int complete_flush_stats(const DoutPrefixProvider *dpp, optional_yield y) override; | |
314 | virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, | |
315 | bool* is_truncated, RGWUsageIter& usage_iter, | |
316 | std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) override; | |
317 | virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) override; | |
f67539c2 | 318 | |
20effc67 TL |
319 | virtual int load_user(const DoutPrefixProvider* dpp, optional_yield y) override; |
320 | virtual int store_user(const DoutPrefixProvider* dpp, optional_yield y, bool exclusive, RGWUserInfo* old_info = nullptr) override; | |
321 | virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) override; | |
1e59de90 | 322 | virtual int verify_mfa(const std::string& mfa_str, bool* verified, const DoutPrefixProvider* dpp, optional_yield y) override; |
f67539c2 | 323 | |
20effc67 | 324 | friend class RadosBucket; |
f67539c2 TL |
325 | }; |
326 | ||
1e59de90 | 327 | class RadosObject : public StoreObject { |
f67539c2 | 328 | private: |
20effc67 | 329 | RadosStore* store; |
f67539c2 | 330 | RGWAccessControlPolicy acls; |
1e59de90 TL |
331 | RGWObjManifest *manifest{nullptr}; |
332 | RGWObjectCtx* rados_ctx; | |
333 | bool rados_ctx_owned; | |
f67539c2 TL |
334 | |
335 | public: | |
336 | ||
337 | struct RadosReadOp : public ReadOp { | |
338 | private: | |
20effc67 | 339 | RadosObject* source; |
f67539c2 TL |
340 | RGWObjectCtx* rctx; |
341 | RGWRados::Object op_target; | |
342 | RGWRados::Object::Read parent_op; | |
343 | ||
344 | public: | |
20effc67 | 345 | RadosReadOp(RadosObject *_source, RGWObjectCtx *_rctx); |
f67539c2 | 346 | |
20effc67 | 347 | virtual int prepare(optional_yield y, const DoutPrefixProvider* dpp) override; |
1e59de90 TL |
348 | |
349 | /* | |
350 | * Both `read` and `iterate` read up through index `end` | |
351 | * *inclusive*. The number of bytes that could be returned is | |
352 | * `end - ofs + 1`. | |
353 | */ | |
354 | virtual int read(int64_t ofs, int64_t end, | |
355 | bufferlist& bl, optional_yield y, | |
356 | const DoutPrefixProvider* dpp) override; | |
357 | virtual int iterate(const DoutPrefixProvider* dpp, | |
358 | int64_t ofs, int64_t end, | |
359 | RGWGetDataCB* cb, optional_yield y) override; | |
360 | ||
361 | virtual int get_attr(const DoutPrefixProvider* dpp, const char* name, bufferlist& dest, optional_yield y) override; | |
f67539c2 TL |
362 | }; |
363 | ||
20effc67 | 364 | struct RadosDeleteOp : public DeleteOp { |
f67539c2 | 365 | private: |
20effc67 | 366 | RadosObject* source; |
f67539c2 | 367 | RGWRados::Object op_target; |
20effc67 | 368 | RGWRados::Object::Delete parent_op; |
f67539c2 TL |
369 | |
370 | public: | |
1e59de90 | 371 | RadosDeleteOp(RadosObject* _source); |
f67539c2 | 372 | |
20effc67 | 373 | virtual int delete_obj(const DoutPrefixProvider* dpp, optional_yield y) override; |
f67539c2 TL |
374 | }; |
375 | ||
20effc67 | 376 | RadosObject(RadosStore *_st, const rgw_obj_key& _k) |
1e59de90 | 377 | : StoreObject(_k), |
f67539c2 | 378 | store(_st), |
1e59de90 TL |
379 | acls(), |
380 | rados_ctx(new RGWObjectCtx(dynamic_cast<Driver*>(store))), | |
381 | rados_ctx_owned(true) { | |
f67539c2 | 382 | } |
20effc67 | 383 | RadosObject(RadosStore *_st, const rgw_obj_key& _k, Bucket* _b) |
1e59de90 | 384 | : StoreObject(_k, _b), |
f67539c2 | 385 | store(_st), |
1e59de90 TL |
386 | acls(), |
387 | rados_ctx(new RGWObjectCtx(dynamic_cast<Driver*>(store))) , | |
388 | rados_ctx_owned(true) { | |
389 | } | |
390 | RadosObject(RadosObject& _o) : StoreObject(_o) { | |
391 | store = _o.store; | |
392 | acls = _o.acls; | |
393 | manifest = _o.manifest; | |
394 | rados_ctx = _o.rados_ctx; | |
395 | rados_ctx_owned = false; | |
f67539c2 | 396 | } |
20effc67 TL |
397 | |
398 | virtual ~RadosObject(); | |
399 | ||
1e59de90 TL |
400 | virtual void invalidate() override { |
401 | StoreObject::invalidate(); | |
402 | rados_ctx->invalidate(get_obj()); | |
403 | } | |
404 | virtual int delete_object(const DoutPrefixProvider* dpp, | |
20effc67 TL |
405 | optional_yield y, bool prevent_versioning) override; |
406 | virtual int delete_obj_aio(const DoutPrefixProvider* dpp, RGWObjState* astate, Completions* aio, | |
407 | bool keep_index_consistent, optional_yield y) override; | |
1e59de90 | 408 | virtual int copy_object(User* user, |
20effc67 TL |
409 | req_info* info, const rgw_zone_id& source_zone, |
410 | rgw::sal::Object* dest_object, rgw::sal::Bucket* dest_bucket, | |
411 | rgw::sal::Bucket* src_bucket, | |
f67539c2 | 412 | const rgw_placement_rule& dest_placement, |
20effc67 TL |
413 | ceph::real_time* src_mtime, ceph::real_time* mtime, |
414 | const ceph::real_time* mod_ptr, const ceph::real_time* unmod_ptr, | |
f67539c2 | 415 | bool high_precision_time, |
20effc67 TL |
416 | const char* if_match, const char* if_nomatch, |
417 | AttrsMod attrs_mod, bool copy_if_newer, Attrs& attrs, | |
f67539c2 TL |
418 | RGWObjCategory category, uint64_t olh_epoch, |
419 | boost::optional<ceph::real_time> delete_at, | |
20effc67 TL |
420 | std::string* version_id, std::string* tag, std::string* etag, |
421 | void (*progress_cb)(off_t, void *), void* progress_data, | |
422 | const DoutPrefixProvider* dpp, optional_yield y) override; | |
423 | virtual RGWAccessControlPolicy& get_acl(void) override { return acls; } | |
424 | virtual int set_acl(const RGWAccessControlPolicy& acl) override { acls = acl; return 0; } | |
1e59de90 TL |
425 | virtual void set_atomic() override { |
426 | rados_ctx->set_atomic(state.obj); | |
427 | StoreObject::set_atomic(); | |
428 | } | |
429 | virtual void set_prefetch_data() override { | |
430 | rados_ctx->set_prefetch_data(state.obj); | |
431 | StoreObject::set_prefetch_data(); | |
432 | } | |
433 | virtual void set_compressed() override { | |
434 | rados_ctx->set_compressed(state.obj); | |
435 | StoreObject::set_compressed(); | |
436 | } | |
437 | ||
438 | virtual int get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **state, optional_yield y, bool follow_olh = true) override; | |
439 | virtual int set_obj_attrs(const DoutPrefixProvider* dpp, Attrs* setattrs, Attrs* delattrs, optional_yield y) override; | |
440 | virtual int get_obj_attrs(optional_yield y, const DoutPrefixProvider* dpp, rgw_obj* target_obj = NULL) override; | |
441 | virtual int modify_obj_attrs(const char* attr_name, bufferlist& attr_val, optional_yield y, const DoutPrefixProvider* dpp) override; | |
442 | virtual int delete_obj_attrs(const DoutPrefixProvider* dpp, const char* attr_name, optional_yield y) override; | |
f67539c2 TL |
443 | virtual bool is_expired() override; |
444 | virtual void gen_rand_obj_instance_name() override; | |
20effc67 TL |
445 | void get_raw_obj(rgw_raw_obj* raw_obj); |
446 | virtual std::unique_ptr<Object> clone() override { | |
447 | return std::unique_ptr<Object>(new RadosObject(*this)); | |
f67539c2 | 448 | } |
1e59de90 TL |
449 | virtual std::unique_ptr<MPSerializer> get_serializer(const DoutPrefixProvider *dpp, |
450 | const std::string& lock_name) override; | |
451 | virtual int transition(Bucket* bucket, | |
f67539c2 TL |
452 | const rgw_placement_rule& placement_rule, |
453 | const real_time& mtime, | |
454 | uint64_t olh_epoch, | |
20effc67 | 455 | const DoutPrefixProvider* dpp, |
f67539c2 | 456 | optional_yield y) override; |
1e59de90 TL |
457 | virtual int transition_to_cloud(Bucket* bucket, |
458 | rgw::sal::PlacementTier* tier, | |
459 | rgw_bucket_dir_entry& o, | |
460 | std::set<std::string>& cloud_targets, | |
461 | CephContext* cct, | |
462 | bool update_object, | |
463 | const DoutPrefixProvider* dpp, | |
464 | optional_yield y) override; | |
f67539c2 | 465 | virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) override; |
1e59de90 | 466 | virtual int dump_obj_layout(const DoutPrefixProvider *dpp, optional_yield y, Formatter* f) override; |
f67539c2 TL |
467 | |
468 | /* Swift versioning */ | |
1e59de90 | 469 | virtual int swift_versioning_restore(bool& restored, |
20effc67 | 470 | const DoutPrefixProvider* dpp) override; |
1e59de90 | 471 | virtual int swift_versioning_copy(const DoutPrefixProvider* dpp, |
f67539c2 TL |
472 | optional_yield y) override; |
473 | ||
474 | /* OPs */ | |
1e59de90 TL |
475 | virtual std::unique_ptr<ReadOp> get_read_op() override; |
476 | virtual std::unique_ptr<DeleteOp> get_delete_op() override; | |
f67539c2 TL |
477 | |
478 | /* OMAP */ | |
20effc67 TL |
479 | virtual int omap_get_vals(const DoutPrefixProvider *dpp, const std::string& marker, uint64_t count, |
480 | std::map<std::string, bufferlist> *m, | |
481 | bool* pmore, optional_yield y) override; | |
482 | virtual int omap_get_all(const DoutPrefixProvider *dpp, std::map<std::string, bufferlist> *m, | |
483 | optional_yield y) override; | |
b3b6e05e | 484 | virtual int omap_get_vals_by_keys(const DoutPrefixProvider *dpp, const std::string& oid, |
f67539c2 | 485 | const std::set<std::string>& keys, |
20effc67 | 486 | Attrs* vals) override; |
b3b6e05e | 487 | virtual int omap_set_val_by_key(const DoutPrefixProvider *dpp, const std::string& key, bufferlist& val, |
f67539c2 | 488 | bool must_exist, optional_yield y) override; |
39ae355f | 489 | virtual int chown(User& new_user, const DoutPrefixProvider* dpp, optional_yield y) override; |
f67539c2 | 490 | |
20effc67 TL |
491 | /* Internal to RadosStore */ |
492 | int get_max_chunk_size(const DoutPrefixProvider* dpp, | |
493 | rgw_placement_rule placement_rule, | |
494 | uint64_t* max_chunk_size, | |
495 | uint64_t* alignment = nullptr); | |
496 | void get_max_aligned_size(uint64_t size, uint64_t alignment, uint64_t* max_size); | |
497 | void raw_obj_to_obj(const rgw_raw_obj& raw_obj); | |
1e59de90 TL |
498 | int write_cloud_tier(const DoutPrefixProvider* dpp, |
499 | optional_yield y, | |
500 | uint64_t olh_epoch, | |
501 | rgw::sal::PlacementTier* tier, | |
502 | bool is_multipart_upload, | |
503 | rgw_placement_rule& target_placement, | |
504 | Object* head_obj); | |
505 | RGWObjManifest* get_manifest() { return manifest; } | |
506 | RGWObjectCtx& get_ctx() { return *rados_ctx; } | |
20effc67 | 507 | |
f67539c2 | 508 | private: |
20effc67 | 509 | int read_attrs(const DoutPrefixProvider* dpp, RGWRados::Object::Read &read_op, optional_yield y, rgw_obj* target_obj = nullptr); |
f67539c2 TL |
510 | }; |
511 | ||
1e59de90 | 512 | class RadosBucket : public StoreBucket { |
f67539c2 | 513 | private: |
20effc67 | 514 | RadosStore* store; |
f67539c2 | 515 | RGWAccessControlPolicy acls; |
1e59de90 | 516 | std::string topics_oid() const; |
f67539c2 TL |
517 | |
518 | public: | |
20effc67 | 519 | RadosBucket(RadosStore *_st) |
f67539c2 TL |
520 | : store(_st), |
521 | acls() { | |
522 | } | |
523 | ||
20effc67 | 524 | RadosBucket(RadosStore *_st, User* _u) |
1e59de90 | 525 | : StoreBucket(_u), |
20effc67 TL |
526 | store(_st), |
527 | acls() { | |
528 | } | |
529 | ||
530 | RadosBucket(RadosStore *_st, const rgw_bucket& _b) | |
1e59de90 | 531 | : StoreBucket(_b), |
f67539c2 TL |
532 | store(_st), |
533 | acls() { | |
534 | } | |
535 | ||
20effc67 | 536 | RadosBucket(RadosStore *_st, const RGWBucketEnt& _e) |
1e59de90 | 537 | : StoreBucket(_e), |
f67539c2 TL |
538 | store(_st), |
539 | acls() { | |
540 | } | |
541 | ||
20effc67 | 542 | RadosBucket(RadosStore *_st, const RGWBucketInfo& _i) |
1e59de90 | 543 | : StoreBucket(_i), |
f67539c2 TL |
544 | store(_st), |
545 | acls() { | |
546 | } | |
547 | ||
20effc67 | 548 | RadosBucket(RadosStore *_st, const rgw_bucket& _b, User* _u) |
1e59de90 | 549 | : StoreBucket(_b, _u), |
f67539c2 TL |
550 | store(_st), |
551 | acls() { | |
552 | } | |
553 | ||
20effc67 | 554 | RadosBucket(RadosStore *_st, const RGWBucketEnt& _e, User* _u) |
1e59de90 | 555 | : StoreBucket(_e, _u), |
f67539c2 TL |
556 | store(_st), |
557 | acls() { | |
558 | } | |
559 | ||
20effc67 | 560 | RadosBucket(RadosStore *_st, const RGWBucketInfo& _i, User* _u) |
1e59de90 | 561 | : StoreBucket(_i, _u), |
f67539c2 TL |
562 | store(_st), |
563 | acls() { | |
564 | } | |
565 | ||
20effc67 | 566 | virtual ~RadosBucket(); |
20effc67 TL |
567 | virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) override; |
568 | virtual int list(const DoutPrefixProvider* dpp, ListParams&, int, ListResults&, optional_yield y) override; | |
569 | virtual int remove_bucket(const DoutPrefixProvider* dpp, bool delete_children, bool forward_to_master, req_info* req_info, optional_yield y) override; | |
570 | virtual int remove_bucket_bypass_gc(int concurrent_max, bool | |
571 | keep_index_consistent, | |
572 | optional_yield y, const | |
573 | DoutPrefixProvider *dpp) override; | |
574 | virtual RGWAccessControlPolicy& get_acl(void) override { return acls; } | |
575 | virtual int set_acl(const DoutPrefixProvider* dpp, RGWAccessControlPolicy& acl, optional_yield y) override; | |
576 | virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y, bool get_stats = false) override; | |
1e59de90 TL |
577 | virtual int read_stats(const DoutPrefixProvider *dpp, |
578 | const bucket_index_layout_generation& idx_layout, | |
579 | int shard_id, std::string* bucket_ver, std::string* master_ver, | |
580 | std::map<RGWObjCategory, RGWStorageStats>& stats, | |
581 | std::string* max_marker = nullptr, | |
582 | bool* syncstopped = nullptr) override; | |
583 | virtual int read_stats_async(const DoutPrefixProvider *dpp, | |
584 | const bucket_index_layout_generation& idx_layout, | |
585 | int shard_id, RGWGetBucketStats_CB* ctx) override; | |
b3b6e05e | 586 | virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) override; |
20effc67 TL |
587 | virtual int update_container_stats(const DoutPrefixProvider* dpp) override; |
588 | virtual int check_bucket_shards(const DoutPrefixProvider* dpp) override; | |
39ae355f | 589 | virtual int chown(const DoutPrefixProvider* dpp, User& new_user, optional_yield y) override; |
20effc67 TL |
590 | virtual int put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time mtime) override; |
591 | virtual bool is_owner(User* user) override; | |
592 | virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) override; | |
1e59de90 | 593 | virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuota& quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override; |
20effc67 TL |
594 | virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& attrs, optional_yield y) override; |
595 | virtual int try_refresh_info(const DoutPrefixProvider* dpp, ceph::real_time* pmtime) override; | |
b3b6e05e | 596 | virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, |
20effc67 TL |
597 | bool* is_truncated, RGWUsageIter& usage_iter, |
598 | std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) override; | |
599 | virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) override; | |
600 | virtual int remove_objs_from_index(const DoutPrefixProvider *dpp, std::list<rgw_obj_index_key>& objs_to_unlink) override; | |
601 | virtual int check_index(const DoutPrefixProvider *dpp, std::map<RGWObjCategory, RGWStorageStats>& existing_stats, std::map<RGWObjCategory, RGWStorageStats>& calculated_stats) override; | |
602 | virtual int rebuild_index(const DoutPrefixProvider *dpp) override; | |
603 | virtual int set_tag_timeout(const DoutPrefixProvider *dpp, uint64_t timeout) override; | |
604 | virtual int purge_instance(const DoutPrefixProvider* dpp) override; | |
605 | virtual std::unique_ptr<Bucket> clone() override { | |
606 | return std::make_unique<RadosBucket>(*this); | |
f67539c2 | 607 | } |
20effc67 TL |
608 | virtual std::unique_ptr<MultipartUpload> get_multipart_upload( |
609 | const std::string& oid, | |
610 | std::optional<std::string> upload_id=std::nullopt, | |
611 | ACLOwner owner={}, ceph::real_time mtime=real_clock::now()) override; | |
612 | virtual int list_multiparts(const DoutPrefixProvider *dpp, | |
613 | const std::string& prefix, | |
614 | std::string& marker, | |
615 | const std::string& delim, | |
616 | const int& max_uploads, | |
617 | std::vector<std::unique_ptr<MultipartUpload>>& uploads, | |
618 | std::map<std::string, bool> *common_prefixes, | |
619 | bool *is_truncated) override; | |
620 | virtual int abort_multiparts(const DoutPrefixProvider* dpp, | |
621 | CephContext* cct) override; | |
1e59de90 TL |
622 | int read_topics(rgw_pubsub_bucket_topics& notifications, RGWObjVersionTracker* objv_tracker, |
623 | optional_yield y, const DoutPrefixProvider *dpp) override; | |
624 | int write_topics(const rgw_pubsub_bucket_topics& notifications, RGWObjVersionTracker* objv_tracker, | |
625 | optional_yield y, const DoutPrefixProvider *dpp) override; | |
626 | int remove_topics(RGWObjVersionTracker* objv_tracker, | |
627 | optional_yield y, const DoutPrefixProvider *dpp) override; | |
f67539c2 | 628 | |
20effc67 TL |
629 | private: |
630 | int link(const DoutPrefixProvider* dpp, User* new_user, optional_yield y, bool update_entrypoint = true, RGWObjVersionTracker* objv = nullptr); | |
631 | int unlink(const DoutPrefixProvider* dpp, User* new_user, optional_yield y, bool update_entrypoint = true); | |
632 | friend class RadosUser; | |
633 | }; | |
634 | ||
1e59de90 | 635 | class RadosMultipartPart : public StoreMultipartPart { |
20effc67 TL |
636 | protected: |
637 | RGWUploadPartInfo info; | |
f67539c2 | 638 | |
20effc67 TL |
639 | public: |
640 | RadosMultipartPart() = default; | |
641 | virtual ~RadosMultipartPart() = default; | |
f67539c2 | 642 | |
20effc67 TL |
643 | virtual uint32_t get_num() { return info.num; } |
644 | virtual uint64_t get_size() { return info.accounted_size; } | |
645 | virtual const std::string& get_etag() { return info.etag; } | |
646 | virtual ceph::real_time& get_mtime() { return info.modified; } | |
f67539c2 | 647 | |
20effc67 TL |
648 | /* For RadosStore code */ |
649 | RGWObjManifest& get_manifest() { return info.manifest; } | |
1e59de90 | 650 | const std::set<std::string>& get_past_prefixes() const { return info.past_prefixes; } |
f67539c2 | 651 | |
20effc67 TL |
652 | friend class RadosMultipartUpload; |
653 | }; | |
f67539c2 | 654 | |
1e59de90 | 655 | class RadosMultipartUpload : public StoreMultipartUpload { |
20effc67 TL |
656 | RadosStore* store; |
657 | RGWMPObj mp_obj; | |
658 | ACLOwner owner; | |
659 | ceph::real_time mtime; | |
660 | rgw_placement_rule placement; | |
661 | RGWObjManifest manifest; | |
662 | ||
663 | public: | |
664 | RadosMultipartUpload(RadosStore* _store, Bucket* _bucket, const std::string& oid, | |
665 | std::optional<std::string> upload_id, ACLOwner owner, | |
666 | ceph::real_time _mtime) | |
1e59de90 | 667 | : StoreMultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), |
20effc67 TL |
668 | owner(owner), mtime(_mtime) {} |
669 | virtual ~RadosMultipartUpload() = default; | |
670 | ||
671 | virtual const std::string& get_meta() const override { return mp_obj.get_meta(); } | |
672 | virtual const std::string& get_key() const override { return mp_obj.get_key(); } | |
673 | virtual const std::string& get_upload_id() const override { return mp_obj.get_upload_id(); } | |
674 | virtual const ACLOwner& get_owner() const override { return owner; } | |
675 | virtual ceph::real_time& get_mtime() override { return mtime; } | |
676 | virtual std::unique_ptr<rgw::sal::Object> get_meta_obj() override; | |
1e59de90 | 677 | virtual int init(const DoutPrefixProvider* dpp, optional_yield y, ACLOwner& owner, rgw_placement_rule& dest_placement, rgw::sal::Attrs& attrs) override; |
20effc67 TL |
678 | virtual int list_parts(const DoutPrefixProvider* dpp, CephContext* cct, |
679 | int num_parts, int marker, | |
680 | int* next_marker, bool* truncated, | |
681 | bool assume_unsorted = false) override; | |
1e59de90 | 682 | virtual int abort(const DoutPrefixProvider* dpp, CephContext* cct) override; |
20effc67 TL |
683 | virtual int complete(const DoutPrefixProvider* dpp, |
684 | optional_yield y, CephContext* cct, | |
685 | std::map<int, std::string>& part_etags, | |
686 | std::list<rgw_obj_index_key>& remove_objs, | |
687 | uint64_t& accounted_size, bool& compressed, | |
688 | RGWCompressionInfo& cs_info, off_t& ofs, | |
689 | std::string& tag, ACLOwner& owner, | |
690 | uint64_t olh_epoch, | |
1e59de90 TL |
691 | rgw::sal::Object* target_obj) override; |
692 | virtual int get_info(const DoutPrefixProvider *dpp, optional_yield y, rgw_placement_rule** rule, rgw::sal::Attrs* attrs = nullptr) override; | |
20effc67 TL |
693 | virtual std::unique_ptr<Writer> get_writer(const DoutPrefixProvider *dpp, |
694 | optional_yield y, | |
1e59de90 TL |
695 | rgw::sal::Object* obj, |
696 | const rgw_user& owner, | |
20effc67 TL |
697 | const rgw_placement_rule *ptail_placement_rule, |
698 | uint64_t part_num, | |
699 | const std::string& part_num_str) override; | |
1e59de90 TL |
700 | protected: |
701 | int cleanup_part_history(const DoutPrefixProvider* dpp, | |
702 | optional_yield y, | |
703 | RadosMultipartPart* part, | |
704 | std::list<rgw_obj_index_key>& remove_objs); | |
f67539c2 TL |
705 | }; |
706 | ||
1e59de90 | 707 | class MPRadosSerializer : public StoreMPSerializer { |
f67539c2 TL |
708 | librados::IoCtx ioctx; |
709 | rados::cls::lock::Lock lock; | |
710 | librados::ObjectWriteOperation op; | |
711 | ||
712 | public: | |
20effc67 | 713 | MPRadosSerializer(const DoutPrefixProvider *dpp, RadosStore* store, RadosObject* obj, const std::string& lock_name); |
f67539c2 | 714 | |
b3b6e05e | 715 | virtual int try_lock(const DoutPrefixProvider *dpp, utime_t dur, optional_yield y) override; |
20effc67 | 716 | virtual int unlock() override { |
f67539c2 TL |
717 | return lock.unlock(&ioctx, oid); |
718 | } | |
719 | }; | |
720 | ||
1e59de90 | 721 | class LCRadosSerializer : public StoreLCSerializer { |
f67539c2 TL |
722 | librados::IoCtx* ioctx; |
723 | rados::cls::lock::Lock lock; | |
f67539c2 TL |
724 | |
725 | public: | |
20effc67 | 726 | LCRadosSerializer(RadosStore* store, const std::string& oid, const std::string& lock_name, const std::string& cookie); |
f67539c2 | 727 | |
b3b6e05e | 728 | virtual int try_lock(const DoutPrefixProvider *dpp, utime_t dur, optional_yield y) override; |
20effc67 | 729 | virtual int unlock() override { |
f67539c2 TL |
730 | return lock.unlock(ioctx, oid); |
731 | } | |
732 | }; | |
733 | ||
1e59de90 | 734 | class RadosLifecycle : public StoreLifecycle { |
20effc67 | 735 | RadosStore* store; |
f67539c2 TL |
736 | |
737 | public: | |
20effc67 TL |
738 | RadosLifecycle(RadosStore* _st) : store(_st) {} |
739 | ||
1e59de90 TL |
740 | using StoreLifecycle::get_entry; |
741 | virtual int get_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override; | |
742 | virtual int get_next_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override; | |
743 | virtual int set_entry(const std::string& oid, LCEntry& entry) override; | |
20effc67 | 744 | virtual int list_entries(const std::string& oid, const std::string& marker, |
1e59de90 TL |
745 | uint32_t max_entries, |
746 | std::vector<std::unique_ptr<LCEntry>>& entries) override; | |
747 | virtual int rm_entry(const std::string& oid, LCEntry& entry) override; | |
748 | virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) override; | |
749 | virtual int put_head(const std::string& oid, LCHead& head) override; | |
750 | virtual std::unique_ptr<LCSerializer> get_serializer(const std::string& lock_name, | |
751 | const std::string& oid, | |
752 | const std::string& cookie) override; | |
f67539c2 TL |
753 | }; |
754 | ||
1e59de90 | 755 | class RadosNotification : public StoreNotification { |
20effc67 TL |
756 | RadosStore* store; |
757 | /* XXX it feels incorrect to me that rgw::notify::reservation_t is | |
758 | * currently RADOS-specific; instead, I think notification types such as | |
759 | * reservation_t should be generally visible, whereas the internal | |
760 | * notification behavior should be made portable (e.g., notification | |
761 | * to non-RADOS message sinks) */ | |
762 | rgw::notify::reservation_t res; | |
763 | ||
764 | public: | |
1e59de90 TL |
765 | RadosNotification(const DoutPrefixProvider* _dpp, RadosStore* _store, Object* _obj, Object* _src_obj, req_state* _s, rgw::notify::EventType _type, optional_yield y, const std::string* object_name) : |
766 | StoreNotification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _s, _obj, _src_obj, object_name, y) { } | |
20effc67 | 767 | |
1e59de90 TL |
768 | RadosNotification(const DoutPrefixProvider* _dpp, RadosStore* _store, Object* _obj, Object* _src_obj, rgw::notify::EventType _type, rgw::sal::Bucket* _bucket, std::string& _user_id, std::string& _user_tenant, std::string& _req_id, optional_yield y) : |
769 | StoreNotification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _obj, _src_obj, _bucket, _user_id, _user_tenant, _req_id, y) {} | |
20effc67 TL |
770 | |
771 | ~RadosNotification() = default; | |
772 | ||
773 | rgw::notify::reservation_t& get_reservation(void) { | |
774 | return res; | |
775 | } | |
776 | ||
777 | virtual int publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags = nullptr) override; | |
778 | virtual int publish_commit(const DoutPrefixProvider* dpp, uint64_t size, | |
779 | const ceph::real_time& mtime, const std::string& etag, const std::string& version) override; | |
780 | }; | |
781 | ||
1e59de90 | 782 | class RadosAtomicWriter : public StoreWriter { |
20effc67 TL |
783 | protected: |
784 | rgw::sal::RadosStore* store; | |
785 | std::unique_ptr<Aio> aio; | |
1e59de90 | 786 | RGWObjectCtx& obj_ctx; |
20effc67 | 787 | rgw::putobj::AtomicObjectProcessor processor; |
f67539c2 | 788 | |
f67539c2 | 789 | public: |
20effc67 TL |
790 | RadosAtomicWriter(const DoutPrefixProvider *dpp, |
791 | optional_yield y, | |
1e59de90 TL |
792 | RGWBucketInfo& bucket_info, |
793 | RGWObjectCtx& obj_ctx, | |
794 | const rgw_obj& obj, | |
20effc67 | 795 | RadosStore* _store, std::unique_ptr<Aio> _aio, |
1e59de90 | 796 | const rgw_user& owner, |
20effc67 TL |
797 | const rgw_placement_rule *ptail_placement_rule, |
798 | uint64_t olh_epoch, | |
799 | const std::string& unique_tag) : | |
1e59de90 | 800 | StoreWriter(dpp, y), |
20effc67 TL |
801 | store(_store), |
802 | aio(std::move(_aio)), | |
1e59de90 TL |
803 | obj_ctx(obj_ctx), |
804 | processor(&*aio, store->getRados(), bucket_info, | |
20effc67 | 805 | ptail_placement_rule, owner, obj_ctx, |
1e59de90 | 806 | obj, olh_epoch, unique_tag, |
20effc67 TL |
807 | dpp, y) |
808 | {} | |
809 | ~RadosAtomicWriter() = default; | |
810 | ||
811 | // prepare to start processing object data | |
812 | virtual int prepare(optional_yield y) override; | |
813 | ||
814 | // Process a bufferlist | |
815 | virtual int process(bufferlist&& data, uint64_t offset) override; | |
816 | ||
817 | // complete the operation and make its result visible to clients | |
818 | virtual int complete(size_t accounted_size, const std::string& etag, | |
819 | ceph::real_time *mtime, ceph::real_time set_mtime, | |
820 | std::map<std::string, bufferlist>& attrs, | |
821 | ceph::real_time delete_at, | |
822 | const char *if_match, const char *if_nomatch, | |
823 | const std::string *user_data, | |
824 | rgw_zone_set *zones_trace, bool *canceled, | |
825 | optional_yield y) override; | |
826 | }; | |
827 | ||
1e59de90 | 828 | class RadosAppendWriter : public StoreWriter { |
20effc67 TL |
829 | protected: |
830 | rgw::sal::RadosStore* store; | |
831 | std::unique_ptr<Aio> aio; | |
1e59de90 | 832 | RGWObjectCtx& obj_ctx; |
20effc67 TL |
833 | rgw::putobj::AppendObjectProcessor processor; |
834 | ||
835 | public: | |
836 | RadosAppendWriter(const DoutPrefixProvider *dpp, | |
837 | optional_yield y, | |
1e59de90 TL |
838 | RGWBucketInfo& bucket_info, |
839 | RGWObjectCtx& obj_ctx, | |
840 | const rgw_obj& obj, | |
20effc67 | 841 | RadosStore* _store, std::unique_ptr<Aio> _aio, |
1e59de90 | 842 | const rgw_user& owner, |
20effc67 TL |
843 | const rgw_placement_rule *ptail_placement_rule, |
844 | const std::string& unique_tag, | |
845 | uint64_t position, | |
846 | uint64_t *cur_accounted_size) : | |
1e59de90 TL |
847 | StoreWriter(dpp, y), |
848 | store(_store), | |
849 | aio(std::move(_aio)), | |
850 | obj_ctx(obj_ctx), | |
851 | processor(&*aio, store->getRados(), bucket_info, | |
852 | ptail_placement_rule, owner, obj_ctx, | |
853 | obj, unique_tag, position, | |
854 | cur_accounted_size, dpp, y) | |
20effc67 TL |
855 | {} |
856 | ~RadosAppendWriter() = default; | |
857 | ||
858 | // prepare to start processing object data | |
859 | virtual int prepare(optional_yield y) override; | |
860 | ||
861 | // Process a bufferlist | |
862 | virtual int process(bufferlist&& data, uint64_t offset) override; | |
863 | ||
864 | // complete the operation and make its result visible to clients | |
865 | virtual int complete(size_t accounted_size, const std::string& etag, | |
866 | ceph::real_time *mtime, ceph::real_time set_mtime, | |
867 | std::map<std::string, bufferlist>& attrs, | |
868 | ceph::real_time delete_at, | |
869 | const char *if_match, const char *if_nomatch, | |
870 | const std::string *user_data, | |
871 | rgw_zone_set *zones_trace, bool *canceled, | |
872 | optional_yield y) override; | |
873 | }; | |
874 | ||
1e59de90 | 875 | class RadosMultipartWriter : public StoreWriter { |
20effc67 TL |
876 | protected: |
877 | rgw::sal::RadosStore* store; | |
878 | std::unique_ptr<Aio> aio; | |
1e59de90 | 879 | RGWObjectCtx& obj_ctx; |
20effc67 TL |
880 | rgw::putobj::MultipartObjectProcessor processor; |
881 | ||
882 | public: | |
883 | RadosMultipartWriter(const DoutPrefixProvider *dpp, | |
1e59de90 TL |
884 | optional_yield y, const std::string& upload_id, |
885 | RGWBucketInfo& bucket_info, | |
886 | RGWObjectCtx& obj_ctx, | |
887 | const rgw_obj& obj, | |
20effc67 | 888 | RadosStore* _store, std::unique_ptr<Aio> _aio, |
1e59de90 | 889 | const rgw_user& owner, |
20effc67 TL |
890 | const rgw_placement_rule *ptail_placement_rule, |
891 | uint64_t part_num, const std::string& part_num_str) : | |
1e59de90 TL |
892 | StoreWriter(dpp, y), |
893 | store(_store), | |
894 | aio(std::move(_aio)), | |
895 | obj_ctx(obj_ctx), | |
896 | processor(&*aio, store->getRados(), bucket_info, | |
897 | ptail_placement_rule, owner, obj_ctx, | |
898 | obj, upload_id, | |
899 | part_num, part_num_str, dpp, y) | |
20effc67 TL |
900 | {} |
901 | ~RadosMultipartWriter() = default; | |
902 | ||
903 | // prepare to start processing object data | |
904 | virtual int prepare(optional_yield y) override; | |
905 | ||
906 | // Process a bufferlist | |
907 | virtual int process(bufferlist&& data, uint64_t offset) override; | |
908 | ||
909 | // complete the operation and make its result visible to clients | |
910 | virtual int complete(size_t accounted_size, const std::string& etag, | |
911 | ceph::real_time *mtime, ceph::real_time set_mtime, | |
912 | std::map<std::string, bufferlist>& attrs, | |
913 | ceph::real_time delete_at, | |
914 | const char *if_match, const char *if_nomatch, | |
915 | const std::string *user_data, | |
916 | rgw_zone_set *zones_trace, bool *canceled, | |
917 | optional_yield y) override; | |
918 | }; | |
919 | ||
1e59de90 TL |
920 | class RadosLuaManager : public StoreLuaManager { |
921 | RadosStore* const store; | |
20effc67 TL |
922 | rgw_pool pool; |
923 | ||
924 | public: | |
1e59de90 TL |
925 | RadosLuaManager(RadosStore* _s); |
926 | virtual ~RadosLuaManager() = default; | |
927 | ||
928 | virtual int get_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, std::string& script); | |
929 | virtual int put_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, const std::string& script); | |
930 | virtual int del_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key); | |
931 | virtual int add_package(const DoutPrefixProvider* dpp, optional_yield y, const std::string& package_name); | |
932 | virtual int remove_package(const DoutPrefixProvider* dpp, optional_yield y, const std::string& package_name); | |
933 | virtual int list_packages(const DoutPrefixProvider* dpp, optional_yield y, rgw::lua::packages_t& packages); | |
20effc67 TL |
934 | }; |
935 | ||
936 | class RadosOIDCProvider : public RGWOIDCProvider { | |
937 | RadosStore* store; | |
938 | public: | |
939 | RadosOIDCProvider(RadosStore* _store) : store(_store) {} | |
940 | ~RadosOIDCProvider() = default; | |
941 | ||
942 | virtual int store_url(const DoutPrefixProvider *dpp, const std::string& url, bool exclusive, optional_yield y) override; | |
943 | virtual int read_url(const DoutPrefixProvider *dpp, const std::string& url, const std::string& tenant) override; | |
944 | virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) override; | |
945 | void encode(bufferlist& bl) const { | |
946 | RGWOIDCProvider::encode(bl); | |
f67539c2 | 947 | } |
20effc67 TL |
948 | void decode(bufferlist::const_iterator& bl) { |
949 | RGWOIDCProvider::decode(bl); | |
f67539c2 | 950 | } |
20effc67 | 951 | }; |
f67539c2 | 952 | |
20effc67 TL |
953 | class RadosRole : public RGWRole { |
954 | RadosStore* store; | |
955 | public: | |
956 | RadosRole(RadosStore* _store, std::string name, | |
957 | std::string tenant, | |
958 | std::string path, | |
959 | std::string trust_policy, | |
960 | std::string max_session_duration, | |
961 | std::multimap<std::string,std::string> tags) : RGWRole(name, tenant, path, trust_policy, max_session_duration, tags), store(_store) {} | |
962 | RadosRole(RadosStore* _store, std::string id) : RGWRole(id), store(_store) {} | |
39ae355f TL |
963 | RadosRole(RadosStore* _store, const RGWRoleInfo& info) : RGWRole(info), store(_store) {} |
964 | RadosRole(RadosStore* _store) : store(_store) {} | |
20effc67 TL |
965 | ~RadosRole() = default; |
966 | ||
967 | virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) override; | |
968 | virtual int store_name(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) override; | |
969 | virtual int store_path(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) override; | |
970 | virtual int read_id(const DoutPrefixProvider *dpp, const std::string& role_name, const std::string& tenant, std::string& role_id, optional_yield y) override; | |
971 | virtual int read_name(const DoutPrefixProvider *dpp, optional_yield y) override; | |
972 | virtual int read_info(const DoutPrefixProvider *dpp, optional_yield y) override; | |
39ae355f | 973 | virtual int create(const DoutPrefixProvider *dpp, bool exclusive, const std::string& role_id, optional_yield y) override; |
20effc67 | 974 | virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) override; |
f67539c2 | 975 | }; |
39ae355f | 976 | }} // namespace rgw::sal |
20effc67 TL |
977 | |
978 | WRITE_CLASS_ENCODER(rgw::sal::RadosOIDCProvider) |