2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2020 Red Hat, Inc.
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.
19 #include "rgw_rados.h"
20 #include "rgw_notify.h"
21 #include "rgw_oidc_provider.h"
23 #include "rgw_multi.h"
24 #include "rgw_putobj_processor.h"
25 #include "services/svc_tier_rados.h"
26 #include "cls/lock/cls_lock_client.h"
28 namespace rgw
{ namespace sal
{
31 class RadosMultipartUpload
;
33 class RadosCompletions
: public Completions
{
35 std::list
<librados::AioCompletion
*> handles
;
37 ~RadosCompletions() = default;
38 virtual int drain() override
;
41 class RadosUser
: public User
{
46 RadosUser(RadosStore
*_st
, const rgw_user
& _u
) : User(_u
), store(_st
) { }
47 RadosUser(RadosStore
*_st
, const RGWUserInfo
& _i
) : User(_i
), store(_st
) { }
48 RadosUser(RadosStore
*_st
) : store(_st
) { }
49 RadosUser(RadosUser
& _o
) = default;
52 virtual std::unique_ptr
<User
> clone() override
{
53 return std::unique_ptr
<User
>(new RadosUser(*this));
55 int list_buckets(const DoutPrefixProvider
* dpp
, const std::string
& marker
, const std::string
& end_marker
,
56 uint64_t max
, bool need_stats
, BucketList
& buckets
,
57 optional_yield y
) override
;
58 virtual int create_bucket(const DoutPrefixProvider
* dpp
,
60 const std::string
& zonegroup_id
,
61 rgw_placement_rule
& placement_rule
,
62 std::string
& swift_ver_location
,
63 const RGWQuotaInfo
* pquota_info
,
64 const RGWAccessControlPolicy
& policy
,
69 bool obj_lock_enabled
,
72 std::unique_ptr
<Bucket
>* bucket
,
73 optional_yield y
) override
;
74 virtual int read_attrs(const DoutPrefixProvider
* dpp
, optional_yield y
) override
;
75 virtual int merge_and_store_attrs(const DoutPrefixProvider
* dpp
, Attrs
& new_attrs
, optional_yield y
) override
;
76 virtual int read_stats(const DoutPrefixProvider
*dpp
,
77 optional_yield y
, RGWStorageStats
* stats
,
78 ceph::real_time
* last_stats_sync
= nullptr,
79 ceph::real_time
* last_stats_update
= nullptr) override
;
80 virtual int read_stats_async(const DoutPrefixProvider
*dpp
, RGWGetUserStats_CB
* cb
) override
;
81 virtual int complete_flush_stats(const DoutPrefixProvider
*dpp
, optional_yield y
) override
;
82 virtual int read_usage(const DoutPrefixProvider
*dpp
, uint64_t start_epoch
, uint64_t end_epoch
, uint32_t max_entries
,
83 bool* is_truncated
, RGWUsageIter
& usage_iter
,
84 std::map
<rgw_user_bucket
, rgw_usage_log_entry
>& usage
) override
;
85 virtual int trim_usage(const DoutPrefixProvider
*dpp
, uint64_t start_epoch
, uint64_t end_epoch
) override
;
87 virtual int load_user(const DoutPrefixProvider
* dpp
, optional_yield y
) override
;
88 virtual int store_user(const DoutPrefixProvider
* dpp
, optional_yield y
, bool exclusive
, RGWUserInfo
* old_info
= nullptr) override
;
89 virtual int remove_user(const DoutPrefixProvider
* dpp
, optional_yield y
) override
;
91 friend class RadosBucket
;
94 class RadosObject
: public Object
{
97 RGWAccessControlPolicy acls
;
101 struct RadosReadOp
: public ReadOp
{
105 RGWRados::Object op_target
;
106 RGWRados::Object::Read parent_op
;
109 RadosReadOp(RadosObject
*_source
, RGWObjectCtx
*_rctx
);
111 virtual int prepare(optional_yield y
, const DoutPrefixProvider
* dpp
) override
;
112 virtual int read(int64_t ofs
, int64_t end
, bufferlist
& bl
, optional_yield y
, const DoutPrefixProvider
* dpp
) override
;
113 virtual int iterate(const DoutPrefixProvider
* dpp
, int64_t ofs
, int64_t end
, RGWGetDataCB
* cb
, optional_yield y
) override
;
114 virtual int get_attr(const DoutPrefixProvider
* dpp
, const char* name
, bufferlist
& dest
, optional_yield y
) override
;
117 struct RadosDeleteOp
: public DeleteOp
{
121 RGWRados::Object op_target
;
122 RGWRados::Object::Delete parent_op
;
125 RadosDeleteOp(RadosObject
* _source
, RGWObjectCtx
* _rctx
);
127 virtual int delete_obj(const DoutPrefixProvider
* dpp
, optional_yield y
) override
;
130 RadosObject() = default;
132 RadosObject(RadosStore
*_st
, const rgw_obj_key
& _k
)
137 RadosObject(RadosStore
*_st
, const rgw_obj_key
& _k
, Bucket
* _b
)
142 RadosObject(RadosObject
& _o
) = default;
144 virtual ~RadosObject();
146 virtual int delete_object(const DoutPrefixProvider
* dpp
, RGWObjectCtx
* obj_ctx
,
147 optional_yield y
, bool prevent_versioning
) override
;
148 virtual int delete_obj_aio(const DoutPrefixProvider
* dpp
, RGWObjState
* astate
, Completions
* aio
,
149 bool keep_index_consistent
, optional_yield y
) override
;
150 virtual int copy_object(RGWObjectCtx
& obj_ctx
, User
* user
,
151 req_info
* info
, const rgw_zone_id
& source_zone
,
152 rgw::sal::Object
* dest_object
, rgw::sal::Bucket
* dest_bucket
,
153 rgw::sal::Bucket
* src_bucket
,
154 const rgw_placement_rule
& dest_placement
,
155 ceph::real_time
* src_mtime
, ceph::real_time
* mtime
,
156 const ceph::real_time
* mod_ptr
, const ceph::real_time
* unmod_ptr
,
157 bool high_precision_time
,
158 const char* if_match
, const char* if_nomatch
,
159 AttrsMod attrs_mod
, bool copy_if_newer
, Attrs
& attrs
,
160 RGWObjCategory category
, uint64_t olh_epoch
,
161 boost::optional
<ceph::real_time
> delete_at
,
162 std::string
* version_id
, std::string
* tag
, std::string
* etag
,
163 void (*progress_cb
)(off_t
, void *), void* progress_data
,
164 const DoutPrefixProvider
* dpp
, optional_yield y
) override
;
165 virtual RGWAccessControlPolicy
& get_acl(void) override
{ return acls
; }
166 virtual int set_acl(const RGWAccessControlPolicy
& acl
) override
{ acls
= acl
; return 0; }
167 virtual void set_atomic(RGWObjectCtx
* rctx
) const override
;
168 virtual void set_prefetch_data(RGWObjectCtx
* rctx
) override
;
169 virtual void set_compressed(RGWObjectCtx
* rctx
) override
;
171 virtual int get_obj_state(const DoutPrefixProvider
* dpp
, RGWObjectCtx
* rctx
, RGWObjState
**state
, optional_yield y
, bool follow_olh
= true) override
;
172 virtual int set_obj_attrs(const DoutPrefixProvider
* dpp
, RGWObjectCtx
* rctx
, Attrs
* setattrs
, Attrs
* delattrs
, optional_yield y
, rgw_obj
* target_obj
= NULL
) override
;
173 virtual int get_obj_attrs(RGWObjectCtx
* rctx
, optional_yield y
, const DoutPrefixProvider
* dpp
, rgw_obj
* target_obj
= NULL
) override
;
174 virtual int modify_obj_attrs(RGWObjectCtx
* rctx
, const char* attr_name
, bufferlist
& attr_val
, optional_yield y
, const DoutPrefixProvider
* dpp
) override
;
175 virtual int delete_obj_attrs(const DoutPrefixProvider
* dpp
, RGWObjectCtx
* rctx
, const char* attr_name
, optional_yield y
) override
;
176 virtual bool is_expired() override
;
177 virtual void gen_rand_obj_instance_name() override
;
178 void get_raw_obj(rgw_raw_obj
* raw_obj
);
179 virtual std::unique_ptr
<Object
> clone() override
{
180 return std::unique_ptr
<Object
>(new RadosObject(*this));
182 virtual MPSerializer
* get_serializer(const DoutPrefixProvider
*dpp
, const std::string
& lock_name
) override
;
183 virtual int transition(RGWObjectCtx
& rctx
,
185 const rgw_placement_rule
& placement_rule
,
186 const real_time
& mtime
,
188 const DoutPrefixProvider
* dpp
,
189 optional_yield y
) override
;
190 virtual bool placement_rules_match(rgw_placement_rule
& r1
, rgw_placement_rule
& r2
) override
;
191 virtual int dump_obj_layout(const DoutPrefixProvider
*dpp
, optional_yield y
, Formatter
* f
, RGWObjectCtx
* obj_ctx
) override
;
193 /* Swift versioning */
194 virtual int swift_versioning_restore(RGWObjectCtx
* obj_ctx
,
196 const DoutPrefixProvider
* dpp
) override
;
197 virtual int swift_versioning_copy(RGWObjectCtx
* obj_ctx
,
198 const DoutPrefixProvider
* dpp
,
199 optional_yield y
) override
;
202 virtual std::unique_ptr
<ReadOp
> get_read_op(RGWObjectCtx
*) override
;
203 virtual std::unique_ptr
<DeleteOp
> get_delete_op(RGWObjectCtx
*) override
;
206 virtual int omap_get_vals(const DoutPrefixProvider
*dpp
, const std::string
& marker
, uint64_t count
,
207 std::map
<std::string
, bufferlist
> *m
,
208 bool* pmore
, optional_yield y
) override
;
209 virtual int omap_get_all(const DoutPrefixProvider
*dpp
, std::map
<std::string
, bufferlist
> *m
,
210 optional_yield y
) override
;
211 virtual int omap_get_vals_by_keys(const DoutPrefixProvider
*dpp
, const std::string
& oid
,
212 const std::set
<std::string
>& keys
,
213 Attrs
* vals
) override
;
214 virtual int omap_set_val_by_key(const DoutPrefixProvider
*dpp
, const std::string
& key
, bufferlist
& val
,
215 bool must_exist
, optional_yield y
) override
;
217 /* Internal to RadosStore */
218 int get_max_chunk_size(const DoutPrefixProvider
* dpp
,
219 rgw_placement_rule placement_rule
,
220 uint64_t* max_chunk_size
,
221 uint64_t* alignment
= nullptr);
222 void get_max_aligned_size(uint64_t size
, uint64_t alignment
, uint64_t* max_size
);
223 void raw_obj_to_obj(const rgw_raw_obj
& raw_obj
);
226 int read_attrs(const DoutPrefixProvider
* dpp
, RGWRados::Object::Read
&read_op
, optional_yield y
, rgw_obj
* target_obj
= nullptr);
229 class RadosBucket
: public Bucket
{
232 RGWAccessControlPolicy acls
;
235 RadosBucket(RadosStore
*_st
)
240 RadosBucket(RadosStore
*_st
, User
* _u
)
246 RadosBucket(RadosStore
*_st
, const rgw_bucket
& _b
)
252 RadosBucket(RadosStore
*_st
, const RGWBucketEnt
& _e
)
258 RadosBucket(RadosStore
*_st
, const RGWBucketInfo
& _i
)
264 RadosBucket(RadosStore
*_st
, const rgw_bucket
& _b
, User
* _u
)
270 RadosBucket(RadosStore
*_st
, const RGWBucketEnt
& _e
, User
* _u
)
276 RadosBucket(RadosStore
*_st
, const RGWBucketInfo
& _i
, User
* _u
)
282 virtual ~RadosBucket();
284 virtual std::unique_ptr
<Object
> get_object(const rgw_obj_key
& k
) override
;
285 virtual int list(const DoutPrefixProvider
* dpp
, ListParams
&, int, ListResults
&, optional_yield y
) override
;
286 virtual int remove_bucket(const DoutPrefixProvider
* dpp
, bool delete_children
, bool forward_to_master
, req_info
* req_info
, optional_yield y
) override
;
287 virtual int remove_bucket_bypass_gc(int concurrent_max
, bool
288 keep_index_consistent
,
289 optional_yield y
, const
290 DoutPrefixProvider
*dpp
) override
;
291 virtual RGWAccessControlPolicy
& get_acl(void) override
{ return acls
; }
292 virtual int set_acl(const DoutPrefixProvider
* dpp
, RGWAccessControlPolicy
& acl
, optional_yield y
) override
;
293 virtual int load_bucket(const DoutPrefixProvider
* dpp
, optional_yield y
, bool get_stats
= false) override
;
294 virtual int read_stats(const DoutPrefixProvider
*dpp
, int shard_id
,
295 std::string
* bucket_ver
, std::string
* master_ver
,
296 std::map
<RGWObjCategory
, RGWStorageStats
>& stats
,
297 std::string
* max_marker
= nullptr,
298 bool* syncstopped
= nullptr) override
;
299 virtual int read_stats_async(const DoutPrefixProvider
*dpp
, int shard_id
, RGWGetBucketStats_CB
* ctx
) override
;
300 virtual int sync_user_stats(const DoutPrefixProvider
*dpp
, optional_yield y
) override
;
301 virtual int update_container_stats(const DoutPrefixProvider
* dpp
) override
;
302 virtual int check_bucket_shards(const DoutPrefixProvider
* dpp
) override
;
303 virtual int chown(const DoutPrefixProvider
* dpp
, User
* new_user
, User
* old_user
, optional_yield y
, const std::string
* marker
= nullptr) override
;
304 virtual int put_info(const DoutPrefixProvider
* dpp
, bool exclusive
, ceph::real_time mtime
) override
;
305 virtual bool is_owner(User
* user
) override
;
306 virtual int check_empty(const DoutPrefixProvider
* dpp
, optional_yield y
) override
;
307 virtual int check_quota(const DoutPrefixProvider
*dpp
, RGWQuotaInfo
& user_quota
, RGWQuotaInfo
& bucket_quota
, uint64_t obj_size
, optional_yield y
, bool check_size_only
= false) override
;
308 virtual int merge_and_store_attrs(const DoutPrefixProvider
* dpp
, Attrs
& attrs
, optional_yield y
) override
;
309 virtual int try_refresh_info(const DoutPrefixProvider
* dpp
, ceph::real_time
* pmtime
) override
;
310 virtual int read_usage(const DoutPrefixProvider
*dpp
, uint64_t start_epoch
, uint64_t end_epoch
, uint32_t max_entries
,
311 bool* is_truncated
, RGWUsageIter
& usage_iter
,
312 std::map
<rgw_user_bucket
, rgw_usage_log_entry
>& usage
) override
;
313 virtual int trim_usage(const DoutPrefixProvider
*dpp
, uint64_t start_epoch
, uint64_t end_epoch
) override
;
314 virtual int remove_objs_from_index(const DoutPrefixProvider
*dpp
, std::list
<rgw_obj_index_key
>& objs_to_unlink
) override
;
315 virtual int check_index(const DoutPrefixProvider
*dpp
, std::map
<RGWObjCategory
, RGWStorageStats
>& existing_stats
, std::map
<RGWObjCategory
, RGWStorageStats
>& calculated_stats
) override
;
316 virtual int rebuild_index(const DoutPrefixProvider
*dpp
) override
;
317 virtual int set_tag_timeout(const DoutPrefixProvider
*dpp
, uint64_t timeout
) override
;
318 virtual int purge_instance(const DoutPrefixProvider
* dpp
) override
;
319 virtual std::unique_ptr
<Bucket
> clone() override
{
320 return std::make_unique
<RadosBucket
>(*this);
322 virtual std::unique_ptr
<MultipartUpload
> get_multipart_upload(
323 const std::string
& oid
,
324 std::optional
<std::string
> upload_id
=std::nullopt
,
325 ACLOwner owner
={}, ceph::real_time mtime
=real_clock::now()) override
;
326 virtual int list_multiparts(const DoutPrefixProvider
*dpp
,
327 const std::string
& prefix
,
329 const std::string
& delim
,
330 const int& max_uploads
,
331 std::vector
<std::unique_ptr
<MultipartUpload
>>& uploads
,
332 std::map
<std::string
, bool> *common_prefixes
,
333 bool *is_truncated
) override
;
334 virtual int abort_multiparts(const DoutPrefixProvider
* dpp
,
335 CephContext
* cct
) override
;
338 int link(const DoutPrefixProvider
* dpp
, User
* new_user
, optional_yield y
, bool update_entrypoint
= true, RGWObjVersionTracker
* objv
= nullptr);
339 int unlink(const DoutPrefixProvider
* dpp
, User
* new_user
, optional_yield y
, bool update_entrypoint
= true);
340 friend class RadosUser
;
343 class RadosZone
: public Zone
{
347 RadosZone(RadosStore
* _store
) : store(_store
) {}
348 ~RadosZone() = default;
350 virtual const RGWZoneGroup
& get_zonegroup() override
;
351 virtual int get_zonegroup(const std::string
& id
, RGWZoneGroup
& zonegroup
) override
;
352 virtual const RGWZoneParams
& get_params() override
;
353 virtual const rgw_zone_id
& get_id() override
;
354 virtual const RGWRealm
& get_realm() override
;
355 virtual const std::string
& get_name() const override
;
356 virtual bool is_writeable() override
;
357 virtual bool get_redirect_endpoint(std::string
* endpoint
) override
;
358 virtual bool has_zonegroup_api(const std::string
& api
) const override
;
359 virtual const std::string
& get_current_period_id() override
;
362 class RadosStore
: public Store
{
365 RGWUserCtl
* user_ctl
;
366 std::string luarocks_path
;
371 : rados(nullptr), zone(this) {
377 virtual const char* get_name() const override
{
381 virtual std::unique_ptr
<User
> get_user(const rgw_user
& u
) override
;
382 virtual std::string
get_cluster_id(const DoutPrefixProvider
* dpp
, optional_yield y
) override
;
383 virtual int get_user_by_access_key(const DoutPrefixProvider
* dpp
, const std::string
& key
, optional_yield y
, std::unique_ptr
<User
>* user
) override
;
384 virtual int get_user_by_email(const DoutPrefixProvider
* dpp
, const std::string
& email
, optional_yield y
, std::unique_ptr
<User
>* user
) override
;
385 virtual int get_user_by_swift(const DoutPrefixProvider
* dpp
, const std::string
& user_str
, optional_yield y
, std::unique_ptr
<User
>* user
) override
;
386 virtual std::unique_ptr
<Object
> get_object(const rgw_obj_key
& k
) override
;
387 virtual int get_bucket(const DoutPrefixProvider
* dpp
, User
* u
, const rgw_bucket
& b
, std::unique_ptr
<Bucket
>* bucket
, optional_yield y
) override
;
388 virtual int get_bucket(User
* u
, const RGWBucketInfo
& i
, std::unique_ptr
<Bucket
>* bucket
) override
;
389 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
;
390 virtual bool is_meta_master() override
;
391 virtual int forward_request_to_master(const DoutPrefixProvider
*dpp
, User
* user
, obj_version
* objv
,
392 bufferlist
& in_data
, JSONParser
* jp
, req_info
& info
,
393 optional_yield y
) override
;
394 virtual Zone
* get_zone() { return &zone
; }
395 virtual std::string
zone_unique_id(uint64_t unique_num
) override
;
396 virtual std::string
zone_unique_trans_id(const uint64_t unique_num
) override
;
397 virtual int cluster_stat(RGWClusterStat
& stats
) override
;
398 virtual std::unique_ptr
<Lifecycle
> get_lifecycle(void) override
;
399 virtual std::unique_ptr
<Completions
> get_completions(void) override
;
402 virtual std::unique_ptr
<Notification
> get_notification(rgw::sal::Object
* obj
, rgw::sal::Object
* src_obj
, struct req_state
* s
, rgw::notify::EventType event_type
, const std::string
* object_name
=nullptr) override
;
404 // non-op variant (e.g., rgwlc)
405 virtual std::unique_ptr
<Notification
> get_notification(const DoutPrefixProvider
* dpp
, rgw::sal::Object
* obj
, rgw::sal::Object
* src_obj
, RGWObjectCtx
* rctx
, rgw::notify::EventType event_type
, rgw::sal::Bucket
* _bucket
, std::string
& _user_id
, std::string
& _user_tenant
, std::string
& _req_id
, optional_yield y
) override
;
406 virtual RGWLC
* get_rgwlc(void) override
{ return rados
->get_lc(); }
407 virtual RGWCoroutinesManagerRegistry
* get_cr_registry() override
{ return rados
->get_cr_registry(); }
409 virtual int log_usage(const DoutPrefixProvider
*dpp
, std::map
<rgw_user_bucket
, RGWUsageBatch
>& usage_info
) override
;
410 virtual int log_op(const DoutPrefixProvider
*dpp
, std::string
& oid
, bufferlist
& bl
) override
;
411 virtual int register_to_service_map(const DoutPrefixProvider
*dpp
, const std::string
& daemon_type
,
412 const std::map
<std::string
, std::string
>& meta
) override
;
413 virtual void get_quota(RGWQuotaInfo
& bucket_quota
, RGWQuotaInfo
& user_quota
) override
;
414 virtual void get_ratelimit(RGWRateLimitInfo
& bucket_ratelimit
, RGWRateLimitInfo
& user_ratelimit
, RGWRateLimitInfo
& anon_ratelimit
) override
;
415 virtual int set_buckets_enabled(const DoutPrefixProvider
* dpp
, std::vector
<rgw_bucket
>& buckets
, bool enabled
) override
;
416 virtual uint64_t get_new_req_id() override
{ return rados
->get_new_req_id(); }
417 virtual int get_sync_policy_handler(const DoutPrefixProvider
* dpp
,
418 std::optional
<rgw_zone_id
> zone
,
419 std::optional
<rgw_bucket
> bucket
,
420 RGWBucketSyncPolicyHandlerRef
* phandler
,
421 optional_yield y
) override
;
422 virtual RGWDataSyncStatusManager
* get_data_sync_manager(const rgw_zone_id
& source_zone
) override
;
423 virtual void wakeup_meta_sync_shards(std::set
<int>& shard_ids
) override
{ rados
->wakeup_meta_sync_shards(shard_ids
); }
424 virtual void wakeup_data_sync_shards(const DoutPrefixProvider
*dpp
, const rgw_zone_id
& source_zone
, std::map
<int, std::set
<std::string
> >& shard_ids
) override
{ rados
->wakeup_data_sync_shards(dpp
, source_zone
, shard_ids
); }
425 virtual int clear_usage(const DoutPrefixProvider
*dpp
) override
{ return rados
->clear_usage(dpp
); }
426 virtual int read_all_usage(const DoutPrefixProvider
*dpp
, uint64_t start_epoch
, uint64_t end_epoch
,
427 uint32_t max_entries
, bool* is_truncated
,
428 RGWUsageIter
& usage_iter
,
429 std::map
<rgw_user_bucket
, rgw_usage_log_entry
>& usage
) override
;
430 virtual int trim_all_usage(const DoutPrefixProvider
*dpp
, uint64_t start_epoch
, uint64_t end_epoch
) override
;
431 virtual int get_config_key_val(std::string name
, bufferlist
* bl
) override
;
432 virtual int meta_list_keys_init(const DoutPrefixProvider
*dpp
, const std::string
& section
, const std::string
& marker
, void** phandle
) override
;
433 virtual int meta_list_keys_next(const DoutPrefixProvider
*dpp
, void* handle
, int max
, std::list
<std::string
>& keys
, bool* truncated
) override
;
434 virtual void meta_list_keys_complete(void* handle
) override
;
435 virtual std::string
meta_get_marker(void* handle
) override
;
436 virtual int meta_remove(const DoutPrefixProvider
* dpp
, std::string
& metadata_key
, optional_yield y
) override
;
437 virtual const RGWSyncModuleInstanceRef
& get_sync_module() { return rados
->get_sync_module(); }
438 virtual std::string
get_host_id() { return rados
->host_id
; }
439 virtual std::unique_ptr
<LuaScriptManager
> get_lua_script_manager() override
;
440 virtual std::unique_ptr
<RGWRole
> get_role(std::string name
,
443 std::string trust_policy
="",
444 std::string max_session_duration_str
="",
445 std::multimap
<std::string
,std::string
> tags
={}) override
;
446 virtual std::unique_ptr
<RGWRole
> get_role(std::string id
) override
;
447 virtual int get_roles(const DoutPrefixProvider
*dpp
,
449 const std::string
& path_prefix
,
450 const std::string
& tenant
,
451 std::vector
<std::unique_ptr
<RGWRole
>>& roles
) override
;
452 virtual std::unique_ptr
<RGWOIDCProvider
> get_oidc_provider() override
;
453 virtual int get_oidc_providers(const DoutPrefixProvider
*dpp
,
454 const std::string
& tenant
,
455 std::vector
<std::unique_ptr
<RGWOIDCProvider
>>& providers
) override
;
456 virtual std::unique_ptr
<Writer
> get_append_writer(const DoutPrefixProvider
*dpp
,
458 std::unique_ptr
<rgw::sal::Object
> _head_obj
,
459 const rgw_user
& owner
, RGWObjectCtx
& obj_ctx
,
460 const rgw_placement_rule
*ptail_placement_rule
,
461 const std::string
& unique_tag
,
463 uint64_t *cur_accounted_size
) override
;
464 virtual std::unique_ptr
<Writer
> get_atomic_writer(const DoutPrefixProvider
*dpp
,
466 std::unique_ptr
<rgw::sal::Object
> _head_obj
,
467 const rgw_user
& owner
, RGWObjectCtx
& obj_ctx
,
468 const rgw_placement_rule
*ptail_placement_rule
,
470 const std::string
& unique_tag
) override
;
472 virtual void finalize(void) override
;
474 virtual CephContext
* ctx(void) override
{ return rados
->ctx(); }
476 virtual const std::string
& get_luarocks_path() const override
{
477 return luarocks_path
;
480 virtual void set_luarocks_path(const std::string
& path
) override
{
481 luarocks_path
= path
;
484 /* Unique to RadosStore */
485 int get_obj_head_ioctx(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
,
486 librados::IoCtx
* ioctx
);
487 int delete_raw_obj(const DoutPrefixProvider
*dpp
, const rgw_raw_obj
& obj
);
488 int delete_raw_obj_aio(const DoutPrefixProvider
*dpp
, const rgw_raw_obj
& obj
, Completions
* aio
);
489 void get_raw_obj(const rgw_placement_rule
& placement_rule
, const rgw_obj
& obj
, rgw_raw_obj
* raw_obj
);
490 int get_raw_chunk_size(const DoutPrefixProvider
* dpp
, const rgw_raw_obj
& obj
, uint64_t* chunk_size
);
492 void setRados(RGWRados
* st
) { rados
= st
; }
493 RGWRados
* getRados(void) { return rados
; }
495 RGWServices
* svc() { return &rados
->svc
; }
496 const RGWServices
* svc() const { return &rados
->svc
; }
497 RGWCtl
* ctl() { return &rados
->ctl
; }
498 const RGWCtl
* ctl() const { return &rados
->ctl
; }
500 void setUserCtl(RGWUserCtl
*_ctl
) { user_ctl
= _ctl
; }
503 class RadosMultipartPart
: public MultipartPart
{
505 RGWUploadPartInfo info
;
508 RadosMultipartPart() = default;
509 virtual ~RadosMultipartPart() = default;
511 virtual uint32_t get_num() { return info
.num
; }
512 virtual uint64_t get_size() { return info
.accounted_size
; }
513 virtual const std::string
& get_etag() { return info
.etag
; }
514 virtual ceph::real_time
& get_mtime() { return info
.modified
; }
516 /* For RadosStore code */
517 RGWObjManifest
& get_manifest() { return info
.manifest
; }
519 friend class RadosMultipartUpload
;
522 class RadosMultipartUpload
: public MultipartUpload
{
526 ceph::real_time mtime
;
527 rgw_placement_rule placement
;
528 RGWObjManifest manifest
;
531 RadosMultipartUpload(RadosStore
* _store
, Bucket
* _bucket
, const std::string
& oid
,
532 std::optional
<std::string
> upload_id
, ACLOwner owner
,
533 ceph::real_time _mtime
)
534 : MultipartUpload(_bucket
), store(_store
), mp_obj(oid
, upload_id
),
535 owner(owner
), mtime(_mtime
) {}
536 virtual ~RadosMultipartUpload() = default;
538 virtual const std::string
& get_meta() const override
{ return mp_obj
.get_meta(); }
539 virtual const std::string
& get_key() const override
{ return mp_obj
.get_key(); }
540 virtual const std::string
& get_upload_id() const override
{ return mp_obj
.get_upload_id(); }
541 virtual const ACLOwner
& get_owner() const override
{ return owner
; }
542 virtual ceph::real_time
& get_mtime() override
{ return mtime
; }
543 virtual std::unique_ptr
<rgw::sal::Object
> get_meta_obj() override
;
544 virtual int init(const DoutPrefixProvider
* dpp
, optional_yield y
, RGWObjectCtx
* obj_ctx
, ACLOwner
& owner
, rgw_placement_rule
& dest_placement
, rgw::sal::Attrs
& attrs
) override
;
545 virtual int list_parts(const DoutPrefixProvider
* dpp
, CephContext
* cct
,
546 int num_parts
, int marker
,
547 int* next_marker
, bool* truncated
,
548 bool assume_unsorted
= false) override
;
549 virtual int abort(const DoutPrefixProvider
* dpp
, CephContext
* cct
,
550 RGWObjectCtx
* obj_ctx
) override
;
551 virtual int complete(const DoutPrefixProvider
* dpp
,
552 optional_yield y
, CephContext
* cct
,
553 std::map
<int, std::string
>& part_etags
,
554 std::list
<rgw_obj_index_key
>& remove_objs
,
555 uint64_t& accounted_size
, bool& compressed
,
556 RGWCompressionInfo
& cs_info
, off_t
& ofs
,
557 std::string
& tag
, ACLOwner
& owner
,
559 rgw::sal::Object
* target_obj
,
560 RGWObjectCtx
* obj_ctx
) override
;
561 virtual int get_info(const DoutPrefixProvider
*dpp
, optional_yield y
, RGWObjectCtx
* obj_ctx
, rgw_placement_rule
** rule
, rgw::sal::Attrs
* attrs
= nullptr) override
;
562 virtual std::unique_ptr
<Writer
> get_writer(const DoutPrefixProvider
*dpp
,
564 std::unique_ptr
<rgw::sal::Object
> _head_obj
,
565 const rgw_user
& owner
, RGWObjectCtx
& obj_ctx
,
566 const rgw_placement_rule
*ptail_placement_rule
,
568 const std::string
& part_num_str
) override
;
571 class MPRadosSerializer
: public MPSerializer
{
572 librados::IoCtx ioctx
;
573 rados::cls::lock::Lock lock
;
574 librados::ObjectWriteOperation op
;
577 MPRadosSerializer(const DoutPrefixProvider
*dpp
, RadosStore
* store
, RadosObject
* obj
, const std::string
& lock_name
);
579 virtual int try_lock(const DoutPrefixProvider
*dpp
, utime_t dur
, optional_yield y
) override
;
580 virtual int unlock() override
{
581 return lock
.unlock(&ioctx
, oid
);
585 class LCRadosSerializer
: public LCSerializer
{
586 librados::IoCtx
* ioctx
;
587 rados::cls::lock::Lock lock
;
588 const std::string oid
;
591 LCRadosSerializer(RadosStore
* store
, const std::string
& oid
, const std::string
& lock_name
, const std::string
& cookie
);
593 virtual int try_lock(const DoutPrefixProvider
*dpp
, utime_t dur
, optional_yield y
) override
;
594 virtual int unlock() override
{
595 return lock
.unlock(ioctx
, oid
);
599 class RadosLifecycle
: public Lifecycle
{
603 RadosLifecycle(RadosStore
* _st
) : store(_st
) {}
605 virtual int get_entry(const std::string
& oid
, const std::string
& marker
, LCEntry
& entry
) override
;
606 virtual int get_next_entry(const std::string
& oid
, std::string
& marker
, LCEntry
& entry
) override
;
607 virtual int set_entry(const std::string
& oid
, const LCEntry
& entry
) override
;
608 virtual int list_entries(const std::string
& oid
, const std::string
& marker
,
609 uint32_t max_entries
, std::vector
<LCEntry
>& entries
) override
;
610 virtual int rm_entry(const std::string
& oid
, const LCEntry
& entry
) override
;
611 virtual int get_head(const std::string
& oid
, LCHead
& head
) override
;
612 virtual int put_head(const std::string
& oid
, const LCHead
& head
) override
;
613 virtual LCSerializer
* get_serializer(const std::string
& lock_name
, const std::string
& oid
, const std::string
& cookie
) override
;
616 class RadosNotification
: public Notification
{
618 /* XXX it feels incorrect to me that rgw::notify::reservation_t is
619 * currently RADOS-specific; instead, I think notification types such as
620 * reservation_t should be generally visible, whereas the internal
621 * notification behavior should be made portable (e.g., notification
622 * to non-RADOS message sinks) */
623 rgw::notify::reservation_t res
;
626 RadosNotification(const DoutPrefixProvider
* _dpp
, RadosStore
* _store
, Object
* _obj
, Object
* _src_obj
, req_state
* _s
, rgw::notify::EventType _type
, const std::string
* object_name
=nullptr) :
627 Notification(_obj
, _src_obj
, _type
), store(_store
), res(_dpp
, _store
, _s
, _obj
, _src_obj
, object_name
) { }
629 RadosNotification(const DoutPrefixProvider
* _dpp
, RadosStore
* _store
, Object
* _obj
, Object
* _src_obj
, RGWObjectCtx
* rctx
, rgw::notify::EventType _type
, rgw::sal::Bucket
* _bucket
, std::string
& _user_id
, std::string
& _user_tenant
, std::string
& _req_id
, optional_yield y
) :
630 Notification(_obj
, _src_obj
, _type
), store(_store
), res(_dpp
, _store
, rctx
, _obj
, _src_obj
, _bucket
, _user_id
, _user_tenant
, _req_id
, y
) {}
632 ~RadosNotification() = default;
634 rgw::notify::reservation_t
& get_reservation(void) {
638 virtual int publish_reserve(const DoutPrefixProvider
*dpp
, RGWObjTags
* obj_tags
= nullptr) override
;
639 virtual int publish_commit(const DoutPrefixProvider
* dpp
, uint64_t size
,
640 const ceph::real_time
& mtime
, const std::string
& etag
, const std::string
& version
) override
;
643 class RadosAtomicWriter
: public Writer
{
645 rgw::sal::RadosStore
* store
;
646 std::unique_ptr
<Aio
> aio
;
647 rgw::putobj::AtomicObjectProcessor processor
;
650 RadosAtomicWriter(const DoutPrefixProvider
*dpp
,
652 std::unique_ptr
<rgw::sal::Object
> _head_obj
,
653 RadosStore
* _store
, std::unique_ptr
<Aio
> _aio
,
654 const rgw_user
& owner
, RGWObjectCtx
& obj_ctx
,
655 const rgw_placement_rule
*ptail_placement_rule
,
657 const std::string
& unique_tag
) :
660 aio(std::move(_aio
)),
661 processor(&*aio
, store
,
662 ptail_placement_rule
, owner
, obj_ctx
,
663 std::move(_head_obj
), olh_epoch
, unique_tag
,
666 ~RadosAtomicWriter() = default;
668 // prepare to start processing object data
669 virtual int prepare(optional_yield y
) override
;
671 // Process a bufferlist
672 virtual int process(bufferlist
&& data
, uint64_t offset
) override
;
674 // complete the operation and make its result visible to clients
675 virtual int complete(size_t accounted_size
, const std::string
& etag
,
676 ceph::real_time
*mtime
, ceph::real_time set_mtime
,
677 std::map
<std::string
, bufferlist
>& attrs
,
678 ceph::real_time delete_at
,
679 const char *if_match
, const char *if_nomatch
,
680 const std::string
*user_data
,
681 rgw_zone_set
*zones_trace
, bool *canceled
,
682 optional_yield y
) override
;
685 class RadosAppendWriter
: public Writer
{
687 rgw::sal::RadosStore
* store
;
688 std::unique_ptr
<Aio
> aio
;
689 rgw::putobj::AppendObjectProcessor processor
;
692 RadosAppendWriter(const DoutPrefixProvider
*dpp
,
694 std::unique_ptr
<rgw::sal::Object
> _head_obj
,
695 RadosStore
* _store
, std::unique_ptr
<Aio
> _aio
,
696 const rgw_user
& owner
, RGWObjectCtx
& obj_ctx
,
697 const rgw_placement_rule
*ptail_placement_rule
,
698 const std::string
& unique_tag
,
700 uint64_t *cur_accounted_size
) :
703 aio(std::move(_aio
)),
704 processor(&*aio
, store
,
705 ptail_placement_rule
, owner
, obj_ctx
,
706 std::move(_head_obj
), unique_tag
, position
,
707 cur_accounted_size
, dpp
, y
)
709 ~RadosAppendWriter() = default;
711 // prepare to start processing object data
712 virtual int prepare(optional_yield y
) override
;
714 // Process a bufferlist
715 virtual int process(bufferlist
&& data
, uint64_t offset
) override
;
717 // complete the operation and make its result visible to clients
718 virtual int complete(size_t accounted_size
, const std::string
& etag
,
719 ceph::real_time
*mtime
, ceph::real_time set_mtime
,
720 std::map
<std::string
, bufferlist
>& attrs
,
721 ceph::real_time delete_at
,
722 const char *if_match
, const char *if_nomatch
,
723 const std::string
*user_data
,
724 rgw_zone_set
*zones_trace
, bool *canceled
,
725 optional_yield y
) override
;
728 class RadosMultipartWriter
: public Writer
{
730 rgw::sal::RadosStore
* store
;
731 std::unique_ptr
<Aio
> aio
;
732 rgw::putobj::MultipartObjectProcessor processor
;
735 RadosMultipartWriter(const DoutPrefixProvider
*dpp
,
736 optional_yield y
, MultipartUpload
* upload
,
737 std::unique_ptr
<rgw::sal::Object
> _head_obj
,
738 RadosStore
* _store
, std::unique_ptr
<Aio
> _aio
,
739 const rgw_user
& owner
, RGWObjectCtx
& obj_ctx
,
740 const rgw_placement_rule
*ptail_placement_rule
,
741 uint64_t part_num
, const std::string
& part_num_str
) :
744 aio(std::move(_aio
)),
745 processor(&*aio
, store
,
746 ptail_placement_rule
, owner
, obj_ctx
,
747 std::move(_head_obj
), upload
->get_upload_id(),
748 part_num
, part_num_str
, dpp
, y
)
750 ~RadosMultipartWriter() = default;
752 // prepare to start processing object data
753 virtual int prepare(optional_yield y
) override
;
755 // Process a bufferlist
756 virtual int process(bufferlist
&& data
, uint64_t offset
) override
;
758 // complete the operation and make its result visible to clients
759 virtual int complete(size_t accounted_size
, const std::string
& etag
,
760 ceph::real_time
*mtime
, ceph::real_time set_mtime
,
761 std::map
<std::string
, bufferlist
>& attrs
,
762 ceph::real_time delete_at
,
763 const char *if_match
, const char *if_nomatch
,
764 const std::string
*user_data
,
765 rgw_zone_set
*zones_trace
, bool *canceled
,
766 optional_yield y
) override
;
769 class RadosLuaScriptManager
: public LuaScriptManager
{
774 RadosLuaScriptManager(RadosStore
* _s
) : store(_s
)
776 pool
= store
->get_zone()->get_params().log_pool
;
778 virtual ~RadosLuaScriptManager() = default;
780 virtual int get(const DoutPrefixProvider
* dpp
, optional_yield y
, const std::string
& key
, std::string
& script
) override
;
781 virtual int put(const DoutPrefixProvider
* dpp
, optional_yield y
, const std::string
& key
, const std::string
& script
) override
;
782 virtual int del(const DoutPrefixProvider
* dpp
, optional_yield y
, const std::string
& key
) override
;
785 class RadosOIDCProvider
: public RGWOIDCProvider
{
788 RadosOIDCProvider(RadosStore
* _store
) : store(_store
) {}
789 ~RadosOIDCProvider() = default;
791 virtual int store_url(const DoutPrefixProvider
*dpp
, const std::string
& url
, bool exclusive
, optional_yield y
) override
;
792 virtual int read_url(const DoutPrefixProvider
*dpp
, const std::string
& url
, const std::string
& tenant
) override
;
793 virtual int delete_obj(const DoutPrefixProvider
*dpp
, optional_yield y
) override
;
794 void encode(bufferlist
& bl
) const {
795 RGWOIDCProvider::encode(bl
);
797 void decode(bufferlist::const_iterator
& bl
) {
798 RGWOIDCProvider::decode(bl
);
802 class RadosRole
: public RGWRole
{
805 RadosRole(RadosStore
* _store
, std::string name
,
808 std::string trust_policy
,
809 std::string max_session_duration
,
810 std::multimap
<std::string
,std::string
> tags
) : RGWRole(name
, tenant
, path
, trust_policy
, max_session_duration
, tags
), store(_store
) {}
811 RadosRole(RadosStore
* _store
, std::string id
) : RGWRole(id
), store(_store
) {}
812 ~RadosRole() = default;
814 virtual int store_info(const DoutPrefixProvider
*dpp
, bool exclusive
, optional_yield y
) override
;
815 virtual int store_name(const DoutPrefixProvider
*dpp
, bool exclusive
, optional_yield y
) override
;
816 virtual int store_path(const DoutPrefixProvider
*dpp
, bool exclusive
, optional_yield y
) override
;
817 virtual int read_id(const DoutPrefixProvider
*dpp
, const std::string
& role_name
, const std::string
& tenant
, std::string
& role_id
, optional_yield y
) override
;
818 virtual int read_name(const DoutPrefixProvider
*dpp
, optional_yield y
) override
;
819 virtual int read_info(const DoutPrefixProvider
*dpp
, optional_yield y
) override
;
820 virtual int create(const DoutPrefixProvider
*dpp
, bool exclusive
, optional_yield y
) override
;
821 virtual int delete_obj(const DoutPrefixProvider
*dpp
, optional_yield y
) override
;
824 } } // namespace rgw::sal
826 WRITE_CLASS_ENCODER(rgw::sal::RadosOIDCProvider
)