1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
4 #ifndef CEPH_RGWRADOS_H
5 #define CEPH_RGWRADOS_H
8 #include <boost/container/flat_map.hpp>
10 #include "include/rados/librados.hpp"
11 #include "include/Context.h"
12 #include "common/RefCountedObj.h"
13 #include "common/RWLock.h"
14 #include "common/ceph_time.h"
15 #include "rgw_common.h"
16 #include "cls/rgw/cls_rgw_types.h"
17 #include "cls/version/cls_version_types.h"
18 #include "cls/log/cls_log_types.h"
19 #include "cls/timeindex/cls_timeindex_types.h"
20 #include "cls/otp/cls_otp_types.h"
22 #include "rgw_metadata.h"
23 #include "rgw_meta_sync_status.h"
24 #include "rgw_period_puller.h"
25 #include "rgw_obj_manifest.h"
26 #include "rgw_sync_module.h"
27 #include "rgw_trim_bilog.h"
28 #include "rgw_service.h"
31 #include "services/svc_rados.h"
32 #include "services/svc_bi_rados.h"
38 class RGWMetaNotifier
;
39 class RGWDataNotifier
;
41 class RGWObjectExpirer
;
42 class RGWMetaSyncProcessorThread
;
43 class RGWDataSyncProcessorThread
;
44 class RGWSyncLogTrimThread
;
45 class RGWSyncTraceManager
;
51 class RGWSysObjectCtx
;
53 /* flags for put_obj_meta() */
54 #define PUT_OBJ_CREATE 0x01
55 #define PUT_OBJ_EXCL 0x02
56 #define PUT_OBJ_CREATE_EXCL (PUT_OBJ_CREATE | PUT_OBJ_EXCL)
58 #define RGW_OBJ_NS_MULTIPART "multipart"
59 #define RGW_OBJ_NS_SHADOW "shadow"
61 static inline void prepend_bucket_marker(const rgw_bucket
& bucket
, const string
& orig_oid
, string
& oid
)
63 if (bucket
.marker
.empty() || orig_oid
.empty()) {
72 static inline void get_obj_bucket_and_oid_loc(const rgw_obj
& obj
, string
& oid
, string
& locator
)
74 const rgw_bucket
& bucket
= obj
.bucket
;
75 prepend_bucket_marker(bucket
, obj
.get_oid(), oid
);
76 const string
& loc
= obj
.key
.get_loc();
78 prepend_bucket_marker(bucket
, loc
, locator
);
84 int rgw_policy_from_attrset(const DoutPrefixProvider
*dpp
, CephContext
*cct
, map
<string
, bufferlist
>& attrset
, RGWAccessControlPolicy
*policy
);
90 RGWOLHInfo() : removed(false) {}
92 void encode(bufferlist
& bl
) const {
93 ENCODE_START(1, 1, bl
);
99 void decode(bufferlist::const_iterator
& bl
) {
105 static void generate_test_instances(list
<RGWOLHInfo
*>& o
);
106 void dump(Formatter
*f
) const;
108 WRITE_CLASS_ENCODER(RGWOLHInfo
)
110 struct RGWOLHPendingInfo
{
111 ceph::real_time time
;
113 RGWOLHPendingInfo() {}
115 void encode(bufferlist
& bl
) const {
116 ENCODE_START(1, 1, bl
);
121 void decode(bufferlist::const_iterator
& bl
) {
127 void dump(Formatter
*f
) const;
129 WRITE_CLASS_ENCODER(RGWOLHPendingInfo
)
131 struct RGWUsageBatch
{
132 map
<ceph::real_time
, rgw_usage_log_entry
> m
;
134 void insert(ceph::real_time
& t
, rgw_usage_log_entry
& entry
, bool *account
) {
135 bool exists
= m
.find(t
) != m
.end();
137 m
[t
].aggregate(entry
);
143 virtual int handle_data(bufferlist
& bl
, off_t bl_ofs
, off_t bl_len
) = 0;
145 virtual ~RGWGetDataCB() {}
148 struct RGWCloneRangeInfo
{
157 bool is_atomic
{false};
158 bool has_attrs
{false};
160 uint64_t size
{0}; //< size of raw object
161 uint64_t accounted_size
{0}; //< size before compression, encryption
162 ceph::real_time mtime
;
167 bool fake_tag
{false};
168 std::optional
<RGWObjManifest
> manifest
;
170 bool has_data
{false};
172 bool prefetch_data
{false};
173 bool keep_tail
{false};
176 uint64_t pg_ver
{false};
177 uint32_t zone_short_id
{0};
179 /* important! don't forget to update copy constructor */
181 RGWObjVersionTracker objv_tracker
;
183 map
<string
, bufferlist
> attrset
;
186 RGWObjState(const RGWObjState
& rhs
);
189 bool get_attr(string name
, bufferlist
& dest
) {
190 map
<string
, bufferlist
>::iterator iter
= attrset
.find(name
);
191 if (iter
!= attrset
.end()) {
199 class RGWFetchObjFilter
{
201 virtual ~RGWFetchObjFilter() {}
203 virtual int filter(CephContext
*cct
,
204 const rgw_obj_key
& source_key
,
205 const RGWBucketInfo
& dest_bucket_info
,
206 std::optional
<rgw_placement_rule
> dest_placement_rule
,
207 const map
<string
, bufferlist
>& obj_attrs
,
208 std::optional
<rgw_user
> *poverride_owner
,
209 const rgw_placement_rule
**prule
) = 0;
212 class RGWFetchObjFilter_Default
: public RGWFetchObjFilter
{
214 rgw_placement_rule dest_rule
;
216 RGWFetchObjFilter_Default() {}
218 int filter(CephContext
*cct
,
219 const rgw_obj_key
& source_key
,
220 const RGWBucketInfo
& dest_bucket_info
,
221 std::optional
<rgw_placement_rule
> dest_placement_rule
,
222 const map
<string
, bufferlist
>& obj_attrs
,
223 std::optional
<rgw_user
> *poverride_owner
,
224 const rgw_placement_rule
**prule
) override
;
228 rgw::sal::RGWRadosStore
*store
;
229 ceph::shared_mutex lock
= ceph::make_shared_mutex("RGWObjectCtx");
232 std::map
<rgw_obj
, RGWObjState
> objs_state
;
234 explicit RGWObjectCtx(rgw::sal::RGWRadosStore
*_store
) : store(_store
) {}
235 explicit RGWObjectCtx(rgw::sal::RGWRadosStore
*_store
, void *_s
) : store(_store
), s(_s
) {}
237 void *get_private() {
241 rgw::sal::RGWRadosStore
*get_store() {
245 RGWObjState
*get_state(const rgw_obj
& obj
);
247 void set_atomic(rgw_obj
& obj
);
248 void set_prefetch_data(const rgw_obj
& obj
);
249 void invalidate(const rgw_obj
& obj
);
253 struct RGWRawObjState
{
255 bool has_attrs
{false};
258 ceph::real_time mtime
;
261 bool has_data
{false};
263 bool prefetch_data
{false};
266 /* important! don't forget to update copy constructor */
268 RGWObjVersionTracker objv_tracker
;
270 map
<string
, bufferlist
> attrset
;
272 RGWRawObjState(const RGWRawObjState
& rhs
) : obj (rhs
.obj
) {
273 has_attrs
= rhs
.has_attrs
;
278 if (rhs
.obj_tag
.length()) {
279 obj_tag
= rhs
.obj_tag
;
281 has_data
= rhs
.has_data
;
282 if (rhs
.data
.length()) {
285 prefetch_data
= rhs
.prefetch_data
;
287 objv_tracker
= rhs
.objv_tracker
;
291 struct RGWPoolIterCtx
{
292 librados::IoCtx io_ctx
;
293 librados::NObjectIterator iter
;
296 struct RGWListRawObjsCtx
{
298 RGWPoolIterCtx iter_ctx
;
300 RGWListRawObjsCtx() : initialized(false) {}
303 struct objexp_hint_entry
{
308 ceph::real_time exp_time
;
310 void encode(bufferlist
& bl
) const {
311 ENCODE_START(2, 1, bl
);
312 encode(bucket_name
, bl
);
313 encode(bucket_id
, bl
);
315 encode(exp_time
, bl
);
320 void decode(bufferlist::const_iterator
& bl
) {
321 // XXX Do we want DECODE_START_LEGACY_COMPAT_LEN(2, 1, 1, bl); ?
323 decode(bucket_name
, bl
);
324 decode(bucket_id
, bl
);
326 decode(exp_time
, bl
);
335 void dump(Formatter
*f
) const;
336 static void generate_test_instances(list
<objexp_hint_entry
*>& o
);
338 WRITE_CLASS_ENCODER(objexp_hint_entry
)
340 class RGWDataChangesLog
;
341 class RGWMetaSyncStatusManager
;
342 class RGWDataSyncStatusManager
;
343 class RGWCoroutinesManagerRegistry
;
345 class RGWGetBucketStats_CB
: public RefCountedObject
{
348 map
<RGWObjCategory
, RGWStorageStats
> *stats
;
350 explicit RGWGetBucketStats_CB(const rgw_bucket
& _bucket
) : bucket(_bucket
), stats(NULL
) {}
351 ~RGWGetBucketStats_CB() override
{}
352 virtual void handle_response(int r
) = 0;
353 virtual void set_response(map
<RGWObjCategory
, RGWStorageStats
> *_stats
) {
358 class RGWGetUserStats_CB
: public RefCountedObject
{
361 RGWStorageStats stats
;
363 explicit RGWGetUserStats_CB(const rgw_user
& _user
) : user(_user
) {}
364 ~RGWGetUserStats_CB() override
{}
365 virtual void handle_response(int r
) = 0;
366 virtual void set_response(RGWStorageStats
& _stats
) {
371 class RGWGetDirHeader_CB
;
372 class RGWGetUserHeader_CB
;
373 namespace rgw
{ namespace sal
{
375 class MPRadosSerializer
;
376 class LCRadosSerializer
;
379 class RGWAsyncRadosProcessor
;
382 class RGWChainedCacheImpl
;
384 struct bucket_info_entry
{
387 map
<string
, bufferlist
> attrs
;
390 struct tombstone_entry
;
392 template <class K
, class V
>
394 using tombstone_cache_t
= lru_map
<rgw_obj
, tombstone_entry
>;
396 class RGWIndexCompletionManager
;
401 friend class RGWMetaNotifier
;
402 friend class RGWDataNotifier
;
403 friend class RGWObjectExpirer
;
404 friend class RGWMetaSyncProcessorThread
;
405 friend class RGWDataSyncProcessorThread
;
406 friend class RGWReshard
;
407 friend class RGWBucketReshard
;
408 friend class RGWBucketReshardLock
;
409 friend class BucketIndexLockGuard
;
410 friend class rgw::sal::MPRadosSerializer
;
411 friend class rgw::sal::LCRadosSerializer
;
412 friend class rgw::sal::RGWRadosStore
;
414 /** Open the pool used as root for this gateway */
415 int open_root_pool_ctx(const DoutPrefixProvider
*dpp
);
416 int open_gc_pool_ctx(const DoutPrefixProvider
*dpp
);
417 int open_lc_pool_ctx(const DoutPrefixProvider
*dpp
);
418 int open_objexp_pool_ctx(const DoutPrefixProvider
*dpp
);
419 int open_reshard_pool_ctx(const DoutPrefixProvider
*dpp
);
420 int open_notif_pool_ctx(const DoutPrefixProvider
*dpp
);
422 int open_pool_ctx(const DoutPrefixProvider
*dpp
, const rgw_pool
& pool
, librados::IoCtx
& io_ctx
,
425 std::atomic
<int64_t> max_req_id
= { 0 };
426 ceph::mutex lock
= ceph::make_mutex("rados_timer_lock");
429 rgw::sal::RGWRadosStore
*store
;
432 RGWObjectExpirer
*obj_expirer
;
436 bool run_sync_thread
;
437 bool run_reshard_thread
;
439 RGWMetaNotifier
*meta_notifier
;
440 RGWDataNotifier
*data_notifier
;
441 RGWMetaSyncProcessorThread
*meta_sync_processor_thread
;
442 RGWSyncTraceManager
*sync_tracer
= nullptr;
443 map
<rgw_zone_id
, RGWDataSyncProcessorThread
*> data_sync_processor_threads
;
445 boost::optional
<rgw::BucketTrimManager
> bucket_trim
;
446 RGWSyncLogTrimThread
*sync_log_trimmer
{nullptr};
448 ceph::mutex meta_sync_thread_lock
= ceph::make_mutex("meta_sync_thread_lock");
449 ceph::mutex data_sync_thread_lock
= ceph::make_mutex("data_sync_thread_lock");
451 librados::IoCtx root_pool_ctx
; // .rgw
453 double inject_notify_timeout_probability
= 0;
454 unsigned max_notify_retries
= 0;
456 friend class RGWWatcher
;
458 ceph::mutex bucket_id_lock
= ceph::make_mutex("rados_bucket_id");
460 // This field represents the number of bucket index object shards
461 uint32_t bucket_index_max_shards
;
463 int get_obj_head_ref(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, rgw_rados_ref
*ref
);
464 int get_system_obj_ref(const DoutPrefixProvider
*dpp
, const rgw_raw_obj
& obj
, rgw_rados_ref
*ref
);
465 uint64_t max_bucket_id
;
467 int get_olh_target_state(const DoutPrefixProvider
*dpp
, RGWObjectCtx
& rctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
,
468 RGWObjState
*olh_state
, RGWObjState
**target_state
, optional_yield y
);
469 int get_obj_state_impl(const DoutPrefixProvider
*dpp
, RGWObjectCtx
*rctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, RGWObjState
**state
,
470 bool follow_olh
, optional_yield y
, bool assume_noent
= false);
471 int append_atomic_test(const DoutPrefixProvider
*dpp
, RGWObjectCtx
*rctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
,
472 librados::ObjectOperation
& op
, RGWObjState
**state
, optional_yield y
);
473 int append_atomic_test(const DoutPrefixProvider
*dpp
, const RGWObjState
* astate
, librados::ObjectOperation
& op
);
475 int update_placement_map();
476 int store_bucket_info(RGWBucketInfo
& info
, map
<string
, bufferlist
> *pattrs
, RGWObjVersionTracker
*objv_tracker
, bool exclusive
);
478 void remove_rgw_head_obj(librados::ObjectWriteOperation
& op
);
479 void cls_obj_check_prefix_exist(librados::ObjectOperation
& op
, const string
& prefix
, bool fail_if_exist
);
480 void cls_obj_check_mtime(librados::ObjectOperation
& op
, const real_time
& mtime
, bool high_precision_time
, RGWCheckMTimeType type
);
484 librados::Rados rados
;
486 using RGWChainedCacheImpl_bucket_info_entry
= RGWChainedCacheImpl
<bucket_info_entry
>;
487 RGWChainedCacheImpl_bucket_info_entry
*binfo_cache
;
489 tombstone_cache_t
*obj_tombstone_cache
;
491 librados::IoCtx gc_pool_ctx
; // .rgw.gc
492 librados::IoCtx lc_pool_ctx
; // .rgw.lc
493 librados::IoCtx objexp_pool_ctx
;
494 librados::IoCtx reshard_pool_ctx
;
495 librados::IoCtx notif_pool_ctx
; // .rgw.notif
497 bool pools_initialized
;
499 RGWQuotaHandler
*quota_handler
;
501 RGWCoroutinesManagerRegistry
*cr_registry
;
503 RGWSyncModuleInstanceRef sync_module
;
504 bool writeable_zone
{false};
506 RGWIndexCompletionManager
*index_completion_manager
{nullptr};
508 bool use_cache
{false};
511 int get_obj_head_ioctx(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, librados::IoCtx
*ioctx
);
513 RGWRados(): timer(NULL
),
514 gc(NULL
), lc(NULL
), obj_expirer(NULL
), use_gc_thread(false), use_lc_thread(false), quota_threads(false),
515 run_sync_thread(false), run_reshard_thread(false), meta_notifier(NULL
),
516 data_notifier(NULL
), meta_sync_processor_thread(NULL
),
517 bucket_index_max_shards(0),
518 max_bucket_id(0), cct(NULL
),
519 binfo_cache(NULL
), obj_tombstone_cache(nullptr),
520 pools_initialized(false),
526 RGWRados
& set_use_cache(bool status
) {
531 RGWRados
& set_use_gc(bool status
) {
540 RGWRados
& set_run_gc_thread(bool _use_gc_thread
) {
541 use_gc_thread
= _use_gc_thread
;
545 RGWRados
& set_run_lc_thread(bool _use_lc_thread
) {
546 use_lc_thread
= _use_lc_thread
;
550 RGWRados
& set_run_quota_threads(bool _run_quota_threads
) {
551 quota_threads
= _run_quota_threads
;
555 RGWRados
& set_run_sync_thread(bool _run_sync_thread
) {
556 run_sync_thread
= _run_sync_thread
;
560 RGWRados
& set_run_reshard_thread(bool _run_reshard_thread
) {
561 run_reshard_thread
= _run_reshard_thread
;
565 uint64_t get_new_req_id() {
569 librados::IoCtx
* get_lc_pool_ctx() {
573 librados::IoCtx
& get_notif_pool_ctx() {
574 return notif_pool_ctx
;
577 void set_context(CephContext
*_cct
) {
580 void set_store(rgw::sal::RGWRadosStore
*_store
) {
587 RGWCtl
*pctl
{nullptr};
590 * AmazonS3 errors contain a HostId string, but is an opaque base64 blob; we
591 * try to be more transparent. This has a wrapper so we can update it when zonegroup/zone are changed.
596 std::shared_ptr
<RGWReshardWait
> reshard_wait
;
598 virtual ~RGWRados() = default;
600 tombstone_cache_t
*get_tombstone_cache() {
601 return obj_tombstone_cache
;
603 const RGWSyncModuleInstanceRef
& get_sync_module() {
606 RGWSyncTraceManager
*get_sync_tracer() {
610 int get_required_alignment(const DoutPrefixProvider
*dpp
, const rgw_pool
& pool
, uint64_t *alignment
);
611 void get_max_aligned_size(uint64_t size
, uint64_t alignment
, uint64_t *max_size
);
612 int get_max_chunk_size(const rgw_pool
& pool
, uint64_t *max_chunk_size
, const DoutPrefixProvider
*dpp
, uint64_t *palignment
= nullptr);
613 int get_max_chunk_size(const rgw_placement_rule
& placement_rule
, const rgw_obj
& obj
, uint64_t *max_chunk_size
, const DoutPrefixProvider
*dpp
, uint64_t *palignment
= nullptr);
615 uint32_t get_max_bucket_shards() {
616 return RGWSI_BucketIndex_RADOS::shards_max();
620 int get_raw_obj_ref(const DoutPrefixProvider
*dpp
, const rgw_raw_obj
& obj
, rgw_rados_ref
*ref
);
622 int list_raw_objects_init(const DoutPrefixProvider
*dpp
, const rgw_pool
& pool
, const string
& marker
, RGWListRawObjsCtx
*ctx
);
623 int list_raw_objects_next(const DoutPrefixProvider
*dpp
, const string
& prefix_filter
, int max
,
624 RGWListRawObjsCtx
& ctx
, list
<string
>& oids
,
626 int list_raw_objects(const DoutPrefixProvider
*dpp
, const rgw_pool
& pool
, const string
& prefix_filter
, int max
,
627 RGWListRawObjsCtx
& ctx
, list
<string
>& oids
,
629 string
list_raw_objs_get_cursor(RGWListRawObjsCtx
& ctx
);
631 CephContext
*ctx() { return cct
; }
632 /** do all necessary setup of the storage device */
633 int initialize(CephContext
*_cct
, const DoutPrefixProvider
*dpp
) {
635 return initialize(dpp
);
637 /** Initialize the RADOS instance and prepare to do other ops */
638 int init_svc(bool raw
, const DoutPrefixProvider
*dpp
);
639 int init_ctl(const DoutPrefixProvider
*dpp
);
641 int init_complete(const DoutPrefixProvider
*dpp
);
642 int initialize(const DoutPrefixProvider
*dpp
);
645 int register_to_service_map(const string
& daemon_type
, const map
<string
, string
>& meta
);
646 int update_service_map(std::map
<std::string
, std::string
>&& status
);
649 int log_list_init(const DoutPrefixProvider
*dpp
, const string
& prefix
, RGWAccessHandle
*handle
);
650 int log_list_next(RGWAccessHandle handle
, string
*name
);
653 int log_remove(const DoutPrefixProvider
*dpp
, const string
& name
);
656 int log_show_init(const DoutPrefixProvider
*dpp
, const string
& name
, RGWAccessHandle
*handle
);
657 int log_show_next(RGWAccessHandle handle
, rgw_log_entry
*entry
);
659 // log bandwidth info
660 int log_usage(const DoutPrefixProvider
*dpp
, map
<rgw_user_bucket
, RGWUsageBatch
>& usage_info
);
661 int read_usage(const DoutPrefixProvider
*dpp
, const rgw_user
& user
, const string
& bucket_name
, uint64_t start_epoch
, uint64_t end_epoch
,
662 uint32_t max_entries
, bool *is_truncated
, RGWUsageIter
& read_iter
, map
<rgw_user_bucket
,
663 rgw_usage_log_entry
>& usage
);
664 int trim_usage(const DoutPrefixProvider
*dpp
, const rgw_user
& user
, const string
& bucket_name
, uint64_t start_epoch
, uint64_t end_epoch
);
665 int clear_usage(const DoutPrefixProvider
*dpp
);
667 int create_pool(const DoutPrefixProvider
*dpp
, const rgw_pool
& pool
);
669 void create_bucket_id(string
*bucket_id
);
671 bool get_obj_data_pool(const rgw_placement_rule
& placement_rule
, const rgw_obj
& obj
, rgw_pool
*pool
);
672 bool obj_to_raw(const rgw_placement_rule
& placement_rule
, const rgw_obj
& obj
, rgw_raw_obj
*raw_obj
);
674 int create_bucket(const RGWUserInfo
& owner
, rgw_bucket
& bucket
,
675 const string
& zonegroup_id
,
676 const rgw_placement_rule
& placement_rule
,
677 const string
& swift_ver_location
,
678 const RGWQuotaInfo
* pquota_info
,
679 map
<std::string
,bufferlist
>& attrs
,
680 RGWBucketInfo
& bucket_info
,
682 obj_version
*pep_objv
,
683 ceph::real_time creation_time
,
684 rgw_bucket
*master_bucket
,
685 uint32_t *master_num_shards
,
687 const DoutPrefixProvider
*dpp
,
688 bool exclusive
= true);
690 RGWCoroutinesManagerRegistry
*get_cr_registry() { return cr_registry
; }
696 RGWSI_RADOS::Obj bucket_obj
;
698 explicit BucketShard(RGWRados
*_store
) : store(_store
), shard_id(-1) {}
699 int init(const rgw_bucket
& _bucket
, const rgw_obj
& obj
, RGWBucketInfo
* out
, const DoutPrefixProvider
*dpp
);
700 int init(const rgw_bucket
& _bucket
, int sid
, const rgw::bucket_index_layout_generation
& idx_layout
, RGWBucketInfo
* out
, const DoutPrefixProvider
*dpp
);
701 int init(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
);
702 int init(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw::bucket_index_layout_generation
& idx_layout
, int sid
);
707 RGWBucketInfo bucket_info
;
715 bool versioning_disabled
;
720 int get_state(const DoutPrefixProvider
*dpp
, RGWObjState
**pstate
, bool follow_olh
, optional_yield y
, bool assume_noent
= false);
721 void invalidate_state();
723 int prepare_atomic_modification(const DoutPrefixProvider
*dpp
, librados::ObjectWriteOperation
& op
, bool reset_obj
, const string
*ptag
,
724 const char *ifmatch
, const char *ifnomatch
, bool removal_op
, bool modify_tail
, optional_yield y
);
725 int complete_atomic_modification(const DoutPrefixProvider
*dpp
);
728 Object(RGWRados
*_store
, const RGWBucketInfo
& _bucket_info
, RGWObjectCtx
& _ctx
, const rgw_obj
& _obj
) : store(_store
), bucket_info(_bucket_info
),
729 ctx(_ctx
), obj(_obj
), bs(store
),
730 state(NULL
), versioning_disabled(false),
731 bs_initialized(false) {}
733 RGWRados
*get_store() { return store
; }
734 rgw_obj
& get_obj() { return obj
; }
735 RGWObjectCtx
& get_ctx() { return ctx
; }
736 RGWBucketInfo
& get_bucket_info() { return bucket_info
; }
737 int get_manifest(const DoutPrefixProvider
*dpp
, RGWObjManifest
**pmanifest
, optional_yield y
);
739 int get_bucket_shard(BucketShard
**pbs
, const DoutPrefixProvider
*dpp
) {
740 if (!bs_initialized
) {
742 bs
.init(bucket_info
.bucket
, obj
, nullptr /* no RGWBucketInfo */, dpp
);
746 bs_initialized
= true;
752 void set_versioning_disabled(bool status
) {
753 versioning_disabled
= status
;
756 bool versioning_enabled() {
757 return (!versioning_disabled
&& bucket_info
.versioning_enabled());
761 RGWRados::Object
*source
;
764 map
<rgw_pool
, librados::IoCtx
> io_ctxs
;
766 librados::IoCtx
*cur_ioctx
{nullptr};
768 rgw_raw_obj head_obj
;
771 struct ConditionParams
{
772 const ceph::real_time
*mod_ptr
;
773 const ceph::real_time
*unmod_ptr
;
774 bool high_precision_time
;
775 uint32_t mod_zone_id
;
777 const char *if_match
;
778 const char *if_nomatch
;
781 mod_ptr(NULL
), unmod_ptr(NULL
), high_precision_time(false), mod_zone_id(0), mod_pg_ver(0),
782 if_match(NULL
), if_nomatch(NULL
) {}
786 ceph::real_time
*lastmod
;
788 map
<string
, bufferlist
> *attrs
;
791 Params() : lastmod(nullptr), obj_size(nullptr), attrs(nullptr),
792 target_obj(nullptr) {}
795 explicit Read(RGWRados::Object
*_source
) : source(_source
) {}
797 int prepare(optional_yield y
, const DoutPrefixProvider
*dpp
);
798 static int range_to_ofs(uint64_t obj_size
, int64_t &ofs
, int64_t &end
);
799 int read(int64_t ofs
, int64_t end
, bufferlist
& bl
, optional_yield y
, const DoutPrefixProvider
*dpp
);
800 int iterate(const DoutPrefixProvider
*dpp
, int64_t ofs
, int64_t end
, RGWGetDataCB
*cb
, optional_yield y
);
801 int get_attr(const DoutPrefixProvider
*dpp
, const char *name
, bufferlist
& dest
, optional_yield y
);
805 RGWRados::Object
*target
;
808 ceph::real_time
*mtime
;
809 map
<std::string
, bufferlist
>* rmattrs
;
810 const bufferlist
*data
;
811 RGWObjManifest
*manifest
;
813 list
<rgw_obj_index_key
> *remove_objs
;
814 ceph::real_time set_mtime
;
816 RGWObjCategory category
;
818 const char *if_match
;
819 const char *if_nomatch
;
820 std::optional
<uint64_t> olh_epoch
;
821 ceph::real_time delete_at
;
823 const string
*user_data
;
824 rgw_zone_set
*zones_trace
;
826 bool completeMultipart
;
829 MetaParams() : mtime(NULL
), rmattrs(NULL
), data(NULL
), manifest(NULL
), ptag(NULL
),
830 remove_objs(NULL
), category(RGWObjCategory::Main
), flags(0),
831 if_match(NULL
), if_nomatch(NULL
), canceled(false), user_data(nullptr), zones_trace(nullptr),
832 modify_tail(false), completeMultipart(false), appendable(false) {}
835 explicit Write(RGWRados::Object
*_target
) : target(_target
) {}
837 int _do_write_meta(const DoutPrefixProvider
*dpp
,
838 uint64_t size
, uint64_t accounted_size
,
839 map
<std::string
, bufferlist
>& attrs
,
840 bool modify_tail
, bool assume_noent
,
841 void *index_op
, optional_yield y
);
842 int write_meta(const DoutPrefixProvider
*dpp
, uint64_t size
, uint64_t accounted_size
,
843 map
<std::string
, bufferlist
>& attrs
, optional_yield y
);
844 int write_data(const char *data
, uint64_t ofs
, uint64_t len
, bool exclusive
);
845 const req_state
* get_req_state() {
846 return (req_state
*)target
->get_ctx().get_private();
851 RGWRados::Object
*target
;
853 struct DeleteParams
{
854 rgw_user bucket_owner
;
855 int versioning_status
; // versioning flags in enum RGWBucketFlags
856 ACLOwner obj_owner
; // needed for creation of deletion marker
858 string marker_version_id
;
859 uint32_t bilog_flags
;
860 list
<rgw_obj_index_key
> *remove_objs
;
861 ceph::real_time expiration_time
;
862 ceph::real_time unmod_since
;
863 ceph::real_time mtime
; /* for setting delete marker mtime */
864 bool high_precision_time
;
865 rgw_zone_set
*zones_trace
;
867 uint64_t parts_accounted_size
;
869 DeleteParams() : versioning_status(0), olh_epoch(0), bilog_flags(0), remove_objs(NULL
), high_precision_time(false), zones_trace(nullptr), abortmp(false), parts_accounted_size(0) {}
872 struct DeleteResult
{
876 DeleteResult() : delete_marker(false) {}
879 explicit Delete(RGWRados::Object
*_target
) : target(_target
) {}
881 int delete_obj(optional_yield y
, const DoutPrefixProvider
*dpp
);
885 RGWRados::Object
*source
;
889 std::optional
<RGWObjManifest
> manifest
;
891 struct timespec mtime
{};
892 map
<string
, bufferlist
> attrs
;
896 librados::IoCtx io_ctx
;
897 librados::AioCompletion
*completion
;
900 State() : completion(NULL
), ret(0) {}
904 explicit Stat(RGWRados::Object
*_source
) : source(_source
) {}
906 int stat_async(const DoutPrefixProvider
*dpp
);
916 RGWBucketInfo bucket_info
;
921 Bucket(RGWRados
*_store
, const RGWBucketInfo
& _bucket_info
) : store(_store
), bucket_info(_bucket_info
), bucket(bucket_info
.bucket
),
922 shard_id(RGW_NO_SHARD
) {}
923 RGWRados
*get_store() { return store
; }
924 rgw_bucket
& get_bucket() { return bucket
; }
925 RGWBucketInfo
& get_bucket_info() { return bucket_info
; }
927 int update_bucket_id(const string
& new_bucket_id
, const DoutPrefixProvider
*dpp
);
929 int get_shard_id() { return shard_id
; }
930 void set_shard_id(int id
) {
935 RGWRados::Bucket
*target
;
938 uint16_t bilog_flags
{0};
940 bool bs_initialized
{false};
942 bool prepared
{false};
943 rgw_zone_set
*zones_trace
{nullptr};
945 int init_bs(const DoutPrefixProvider
*dpp
) {
947 bs
.init(target
->get_bucket(), obj
, nullptr /* no RGWBucketInfo */, dpp
);
951 bs_initialized
= true;
955 void invalidate_bs() {
956 bs_initialized
= false;
959 int guard_reshard(const DoutPrefixProvider
*dpp
, BucketShard
**pbs
, std::function
<int(BucketShard
*)> call
);
962 UpdateIndex(RGWRados::Bucket
*_target
, const rgw_obj
& _obj
) : target(_target
), obj(_obj
),
963 bs(target
->get_store()) {
964 blind
= (target
->get_bucket_info().layout
.current_index
.layout
.type
== rgw::BucketIndexType::Indexless
);
967 int get_bucket_shard(BucketShard
**pbs
, const DoutPrefixProvider
*dpp
) {
968 if (!bs_initialized
) {
969 int r
= init_bs(dpp
);
978 void set_bilog_flags(uint16_t flags
) {
982 void set_zones_trace(rgw_zone_set
*_zones_trace
) {
983 zones_trace
= _zones_trace
;
986 int prepare(const DoutPrefixProvider
*dpp
, RGWModifyOp
, const string
*write_tag
, optional_yield y
);
987 int complete(const DoutPrefixProvider
*dpp
, int64_t poolid
, uint64_t epoch
, uint64_t size
,
988 uint64_t accounted_size
, ceph::real_time
& ut
,
989 const string
& etag
, const string
& content_type
,
990 const string
& storage_class
,
991 bufferlist
*acl_bl
, RGWObjCategory category
,
992 list
<rgw_obj_index_key
> *remove_objs
, const string
*user_data
= nullptr, bool appendable
= false);
993 int complete_del(const DoutPrefixProvider
*dpp
,
994 int64_t poolid
, uint64_t epoch
,
995 ceph::real_time
& removed_mtime
, /* mtime of removed object */
996 list
<rgw_obj_index_key
> *remove_objs
);
997 int cancel(const DoutPrefixProvider
*dpp
);
999 const string
*get_optag() { return &optag
; }
1001 bool is_prepared() { return prepared
; }
1002 }; // class UpdateIndex
1006 // absolute maximum number of objects that
1007 // list_objects_(un)ordered can return
1008 static constexpr int64_t bucket_list_objects_absolute_max
= 25000;
1010 RGWRados::Bucket
*target
;
1011 rgw_obj_key next_marker
;
1013 int list_objects_ordered(const DoutPrefixProvider
*dpp
,
1015 vector
<rgw_bucket_dir_entry
> *result
,
1016 map
<string
, bool> *common_prefixes
,
1019 int list_objects_unordered(const DoutPrefixProvider
*dpp
,
1021 vector
<rgw_bucket_dir_entry
> *result
,
1022 map
<string
, bool> *common_prefixes
,
1032 rgw_obj_key end_marker
;
1035 RGWAccessListFilter
*filter
;
1037 bool allow_unordered
;
1042 list_versions(false),
1043 allow_unordered(false)
1047 explicit List(RGWRados::Bucket
*_target
) : target(_target
) {}
1049 int list_objects(const DoutPrefixProvider
*dpp
, int64_t max
,
1050 vector
<rgw_bucket_dir_entry
> *result
,
1051 map
<string
, bool> *common_prefixes
,
1054 if (params
.allow_unordered
) {
1055 return list_objects_unordered(dpp
, max
, result
, common_prefixes
,
1058 return list_objects_ordered(dpp
, max
, result
, common_prefixes
,
1062 rgw_obj_key
& get_next_marker() {
1068 int on_last_entry_in_listing(const DoutPrefixProvider
*dpp
,
1069 RGWBucketInfo
& bucket_info
,
1070 const std::string
& obj_prefix
,
1071 const std::string
& obj_delim
,
1072 std::function
<int(const rgw_bucket_dir_entry
&)> handler
);
1074 bool swift_versioning_enabled(rgw::sal::RGWBucket
* bucket
) const;
1076 int swift_versioning_copy(RGWObjectCtx
& obj_ctx
, /* in/out */
1077 const rgw_user
& user
, /* in */
1078 rgw::sal::RGWBucket
* bucket
, /* in */
1079 rgw::sal::RGWObject
* obj
, /* in */
1080 const DoutPrefixProvider
*dpp
, /* in/out */
1081 optional_yield y
); /* in */
1082 int swift_versioning_restore(RGWObjectCtx
& obj_ctx
, /* in/out */
1083 const rgw_user
& user
, /* in */
1084 rgw::sal::RGWBucket
* bucket
, /* in */
1085 rgw::sal::RGWObject
* obj
, /* in */
1086 bool& restored
, /* out */
1087 const DoutPrefixProvider
*dpp
); /* in/out */
1088 int copy_obj_to_remote_dest(const DoutPrefixProvider
*dpp
,
1089 RGWObjState
*astate
,
1090 map
<string
, bufferlist
>& src_attrs
,
1091 RGWRados::Object::Read
& read_op
,
1092 const rgw_user
& user_id
,
1093 rgw::sal::RGWObject
* dest_obj
,
1094 ceph::real_time
*mtime
);
1098 ATTRSMOD_REPLACE
= 1,
1102 int rewrite_obj(RGWBucketInfo
& dest_bucket_info
, rgw::sal::RGWObject
* obj
, const DoutPrefixProvider
*dpp
, optional_yield y
);
1104 int stat_remote_obj(const DoutPrefixProvider
*dpp
,
1105 RGWObjectCtx
& obj_ctx
,
1106 const rgw_user
& user_id
,
1108 const rgw_zone_id
& source_zone
,
1109 rgw::sal::RGWObject
* src_obj
,
1110 const RGWBucketInfo
*src_bucket_info
,
1111 real_time
*src_mtime
,
1113 const real_time
*mod_ptr
,
1114 const real_time
*unmod_ptr
,
1115 bool high_precision_time
,
1116 const char *if_match
,
1117 const char *if_nomatch
,
1118 map
<string
, bufferlist
> *pattrs
,
1119 map
<string
, string
> *pheaders
,
1124 int fetch_remote_obj(RGWObjectCtx
& obj_ctx
,
1125 const rgw_user
& user_id
,
1127 const rgw_zone_id
& source_zone
,
1128 rgw::sal::RGWObject
* dest_obj
,
1129 rgw::sal::RGWObject
* src_obj
,
1130 rgw::sal::RGWBucket
* dest_bucket
,
1131 rgw::sal::RGWBucket
* src_bucket
,
1132 std::optional
<rgw_placement_rule
> dest_placement
,
1133 ceph::real_time
*src_mtime
,
1134 ceph::real_time
*mtime
,
1135 const ceph::real_time
*mod_ptr
,
1136 const ceph::real_time
*unmod_ptr
,
1137 bool high_precision_time
,
1138 const char *if_match
,
1139 const char *if_nomatch
,
1142 rgw::sal::RGWAttrs
& attrs
,
1143 RGWObjCategory category
,
1144 std::optional
<uint64_t> olh_epoch
,
1145 ceph::real_time delete_at
,
1148 void (*progress_cb
)(off_t
, void *),
1149 void *progress_data
,
1150 const DoutPrefixProvider
*dpp
,
1151 RGWFetchObjFilter
*filter
,
1152 rgw_zone_set
*zones_trace
= nullptr,
1153 std::optional
<uint64_t>* bytes_transferred
= 0);
1156 * dest_obj: the object to copy into
1157 * src_obj: the object to copy from
1158 * attrs: usage depends on attrs_mod parameter
1159 * attrs_mod: the modification mode of the attrs, may have the following values:
1160 * ATTRSMOD_NONE - the attributes of the source object will be
1161 * copied without modifications, attrs parameter is ignored;
1162 * ATTRSMOD_REPLACE - new object will have the attributes provided by attrs
1163 * parameter, source object attributes are not copied;
1164 * ATTRSMOD_MERGE - any conflicting meta keys on the source object's attributes
1165 * are overwritten by values contained in attrs parameter.
1166 * Returns: 0 on success, -ERR# otherwise.
1168 int copy_obj(RGWObjectCtx
& obj_ctx
,
1169 const rgw_user
& user_id
,
1171 const rgw_zone_id
& source_zone
,
1172 rgw::sal::RGWObject
* dest_obj
,
1173 rgw::sal::RGWObject
* src_obj
,
1174 rgw::sal::RGWBucket
* dest_bucket
,
1175 rgw::sal::RGWBucket
* src_bucket
,
1176 const rgw_placement_rule
& dest_placement
,
1177 ceph::real_time
*src_mtime
,
1178 ceph::real_time
*mtime
,
1179 const ceph::real_time
*mod_ptr
,
1180 const ceph::real_time
*unmod_ptr
,
1181 bool high_precision_time
,
1182 const char *if_match
,
1183 const char *if_nomatch
,
1186 map
<std::string
, bufferlist
>& attrs
,
1187 RGWObjCategory category
,
1189 ceph::real_time delete_at
,
1193 void (*progress_cb
)(off_t
, void *),
1194 void *progress_data
,
1195 const DoutPrefixProvider
*dpp
,
1198 int copy_obj_data(RGWObjectCtx
& obj_ctx
,
1199 rgw::sal::RGWBucket
* bucket
,
1200 const rgw_placement_rule
& dest_placement
,
1201 RGWRados::Object::Read
& read_op
, off_t end
,
1202 rgw::sal::RGWObject
* dest_obj
,
1203 ceph::real_time
*mtime
,
1204 ceph::real_time set_mtime
,
1205 map
<string
, bufferlist
>& attrs
,
1207 ceph::real_time delete_at
,
1209 const DoutPrefixProvider
*dpp
,
1212 int transition_obj(RGWObjectCtx
& obj_ctx
,
1213 rgw::sal::RGWBucket
* bucket
,
1214 rgw::sal::RGWObject
& obj
,
1215 const rgw_placement_rule
& placement_rule
,
1216 const real_time
& mtime
,
1218 const DoutPrefixProvider
*dpp
,
1221 int check_bucket_empty(const DoutPrefixProvider
*dpp
, RGWBucketInfo
& bucket_info
, optional_yield y
);
1225 * bucket: the name of the bucket to delete
1226 * Returns 0 on success, -ERR# otherwise.
1228 int delete_bucket(RGWBucketInfo
& bucket_info
, RGWObjVersionTracker
& objv_tracker
, optional_yield y
, const DoutPrefixProvider
*dpp
, bool check_empty
= true);
1230 void wakeup_meta_sync_shards(set
<int>& shard_ids
);
1231 void wakeup_data_sync_shards(const rgw_zone_id
& source_zone
, map
<int, set
<string
> >& shard_ids
);
1233 RGWMetaSyncStatusManager
* get_meta_sync_manager();
1234 RGWDataSyncStatusManager
* get_data_sync_manager(const rgw_zone_id
& source_zone
);
1236 int set_bucket_owner(rgw_bucket
& bucket
, ACLOwner
& owner
, const DoutPrefixProvider
*dpp
);
1237 int set_buckets_enabled(std::vector
<rgw_bucket
>& buckets
, bool enabled
, const DoutPrefixProvider
*dpp
);
1238 int bucket_suspended(const DoutPrefixProvider
*dpp
, rgw_bucket
& bucket
, bool *suspended
);
1240 /** Delete an object.*/
1241 int delete_obj(const DoutPrefixProvider
*dpp
,
1242 RGWObjectCtx
& obj_ctx
,
1243 const RGWBucketInfo
& bucket_owner
,
1244 const rgw_obj
& src_obj
,
1245 int versioning_status
, // versioning flags in enum RGWBucketFlags
1246 uint16_t bilog_flags
= 0,
1247 const ceph::real_time
& expiration_time
= ceph::real_time(),
1248 rgw_zone_set
*zones_trace
= nullptr);
1250 int delete_raw_obj(const DoutPrefixProvider
*dpp
, const rgw_raw_obj
& obj
);
1252 /** Remove an object from the bucket index */
1253 int delete_obj_index(const rgw_obj
& obj
, ceph::real_time mtime
, const DoutPrefixProvider
*dpp
);
1256 * Set an attr on an object.
1257 * bucket: name of the bucket holding the object
1258 * obj: name of the object to set the attr on
1259 * name: the attr to set
1260 * bl: the contents of the attr
1261 * Returns: 0 on success, -ERR# otherwise.
1263 int set_attr(const DoutPrefixProvider
*dpp
, void *ctx
, const RGWBucketInfo
& bucket_info
, rgw_obj
& obj
, const char *name
, bufferlist
& bl
);
1265 int set_attrs(const DoutPrefixProvider
*dpp
, void *ctx
, const RGWBucketInfo
& bucket_info
, rgw_obj
& obj
,
1266 map
<string
, bufferlist
>& attrs
,
1267 map
<string
, bufferlist
>* rmattrs
,
1270 int get_obj_state(const DoutPrefixProvider
*dpp
, RGWObjectCtx
*rctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, RGWObjState
**state
,
1271 bool follow_olh
, optional_yield y
, bool assume_noent
= false);
1272 int get_obj_state(const DoutPrefixProvider
*dpp
, RGWObjectCtx
*rctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, RGWObjState
**state
, optional_yield y
) {
1273 return get_obj_state(dpp
, rctx
, bucket_info
, obj
, state
, true, y
);
1276 using iterate_obj_cb
= int (*)(const DoutPrefixProvider
*, const rgw_raw_obj
&, off_t
, off_t
,
1277 off_t
, bool, RGWObjState
*, void*);
1279 int iterate_obj(const DoutPrefixProvider
*dpp
, RGWObjectCtx
& ctx
, const RGWBucketInfo
& bucket_info
,
1280 const rgw_obj
& obj
, off_t ofs
, off_t end
,
1281 uint64_t max_chunk_size
, iterate_obj_cb cb
, void *arg
,
1284 int get_obj_iterate_cb(const DoutPrefixProvider
*dpp
,
1285 const rgw_raw_obj
& read_obj
, off_t obj_ofs
,
1286 off_t read_ofs
, off_t len
, bool is_head_obj
,
1287 RGWObjState
*astate
, void *arg
);
1289 void get_obj_aio_completion_cb(librados::completion_t cb
, void *arg
);
1292 * a simple object read without keeping state
1295 int raw_obj_stat(const DoutPrefixProvider
*dpp
,
1296 rgw_raw_obj
& obj
, uint64_t *psize
, ceph::real_time
*pmtime
, uint64_t *epoch
,
1297 map
<string
, bufferlist
> *attrs
, bufferlist
*first_chunk
,
1298 RGWObjVersionTracker
*objv_tracker
, optional_yield y
);
1300 int obj_operate(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, librados::ObjectWriteOperation
*op
);
1301 int obj_operate(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, librados::ObjectReadOperation
*op
);
1303 int guard_reshard(const DoutPrefixProvider
*dpp
,
1305 const rgw_obj
& obj_instance
,
1306 const RGWBucketInfo
& bucket_info
,
1307 std::function
<int(BucketShard
*)> call
);
1308 int block_while_resharding(RGWRados::BucketShard
*bs
,
1309 string
*new_bucket_id
,
1310 const RGWBucketInfo
& bucket_info
,
1312 const DoutPrefixProvider
*dpp
);
1314 void bucket_index_guard_olh_op(const DoutPrefixProvider
*dpp
, RGWObjState
& olh_state
, librados::ObjectOperation
& op
);
1315 int olh_init_modification(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& olh_obj
, string
*op_tag
);
1316 int olh_init_modification_impl(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& olh_obj
, string
*op_tag
);
1317 int bucket_index_link_olh(const DoutPrefixProvider
*dpp
,
1318 const RGWBucketInfo
& bucket_info
, RGWObjState
& olh_state
,
1319 const rgw_obj
& obj_instance
, bool delete_marker
,
1320 const string
& op_tag
, struct rgw_bucket_dir_entry_meta
*meta
,
1322 ceph::real_time unmod_since
, bool high_precision_time
,
1323 rgw_zone_set
*zones_trace
= nullptr,
1324 bool log_data_change
= false);
1325 int bucket_index_unlink_instance(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj_instance
, const string
& op_tag
, const string
& olh_tag
, uint64_t olh_epoch
, rgw_zone_set
*zones_trace
= nullptr);
1326 int bucket_index_read_olh_log(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& obj_instance
, uint64_t ver_marker
,
1327 map
<uint64_t, vector
<rgw_bucket_olh_log_entry
> > *log
, bool *is_truncated
);
1328 int bucket_index_trim_olh_log(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, RGWObjState
& obj_state
, const rgw_obj
& obj_instance
, uint64_t ver
);
1329 int bucket_index_clear_olh(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& obj_instance
);
1330 int apply_olh_log(const DoutPrefixProvider
*dpp
, RGWObjectCtx
& ctx
, RGWObjState
& obj_state
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
,
1331 bufferlist
& obj_tag
, map
<uint64_t, vector
<rgw_bucket_olh_log_entry
> >& log
,
1332 uint64_t *plast_ver
, rgw_zone_set
*zones_trace
= nullptr);
1333 int update_olh(const DoutPrefixProvider
*dpp
, RGWObjectCtx
& obj_ctx
, RGWObjState
*state
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, rgw_zone_set
*zones_trace
= nullptr);
1334 int set_olh(const DoutPrefixProvider
*dpp
, RGWObjectCtx
& obj_ctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& target_obj
, bool delete_marker
, rgw_bucket_dir_entry_meta
*meta
,
1335 uint64_t olh_epoch
, ceph::real_time unmod_since
, bool high_precision_time
,
1336 optional_yield y
, rgw_zone_set
*zones_trace
= nullptr, bool log_data_change
= false);
1337 int repair_olh(const DoutPrefixProvider
*dpp
, RGWObjState
* state
, const RGWBucketInfo
& bucket_info
,
1338 const rgw_obj
& obj
);
1339 int unlink_obj_instance(const DoutPrefixProvider
*dpp
, RGWObjectCtx
& obj_ctx
, RGWBucketInfo
& bucket_info
, const rgw_obj
& target_obj
,
1340 uint64_t olh_epoch
, optional_yield y
, rgw_zone_set
*zones_trace
= nullptr);
1342 void check_pending_olh_entries(map
<string
, bufferlist
>& pending_entries
, map
<string
, bufferlist
> *rm_pending_entries
);
1343 int remove_olh_pending_entries(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& olh_obj
, map
<string
, bufferlist
>& pending_attrs
);
1344 int follow_olh(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, RGWObjectCtx
& ctx
, RGWObjState
*state
, const rgw_obj
& olh_obj
, rgw_obj
*target
);
1345 int get_olh(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, RGWOLHInfo
*olh
);
1347 void gen_rand_obj_instance_name(rgw_obj_key
*target_key
);
1348 void gen_rand_obj_instance_name(rgw_obj
*target
);
1350 int update_containers_stats(map
<string
, RGWBucketEnt
>& m
, const DoutPrefixProvider
*dpp
);
1351 int append_async(const DoutPrefixProvider
*dpp
, rgw_raw_obj
& obj
, size_t size
, bufferlist
& bl
);
1354 void set_atomic(void *ctx
, rgw_obj
& obj
) {
1355 RGWObjectCtx
*rctx
= static_cast<RGWObjectCtx
*>(ctx
);
1356 rctx
->set_atomic(obj
);
1358 void set_prefetch_data(void *ctx
, const rgw_obj
& obj
) {
1359 RGWObjectCtx
*rctx
= static_cast<RGWObjectCtx
*>(ctx
);
1360 rctx
->set_prefetch_data(obj
);
1362 int decode_policy(bufferlist
& bl
, ACLOwner
*owner
);
1363 int get_bucket_stats(const DoutPrefixProvider
*dpp
, RGWBucketInfo
& bucket_info
, int shard_id
, string
*bucket_ver
, string
*master_ver
,
1364 map
<RGWObjCategory
, RGWStorageStats
>& stats
, string
*max_marker
, bool* syncstopped
= NULL
);
1365 int get_bucket_stats_async(const DoutPrefixProvider
*dpp
, RGWBucketInfo
& bucket_info
, int shard_id
, RGWGetBucketStats_CB
*cb
);
1367 int put_bucket_instance_info(RGWBucketInfo
& info
, bool exclusive
, ceph::real_time mtime
, map
<string
, bufferlist
> *pattrs
, const DoutPrefixProvider
*dpp
);
1368 /* xxx dang obj_ctx -> svc */
1369 int get_bucket_instance_info(RGWSysObjectCtx
& obj_ctx
, const string
& meta_key
, RGWBucketInfo
& info
, ceph::real_time
*pmtime
, map
<string
, bufferlist
> *pattrs
, optional_yield y
, const DoutPrefixProvider
*dpp
);
1370 int get_bucket_instance_info(RGWSysObjectCtx
& obj_ctx
, const rgw_bucket
& bucket
, RGWBucketInfo
& info
, ceph::real_time
*pmtime
, map
<string
, bufferlist
> *pattrs
, optional_yield y
, const DoutPrefixProvider
*dpp
);
1372 static void make_bucket_entry_name(const string
& tenant_name
, const string
& bucket_name
, string
& bucket_entry
);
1374 int get_bucket_info(RGWServices
*svc
,
1375 const string
& tenant_name
, const string
& bucket_name
,
1376 RGWBucketInfo
& info
,
1377 ceph::real_time
*pmtime
, optional_yield y
,
1378 const DoutPrefixProvider
*dpp
, map
<string
, bufferlist
> *pattrs
= NULL
);
1380 // Returns 0 on successful refresh. Returns error code if there was
1381 // an error or the version stored on the OSD is the same as that
1382 // presented in the BucketInfo structure.
1384 int try_refresh_bucket_info(RGWBucketInfo
& info
,
1385 ceph::real_time
*pmtime
,
1386 const DoutPrefixProvider
*dpp
,
1387 map
<string
, bufferlist
> *pattrs
= nullptr);
1389 int put_linked_bucket_info(RGWBucketInfo
& info
, bool exclusive
, ceph::real_time mtime
, obj_version
*pep_objv
,
1390 map
<string
, bufferlist
> *pattrs
, bool create_entry_point
,
1391 const DoutPrefixProvider
*dpp
);
1393 int cls_obj_prepare_op(const DoutPrefixProvider
*dpp
, BucketShard
& bs
, RGWModifyOp op
, string
& tag
, rgw_obj
& obj
, uint16_t bilog_flags
, optional_yield y
, rgw_zone_set
*zones_trace
= nullptr);
1394 int cls_obj_complete_op(BucketShard
& bs
, const rgw_obj
& obj
, RGWModifyOp op
, string
& tag
, int64_t pool
, uint64_t epoch
,
1395 rgw_bucket_dir_entry
& ent
, RGWObjCategory category
, list
<rgw_obj_index_key
> *remove_objs
, uint16_t bilog_flags
, rgw_zone_set
*zones_trace
= nullptr);
1396 int cls_obj_complete_add(BucketShard
& bs
, const rgw_obj
& obj
, string
& tag
, int64_t pool
, uint64_t epoch
, rgw_bucket_dir_entry
& ent
,
1397 RGWObjCategory category
, list
<rgw_obj_index_key
> *remove_objs
, uint16_t bilog_flags
, rgw_zone_set
*zones_trace
= nullptr);
1398 int cls_obj_complete_del(BucketShard
& bs
, string
& tag
, int64_t pool
, uint64_t epoch
, rgw_obj
& obj
,
1399 ceph::real_time
& removed_mtime
, list
<rgw_obj_index_key
> *remove_objs
, uint16_t bilog_flags
, rgw_zone_set
*zones_trace
= nullptr);
1400 int cls_obj_complete_cancel(BucketShard
& bs
, string
& tag
, rgw_obj
& obj
, uint16_t bilog_flags
, rgw_zone_set
*zones_trace
= nullptr);
1401 int cls_obj_set_bucket_tag_timeout(const DoutPrefixProvider
*dpp
, RGWBucketInfo
& bucket_info
, uint64_t timeout
);
1404 boost::container::flat_map
<std::string
, rgw_bucket_dir_entry
>;
1406 using check_filter_t
= bool (*)(const std::string
&);
1408 int cls_bucket_list_ordered(const DoutPrefixProvider
*dpp
,
1409 RGWBucketInfo
& bucket_info
,
1411 const rgw_obj_index_key
& start_after
,
1412 const string
& prefix
,
1413 const string
& delimiter
,
1414 const uint32_t num_entries
,
1415 const bool list_versions
,
1416 const uint16_t exp_factor
, // 0 means ignore
1420 rgw_obj_index_key
*last_entry
,
1422 check_filter_t force_check_filter
= nullptr);
1423 int cls_bucket_list_unordered(const DoutPrefixProvider
*dpp
,
1424 RGWBucketInfo
& bucket_info
,
1426 const rgw_obj_index_key
& start_after
,
1427 const string
& prefix
,
1428 uint32_t num_entries
,
1430 vector
<rgw_bucket_dir_entry
>& ent_list
,
1432 rgw_obj_index_key
*last_entry
,
1434 check_filter_t
= nullptr);
1435 int cls_bucket_head(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, int shard_id
, vector
<rgw_bucket_dir_header
>& headers
, map
<int, string
> *bucket_instance_ids
= NULL
);
1436 int cls_bucket_head_async(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, int shard_id
, RGWGetDirHeader_CB
*ctx
, int *num_aio
);
1438 int bi_get_instance(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, rgw_bucket_dir_entry
*dirent
);
1439 int bi_get_olh(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, rgw_bucket_olh_entry
*olh
);
1440 int bi_get(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, BIIndexType index_type
, rgw_cls_bi_entry
*entry
);
1441 void bi_put(librados::ObjectWriteOperation
& op
, BucketShard
& bs
, rgw_cls_bi_entry
& entry
);
1442 int bi_put(BucketShard
& bs
, rgw_cls_bi_entry
& entry
);
1443 int bi_put(const DoutPrefixProvider
*dpp
, rgw_bucket
& bucket
, rgw_obj
& obj
, rgw_cls_bi_entry
& entry
);
1444 int bi_list(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, int shard_id
, const string
& filter_obj
, const string
& marker
, uint32_t max
, list
<rgw_cls_bi_entry
> *entries
, bool *is_truncated
);
1445 int bi_list(BucketShard
& bs
, const string
& filter_obj
, const string
& marker
, uint32_t max
, list
<rgw_cls_bi_entry
> *entries
, bool *is_truncated
);
1446 int bi_list(const DoutPrefixProvider
*dpp
, rgw_bucket
& bucket
, const string
& obj_name
, const string
& marker
, uint32_t max
,
1447 list
<rgw_cls_bi_entry
> *entries
, bool *is_truncated
);
1448 int bi_remove(BucketShard
& bs
);
1450 int cls_obj_usage_log_add(const DoutPrefixProvider
*dpp
, const string
& oid
, rgw_usage_log_info
& info
);
1451 int cls_obj_usage_log_read(const DoutPrefixProvider
*dpp
, const string
& oid
, const string
& user
, const string
& bucket
, uint64_t start_epoch
,
1452 uint64_t end_epoch
, uint32_t max_entries
, string
& read_iter
, map
<rgw_user_bucket
,
1453 rgw_usage_log_entry
>& usage
, bool *is_truncated
);
1454 int cls_obj_usage_log_trim(const DoutPrefixProvider
*dpp
, const string
& oid
, const string
& user
, const string
& bucket
, uint64_t start_epoch
,
1455 uint64_t end_epoch
);
1456 int cls_obj_usage_log_clear(const DoutPrefixProvider
*dpp
, string
& oid
);
1458 int get_target_shard_id(const rgw::bucket_index_normal_layout
& layout
, const string
& obj_key
, int *shard_id
);
1460 int lock_exclusive(const rgw_pool
& pool
, const string
& oid
, ceph::timespan
& duration
, rgw_zone_id
& zone_id
, string
& owner_id
);
1461 int unlock(const rgw_pool
& pool
, const string
& oid
, rgw_zone_id
& zone_id
, string
& owner_id
);
1463 void update_gc_chain(const DoutPrefixProvider
*dpp
, rgw_obj
& head_obj
, RGWObjManifest
& manifest
, cls_rgw_obj_chain
*chain
);
1464 int send_chain_to_gc(cls_rgw_obj_chain
& chain
, const string
& tag
);
1465 void delete_objs_inline(const DoutPrefixProvider
*dpp
, cls_rgw_obj_chain
& chain
, const string
& tag
);
1466 int gc_operate(const DoutPrefixProvider
*dpp
, string
& oid
, librados::ObjectWriteOperation
*op
);
1467 int gc_aio_operate(const std::string
& oid
, librados::AioCompletion
*c
,
1468 librados::ObjectWriteOperation
*op
);
1469 int gc_operate(const DoutPrefixProvider
*dpp
, string
& oid
, librados::ObjectReadOperation
*op
, bufferlist
*pbl
);
1471 int list_gc_objs(int *index
, string
& marker
, uint32_t max
, bool expired_only
, std::list
<cls_rgw_gc_obj_info
>& result
, bool *truncated
, bool& processing_queue
);
1472 int process_gc(bool expired_only
);
1473 bool process_expire_objects(const DoutPrefixProvider
*dpp
);
1474 int defer_gc(const DoutPrefixProvider
*dpp
, void *ctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, optional_yield y
);
1477 int list_lc_progress(string
& marker
, uint32_t max_entries
,
1478 vector
<rgw::sal::Lifecycle::LCEntry
>& progress_map
, int& index
);
1480 int bucket_check_index(const DoutPrefixProvider
*dpp
, RGWBucketInfo
& bucket_info
,
1481 map
<RGWObjCategory
, RGWStorageStats
> *existing_stats
,
1482 map
<RGWObjCategory
, RGWStorageStats
> *calculated_stats
);
1483 int bucket_rebuild_index(const DoutPrefixProvider
*dpp
, RGWBucketInfo
& bucket_info
);
1484 int bucket_set_reshard(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, const cls_rgw_bucket_instance_entry
& entry
);
1485 int remove_objs_from_index(const DoutPrefixProvider
*dpp
, RGWBucketInfo
& bucket_info
, list
<rgw_obj_index_key
>& oid_list
);
1486 int move_rados_obj(const DoutPrefixProvider
*dpp
,
1487 librados::IoCtx
& src_ioctx
,
1488 const string
& src_oid
, const string
& src_locator
,
1489 librados::IoCtx
& dst_ioctx
,
1490 const string
& dst_oid
, const string
& dst_locator
);
1491 int fix_head_obj_locator(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, bool copy_obj
, bool remove_bad
, rgw_obj_key
& key
);
1492 int fix_tail_obj_locator(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, rgw_obj_key
& key
, bool fix
, bool *need_fix
, optional_yield y
);
1494 int check_quota(const rgw_user
& bucket_owner
, rgw_bucket
& bucket
,
1495 RGWQuotaInfo
& user_quota
, RGWQuotaInfo
& bucket_quota
, uint64_t obj_size
,
1496 optional_yield y
, bool check_size_only
= false);
1498 int check_bucket_shards(const RGWBucketInfo
& bucket_info
, const rgw_bucket
& bucket
,
1499 uint64_t num_objs
, const DoutPrefixProvider
*dpp
);
1501 int add_bucket_to_reshard(const DoutPrefixProvider
*dpp
, const RGWBucketInfo
& bucket_info
, uint32_t new_num_shards
);
1503 uint64_t instance_id();
1505 librados::Rados
* get_rados_handle();
1507 int delete_raw_obj_aio(const DoutPrefixProvider
*dpp
, const rgw_raw_obj
& obj
, list
<librados::AioCompletion
*>& handles
);
1508 int delete_obj_aio(const DoutPrefixProvider
*dpp
, const rgw_obj
& obj
, RGWBucketInfo
& info
, RGWObjState
*astate
,
1509 list
<librados::AioCompletion
*>& handles
, bool keep_index_consistent
,
1514 * Check the actual on-disk state of the object specified
1515 * by list_state, and fill in the time and size of object.
1516 * Then append any changes to suggested_updates for
1517 * the rgw class' dir_suggest_changes function.
1519 * Note that this can maul list_state; don't use it afterwards. Also
1520 * it expects object to already be filled in from list_state; it only
1521 * sets the size and mtime.
1523 * Returns 0 on success, -ENOENT if the object doesn't exist on disk,
1524 * and -errno on other failures. (-ENOENT is not a failure, and it
1525 * will encode that info as a suggested update.)
1527 int check_disk_state(const DoutPrefixProvider
*dpp
,
1528 librados::IoCtx io_ctx
,
1529 const RGWBucketInfo
& bucket_info
,
1530 rgw_bucket_dir_entry
& list_state
,
1531 rgw_bucket_dir_entry
& object
,
1532 bufferlist
& suggested_updates
,
1536 * Init pool iteration
1537 * pool: pool to use for the ctx initialization
1538 * ctx: context object to use for the iteration
1539 * Returns: 0 on success, -ERR# otherwise.
1541 int pool_iterate_begin(const DoutPrefixProvider
*dpp
, const rgw_pool
& pool
, RGWPoolIterCtx
& ctx
);
1544 * Init pool iteration
1546 * cursor: position to start iteration
1547 * ctx: context object to use for the iteration
1548 * Returns: 0 on success, -ERR# otherwise.
1550 int pool_iterate_begin(const DoutPrefixProvider
*dpp
, const rgw_pool
& pool
, const string
& cursor
, RGWPoolIterCtx
& ctx
);
1553 * Get pool iteration position
1554 * ctx: context object to use for the iteration
1555 * Returns: string representation of position
1557 string
pool_iterate_get_cursor(RGWPoolIterCtx
& ctx
);
1560 * Iterate over pool return object names, use optional filter
1561 * ctx: iteration context, initialized with pool_iterate_begin()
1562 * num: max number of objects to return
1563 * objs: a vector that the results will append into
1564 * is_truncated: if not NULL, will hold true iff iteration is complete
1565 * filter: if not NULL, will be used to filter returned objects
1566 * Returns: 0 on success, -ERR# otherwise.
1568 int pool_iterate(RGWPoolIterCtx
& ctx
, uint32_t num
, vector
<rgw_bucket_dir_entry
>& objs
,
1569 bool *is_truncated
, RGWAccessListFilter
*filter
);
1571 uint64_t next_bucket_id();
1574 * This is broken out to facilitate unit testing.
1576 static uint32_t calc_ordered_bucket_list_per_shard(uint32_t num_entries
,
1577 uint32_t num_shards
);