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(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();
416 int open_gc_pool_ctx();
417 int open_lc_pool_ctx();
418 int open_objexp_pool_ctx();
419 int open_reshard_pool_ctx();
420 int open_notif_pool_ctx();
422 int open_pool_ctx(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 RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, rgw_rados_ref
*ref
);
464 int get_system_obj_ref(const rgw_raw_obj
& obj
, rgw_rados_ref
*ref
);
465 uint64_t max_bucket_id
;
467 int get_olh_target_state(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(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(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 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};
510 int get_obj_head_ioctx(const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, librados::IoCtx
*ioctx
);
512 RGWRados(): timer(NULL
),
513 gc(NULL
), lc(NULL
), obj_expirer(NULL
), use_gc_thread(false), use_lc_thread(false), quota_threads(false),
514 run_sync_thread(false), run_reshard_thread(false), meta_notifier(NULL
),
515 data_notifier(NULL
), meta_sync_processor_thread(NULL
),
516 bucket_index_max_shards(0),
517 max_bucket_id(0), cct(NULL
),
518 binfo_cache(NULL
), obj_tombstone_cache(nullptr),
519 pools_initialized(false),
525 RGWRados
& set_use_cache(bool status
) {
534 RGWRados
& set_run_gc_thread(bool _use_gc_thread
) {
535 use_gc_thread
= _use_gc_thread
;
539 RGWRados
& set_run_lc_thread(bool _use_lc_thread
) {
540 use_lc_thread
= _use_lc_thread
;
544 RGWRados
& set_run_quota_threads(bool _run_quota_threads
) {
545 quota_threads
= _run_quota_threads
;
549 RGWRados
& set_run_sync_thread(bool _run_sync_thread
) {
550 run_sync_thread
= _run_sync_thread
;
554 RGWRados
& set_run_reshard_thread(bool _run_reshard_thread
) {
555 run_reshard_thread
= _run_reshard_thread
;
559 uint64_t get_new_req_id() {
563 librados::IoCtx
* get_lc_pool_ctx() {
567 librados::IoCtx
& get_notif_pool_ctx() {
568 return notif_pool_ctx
;
571 void set_context(CephContext
*_cct
) {
574 void set_store(rgw::sal::RGWRadosStore
*_store
) {
581 RGWCtl
*pctl
{nullptr};
584 * AmazonS3 errors contain a HostId string, but is an opaque base64 blob; we
585 * try to be more transparent. This has a wrapper so we can update it when zonegroup/zone are changed.
590 std::shared_ptr
<RGWReshardWait
> reshard_wait
;
592 virtual ~RGWRados() = default;
594 tombstone_cache_t
*get_tombstone_cache() {
595 return obj_tombstone_cache
;
597 const RGWSyncModuleInstanceRef
& get_sync_module() {
600 RGWSyncTraceManager
*get_sync_tracer() {
604 int get_required_alignment(const rgw_pool
& pool
, uint64_t *alignment
);
605 void get_max_aligned_size(uint64_t size
, uint64_t alignment
, uint64_t *max_size
);
606 int get_max_chunk_size(const rgw_pool
& pool
, uint64_t *max_chunk_size
, uint64_t *palignment
= nullptr);
607 int get_max_chunk_size(const rgw_placement_rule
& placement_rule
, const rgw_obj
& obj
, uint64_t *max_chunk_size
, uint64_t *palignment
= nullptr);
609 uint32_t get_max_bucket_shards() {
610 return RGWSI_BucketIndex_RADOS::shards_max();
614 int get_raw_obj_ref(const rgw_raw_obj
& obj
, rgw_rados_ref
*ref
);
616 int list_raw_objects_init(const rgw_pool
& pool
, const string
& marker
, RGWListRawObjsCtx
*ctx
);
617 int list_raw_objects_next(const string
& prefix_filter
, int max
,
618 RGWListRawObjsCtx
& ctx
, list
<string
>& oids
,
620 int list_raw_objects(const rgw_pool
& pool
, const string
& prefix_filter
, int max
,
621 RGWListRawObjsCtx
& ctx
, list
<string
>& oids
,
623 string
list_raw_objs_get_cursor(RGWListRawObjsCtx
& ctx
);
625 CephContext
*ctx() { return cct
; }
626 /** do all necessary setup of the storage device */
627 int initialize(CephContext
*_cct
) {
631 /** Initialize the RADOS instance and prepare to do other ops */
632 int init_svc(bool raw
);
639 int register_to_service_map(const string
& daemon_type
, const map
<string
, string
>& meta
);
640 int update_service_map(std::map
<std::string
, std::string
>&& status
);
643 int log_list_init(const string
& prefix
, RGWAccessHandle
*handle
);
644 int log_list_next(RGWAccessHandle handle
, string
*name
);
647 int log_remove(const string
& name
);
650 int log_show_init(const string
& name
, RGWAccessHandle
*handle
);
651 int log_show_next(RGWAccessHandle handle
, rgw_log_entry
*entry
);
653 // log bandwidth info
654 int log_usage(map
<rgw_user_bucket
, RGWUsageBatch
>& usage_info
);
655 int read_usage(const rgw_user
& user
, const string
& bucket_name
, uint64_t start_epoch
, uint64_t end_epoch
,
656 uint32_t max_entries
, bool *is_truncated
, RGWUsageIter
& read_iter
, map
<rgw_user_bucket
,
657 rgw_usage_log_entry
>& usage
);
658 int trim_usage(const rgw_user
& user
, const string
& bucket_name
, uint64_t start_epoch
, uint64_t end_epoch
);
661 int create_pool(const rgw_pool
& pool
);
663 void create_bucket_id(string
*bucket_id
);
665 bool get_obj_data_pool(const rgw_placement_rule
& placement_rule
, const rgw_obj
& obj
, rgw_pool
*pool
);
666 bool obj_to_raw(const rgw_placement_rule
& placement_rule
, const rgw_obj
& obj
, rgw_raw_obj
*raw_obj
);
668 int create_bucket(const RGWUserInfo
& owner
, rgw_bucket
& bucket
,
669 const string
& zonegroup_id
,
670 const rgw_placement_rule
& placement_rule
,
671 const string
& swift_ver_location
,
672 const RGWQuotaInfo
* pquota_info
,
673 map
<std::string
,bufferlist
>& attrs
,
674 RGWBucketInfo
& bucket_info
,
676 obj_version
*pep_objv
,
677 ceph::real_time creation_time
,
678 rgw_bucket
*master_bucket
,
679 uint32_t *master_num_shards
,
681 bool exclusive
= true);
683 RGWCoroutinesManagerRegistry
*get_cr_registry() { return cr_registry
; }
689 RGWSI_RADOS::Obj bucket_obj
;
691 explicit BucketShard(RGWRados
*_store
) : store(_store
), shard_id(-1) {}
692 int init(const rgw_bucket
& _bucket
, const rgw_obj
& obj
, RGWBucketInfo
* out
);
693 int init(const rgw_bucket
& _bucket
, int sid
, const rgw::bucket_index_layout_generation
& idx_layout
, RGWBucketInfo
* out
);
694 int init(const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
);
695 int init(const RGWBucketInfo
& bucket_info
, const rgw::bucket_index_layout_generation
& idx_layout
, int sid
);
700 RGWBucketInfo bucket_info
;
708 bool versioning_disabled
;
713 int get_state(RGWObjState
**pstate
, bool follow_olh
, optional_yield y
, bool assume_noent
= false);
714 void invalidate_state();
716 int prepare_atomic_modification(librados::ObjectWriteOperation
& op
, bool reset_obj
, const string
*ptag
,
717 const char *ifmatch
, const char *ifnomatch
, bool removal_op
, bool modify_tail
, optional_yield y
);
718 int complete_atomic_modification();
721 Object(RGWRados
*_store
, const RGWBucketInfo
& _bucket_info
, RGWObjectCtx
& _ctx
, const rgw_obj
& _obj
) : store(_store
), bucket_info(_bucket_info
),
722 ctx(_ctx
), obj(_obj
), bs(store
),
723 state(NULL
), versioning_disabled(false),
724 bs_initialized(false) {}
726 RGWRados
*get_store() { return store
; }
727 rgw_obj
& get_obj() { return obj
; }
728 RGWObjectCtx
& get_ctx() { return ctx
; }
729 RGWBucketInfo
& get_bucket_info() { return bucket_info
; }
730 int get_manifest(RGWObjManifest
**pmanifest
, optional_yield y
);
732 int get_bucket_shard(BucketShard
**pbs
) {
733 if (!bs_initialized
) {
735 bs
.init(bucket_info
.bucket
, obj
, nullptr /* no RGWBucketInfo */);
739 bs_initialized
= true;
745 void set_versioning_disabled(bool status
) {
746 versioning_disabled
= status
;
749 bool versioning_enabled() {
750 return (!versioning_disabled
&& bucket_info
.versioning_enabled());
754 RGWRados::Object
*source
;
757 map
<rgw_pool
, librados::IoCtx
> io_ctxs
;
759 librados::IoCtx
*cur_ioctx
{nullptr};
761 rgw_raw_obj head_obj
;
764 struct ConditionParams
{
765 const ceph::real_time
*mod_ptr
;
766 const ceph::real_time
*unmod_ptr
;
767 bool high_precision_time
;
768 uint32_t mod_zone_id
;
770 const char *if_match
;
771 const char *if_nomatch
;
774 mod_ptr(NULL
), unmod_ptr(NULL
), high_precision_time(false), mod_zone_id(0), mod_pg_ver(0),
775 if_match(NULL
), if_nomatch(NULL
) {}
779 ceph::real_time
*lastmod
;
781 map
<string
, bufferlist
> *attrs
;
784 Params() : lastmod(nullptr), obj_size(nullptr), attrs(nullptr),
785 target_obj(nullptr) {}
788 explicit Read(RGWRados::Object
*_source
) : source(_source
) {}
790 int prepare(optional_yield y
);
791 static int range_to_ofs(uint64_t obj_size
, int64_t &ofs
, int64_t &end
);
792 int read(int64_t ofs
, int64_t end
, bufferlist
& bl
, optional_yield y
);
793 int iterate(int64_t ofs
, int64_t end
, RGWGetDataCB
*cb
, optional_yield y
);
794 int get_attr(const char *name
, bufferlist
& dest
, optional_yield y
);
798 RGWRados::Object
*target
;
801 ceph::real_time
*mtime
;
802 map
<std::string
, bufferlist
>* rmattrs
;
803 const bufferlist
*data
;
804 RGWObjManifest
*manifest
;
806 list
<rgw_obj_index_key
> *remove_objs
;
807 ceph::real_time set_mtime
;
809 RGWObjCategory category
;
811 const char *if_match
;
812 const char *if_nomatch
;
813 std::optional
<uint64_t> olh_epoch
;
814 ceph::real_time delete_at
;
816 const string
*user_data
;
817 rgw_zone_set
*zones_trace
;
819 bool completeMultipart
;
822 MetaParams() : mtime(NULL
), rmattrs(NULL
), data(NULL
), manifest(NULL
), ptag(NULL
),
823 remove_objs(NULL
), category(RGWObjCategory::Main
), flags(0),
824 if_match(NULL
), if_nomatch(NULL
), canceled(false), user_data(nullptr), zones_trace(nullptr),
825 modify_tail(false), completeMultipart(false), appendable(false) {}
828 explicit Write(RGWRados::Object
*_target
) : target(_target
) {}
830 int _do_write_meta(uint64_t size
, uint64_t accounted_size
,
831 map
<std::string
, bufferlist
>& attrs
,
832 bool modify_tail
, bool assume_noent
,
833 void *index_op
, optional_yield y
);
834 int write_meta(uint64_t size
, uint64_t accounted_size
,
835 map
<std::string
, bufferlist
>& attrs
, optional_yield y
);
836 int write_data(const char *data
, uint64_t ofs
, uint64_t len
, bool exclusive
);
837 const req_state
* get_req_state() {
838 return (req_state
*)target
->get_ctx().get_private();
843 RGWRados::Object
*target
;
845 struct DeleteParams
{
846 rgw_user bucket_owner
;
847 int versioning_status
;
848 ACLOwner obj_owner
; /* needed for creation of deletion marker */
850 string marker_version_id
;
851 uint32_t bilog_flags
;
852 list
<rgw_obj_index_key
> *remove_objs
;
853 ceph::real_time expiration_time
;
854 ceph::real_time unmod_since
;
855 ceph::real_time mtime
; /* for setting delete marker mtime */
856 bool high_precision_time
;
857 rgw_zone_set
*zones_trace
;
859 uint64_t parts_accounted_size
;
861 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) {}
864 struct DeleteResult
{
868 DeleteResult() : delete_marker(false) {}
871 explicit Delete(RGWRados::Object
*_target
) : target(_target
) {}
873 int delete_obj(optional_yield y
);
877 RGWRados::Object
*source
;
881 std::optional
<RGWObjManifest
> manifest
;
883 struct timespec mtime
{};
884 map
<string
, bufferlist
> attrs
;
888 librados::IoCtx io_ctx
;
889 librados::AioCompletion
*completion
;
892 State() : completion(NULL
), ret(0) {}
896 explicit Stat(RGWRados::Object
*_source
) : source(_source
) {}
908 RGWBucketInfo bucket_info
;
913 Bucket(RGWRados
*_store
, const RGWBucketInfo
& _bucket_info
) : store(_store
), bucket_info(_bucket_info
), bucket(bucket_info
.bucket
),
914 shard_id(RGW_NO_SHARD
) {}
915 RGWRados
*get_store() { return store
; }
916 rgw_bucket
& get_bucket() { return bucket
; }
917 RGWBucketInfo
& get_bucket_info() { return bucket_info
; }
919 int update_bucket_id(const string
& new_bucket_id
);
921 int get_shard_id() { return shard_id
; }
922 void set_shard_id(int id
) {
927 RGWRados::Bucket
*target
;
930 uint16_t bilog_flags
{0};
932 bool bs_initialized
{false};
934 bool prepared
{false};
935 rgw_zone_set
*zones_trace
{nullptr};
939 bs
.init(target
->get_bucket(), obj
, nullptr /* no RGWBucketInfo */);
943 bs_initialized
= true;
947 void invalidate_bs() {
948 bs_initialized
= false;
951 int guard_reshard(BucketShard
**pbs
, std::function
<int(BucketShard
*)> call
);
954 UpdateIndex(RGWRados::Bucket
*_target
, const rgw_obj
& _obj
) : target(_target
), obj(_obj
),
955 bs(target
->get_store()) {
956 blind
= (target
->get_bucket_info().layout
.current_index
.layout
.type
== rgw::BucketIndexType::Indexless
);
959 int get_bucket_shard(BucketShard
**pbs
) {
960 if (!bs_initialized
) {
970 void set_bilog_flags(uint16_t flags
) {
974 void set_zones_trace(rgw_zone_set
*_zones_trace
) {
975 zones_trace
= _zones_trace
;
978 int prepare(RGWModifyOp
, const string
*write_tag
, optional_yield y
);
979 int complete(int64_t poolid
, uint64_t epoch
, uint64_t size
,
980 uint64_t accounted_size
, ceph::real_time
& ut
,
981 const string
& etag
, const string
& content_type
,
982 const string
& storage_class
,
983 bufferlist
*acl_bl
, RGWObjCategory category
,
984 list
<rgw_obj_index_key
> *remove_objs
, const string
*user_data
= nullptr, bool appendable
= false);
985 int complete_del(int64_t poolid
, uint64_t epoch
,
986 ceph::real_time
& removed_mtime
, /* mtime of removed object */
987 list
<rgw_obj_index_key
> *remove_objs
);
990 const string
*get_optag() { return &optag
; }
992 bool is_prepared() { return prepared
; }
993 }; // class UpdateIndex
997 // absolute maximum number of objects that
998 // list_objects_(un)ordered can return
999 static constexpr int64_t bucket_list_objects_absolute_max
= 25000;
1001 RGWRados::Bucket
*target
;
1002 rgw_obj_key next_marker
;
1004 int list_objects_ordered(int64_t max
,
1005 vector
<rgw_bucket_dir_entry
> *result
,
1006 map
<string
, bool> *common_prefixes
,
1009 int list_objects_unordered(int64_t max
,
1010 vector
<rgw_bucket_dir_entry
> *result
,
1011 map
<string
, bool> *common_prefixes
,
1021 rgw_obj_key end_marker
;
1024 RGWAccessListFilter
*filter
;
1026 bool allow_unordered
;
1031 list_versions(false),
1032 allow_unordered(false)
1036 explicit List(RGWRados::Bucket
*_target
) : target(_target
) {}
1038 int list_objects(int64_t max
,
1039 vector
<rgw_bucket_dir_entry
> *result
,
1040 map
<string
, bool> *common_prefixes
,
1043 if (params
.allow_unordered
) {
1044 return list_objects_unordered(max
, result
, common_prefixes
,
1047 return list_objects_ordered(max
, result
, common_prefixes
,
1051 rgw_obj_key
& get_next_marker() {
1057 int on_last_entry_in_listing(RGWBucketInfo
& bucket_info
,
1058 const std::string
& obj_prefix
,
1059 const std::string
& obj_delim
,
1060 std::function
<int(const rgw_bucket_dir_entry
&)> handler
);
1062 bool swift_versioning_enabled(rgw::sal::RGWBucket
* bucket
) const;
1064 int swift_versioning_copy(RGWObjectCtx
& obj_ctx
, /* in/out */
1065 const rgw_user
& user
, /* in */
1066 rgw::sal::RGWBucket
* bucket
, /* in */
1067 rgw::sal::RGWObject
* obj
, /* in */
1068 const DoutPrefixProvider
*dpp
, /* in/out */
1069 optional_yield y
); /* in */
1070 int swift_versioning_restore(RGWObjectCtx
& obj_ctx
, /* in/out */
1071 const rgw_user
& user
, /* in */
1072 rgw::sal::RGWBucket
* bucket
, /* in */
1073 rgw::sal::RGWObject
* obj
, /* in */
1074 bool& restored
, /* out */
1075 const DoutPrefixProvider
*dpp
); /* in/out */
1076 int copy_obj_to_remote_dest(RGWObjState
*astate
,
1077 map
<string
, bufferlist
>& src_attrs
,
1078 RGWRados::Object::Read
& read_op
,
1079 const rgw_user
& user_id
,
1080 rgw::sal::RGWObject
* dest_obj
,
1081 ceph::real_time
*mtime
);
1085 ATTRSMOD_REPLACE
= 1,
1089 int rewrite_obj(RGWBucketInfo
& dest_bucket_info
, rgw::sal::RGWObject
* obj
, const DoutPrefixProvider
*dpp
, optional_yield y
);
1091 int stat_remote_obj(RGWObjectCtx
& obj_ctx
,
1092 const rgw_user
& user_id
,
1094 const rgw_zone_id
& source_zone
,
1095 rgw::sal::RGWObject
* src_obj
,
1096 const RGWBucketInfo
*src_bucket_info
,
1097 real_time
*src_mtime
,
1099 const real_time
*mod_ptr
,
1100 const real_time
*unmod_ptr
,
1101 bool high_precision_time
,
1102 const char *if_match
,
1103 const char *if_nomatch
,
1104 map
<string
, bufferlist
> *pattrs
,
1105 map
<string
, string
> *pheaders
,
1110 int fetch_remote_obj(RGWObjectCtx
& obj_ctx
,
1111 const rgw_user
& user_id
,
1113 const rgw_zone_id
& source_zone
,
1114 rgw::sal::RGWObject
* dest_obj
,
1115 rgw::sal::RGWObject
* src_obj
,
1116 rgw::sal::RGWBucket
* dest_bucket
,
1117 rgw::sal::RGWBucket
* src_bucket
,
1118 std::optional
<rgw_placement_rule
> dest_placement
,
1119 ceph::real_time
*src_mtime
,
1120 ceph::real_time
*mtime
,
1121 const ceph::real_time
*mod_ptr
,
1122 const ceph::real_time
*unmod_ptr
,
1123 bool high_precision_time
,
1124 const char *if_match
,
1125 const char *if_nomatch
,
1128 rgw::sal::RGWAttrs
& attrs
,
1129 RGWObjCategory category
,
1130 std::optional
<uint64_t> olh_epoch
,
1131 ceph::real_time delete_at
,
1134 void (*progress_cb
)(off_t
, void *),
1135 void *progress_data
,
1136 const DoutPrefixProvider
*dpp
,
1137 RGWFetchObjFilter
*filter
,
1138 rgw_zone_set
*zones_trace
= nullptr,
1139 std::optional
<uint64_t>* bytes_transferred
= 0);
1142 * dest_obj: the object to copy into
1143 * src_obj: the object to copy from
1144 * attrs: usage depends on attrs_mod parameter
1145 * attrs_mod: the modification mode of the attrs, may have the following values:
1146 * ATTRSMOD_NONE - the attributes of the source object will be
1147 * copied without modifications, attrs parameter is ignored;
1148 * ATTRSMOD_REPLACE - new object will have the attributes provided by attrs
1149 * parameter, source object attributes are not copied;
1150 * ATTRSMOD_MERGE - any conflicting meta keys on the source object's attributes
1151 * are overwritten by values contained in attrs parameter.
1152 * Returns: 0 on success, -ERR# otherwise.
1154 int copy_obj(RGWObjectCtx
& obj_ctx
,
1155 const rgw_user
& user_id
,
1157 const rgw_zone_id
& source_zone
,
1158 rgw::sal::RGWObject
* dest_obj
,
1159 rgw::sal::RGWObject
* src_obj
,
1160 rgw::sal::RGWBucket
* dest_bucket
,
1161 rgw::sal::RGWBucket
* src_bucket
,
1162 const rgw_placement_rule
& dest_placement
,
1163 ceph::real_time
*src_mtime
,
1164 ceph::real_time
*mtime
,
1165 const ceph::real_time
*mod_ptr
,
1166 const ceph::real_time
*unmod_ptr
,
1167 bool high_precision_time
,
1168 const char *if_match
,
1169 const char *if_nomatch
,
1172 map
<std::string
, bufferlist
>& attrs
,
1173 RGWObjCategory category
,
1175 ceph::real_time delete_at
,
1179 void (*progress_cb
)(off_t
, void *),
1180 void *progress_data
,
1181 const DoutPrefixProvider
*dpp
,
1184 int copy_obj_data(RGWObjectCtx
& obj_ctx
,
1185 rgw::sal::RGWBucket
* bucket
,
1186 const rgw_placement_rule
& dest_placement
,
1187 RGWRados::Object::Read
& read_op
, off_t end
,
1188 rgw::sal::RGWObject
* dest_obj
,
1189 ceph::real_time
*mtime
,
1190 ceph::real_time set_mtime
,
1191 map
<string
, bufferlist
>& attrs
,
1193 ceph::real_time delete_at
,
1195 const DoutPrefixProvider
*dpp
,
1198 int transition_obj(RGWObjectCtx
& obj_ctx
,
1199 rgw::sal::RGWBucket
* bucket
,
1200 rgw::sal::RGWObject
& obj
,
1201 const rgw_placement_rule
& placement_rule
,
1202 const real_time
& mtime
,
1204 const DoutPrefixProvider
*dpp
,
1207 int check_bucket_empty(RGWBucketInfo
& bucket_info
, optional_yield y
);
1211 * bucket: the name of the bucket to delete
1212 * Returns 0 on success, -ERR# otherwise.
1214 int delete_bucket(RGWBucketInfo
& bucket_info
, RGWObjVersionTracker
& objv_tracker
, optional_yield y
, bool check_empty
= true);
1216 void wakeup_meta_sync_shards(set
<int>& shard_ids
);
1217 void wakeup_data_sync_shards(const rgw_zone_id
& source_zone
, map
<int, set
<string
> >& shard_ids
);
1219 RGWMetaSyncStatusManager
* get_meta_sync_manager();
1220 RGWDataSyncStatusManager
* get_data_sync_manager(const rgw_zone_id
& source_zone
);
1222 int set_bucket_owner(rgw_bucket
& bucket
, ACLOwner
& owner
);
1223 int set_buckets_enabled(std::vector
<rgw_bucket
>& buckets
, bool enabled
);
1224 int bucket_suspended(rgw_bucket
& bucket
, bool *suspended
);
1226 /** Delete an object.*/
1227 int delete_obj(RGWObjectCtx
& obj_ctx
,
1228 const RGWBucketInfo
& bucket_owner
,
1229 const rgw_obj
& src_obj
,
1230 int versioning_status
,
1231 uint16_t bilog_flags
= 0,
1232 const ceph::real_time
& expiration_time
= ceph::real_time(),
1233 rgw_zone_set
*zones_trace
= nullptr);
1235 int delete_raw_obj(const rgw_raw_obj
& obj
);
1237 /** Remove an object from the bucket index */
1238 int delete_obj_index(const rgw_obj
& obj
, ceph::real_time mtime
);
1241 * Set an attr on an object.
1242 * bucket: name of the bucket holding the object
1243 * obj: name of the object to set the attr on
1244 * name: the attr to set
1245 * bl: the contents of the attr
1246 * Returns: 0 on success, -ERR# otherwise.
1248 int set_attr(void *ctx
, const RGWBucketInfo
& bucket_info
, rgw_obj
& obj
, const char *name
, bufferlist
& bl
);
1250 int set_attrs(void *ctx
, const RGWBucketInfo
& bucket_info
, rgw_obj
& obj
,
1251 map
<string
, bufferlist
>& attrs
,
1252 map
<string
, bufferlist
>* rmattrs
,
1255 int get_obj_state(RGWObjectCtx
*rctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, RGWObjState
**state
,
1256 bool follow_olh
, optional_yield y
, bool assume_noent
= false);
1257 int get_obj_state(RGWObjectCtx
*rctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, RGWObjState
**state
, optional_yield y
) {
1258 return get_obj_state(rctx
, bucket_info
, obj
, state
, true, y
);
1261 using iterate_obj_cb
= int (*)(const rgw_raw_obj
&, off_t
, off_t
,
1262 off_t
, bool, RGWObjState
*, void*);
1264 int iterate_obj(RGWObjectCtx
& ctx
, const RGWBucketInfo
& bucket_info
,
1265 const rgw_obj
& obj
, off_t ofs
, off_t end
,
1266 uint64_t max_chunk_size
, iterate_obj_cb cb
, void *arg
,
1269 int get_obj_iterate_cb(const rgw_raw_obj
& read_obj
, off_t obj_ofs
,
1270 off_t read_ofs
, off_t len
, bool is_head_obj
,
1271 RGWObjState
*astate
, void *arg
);
1273 void get_obj_aio_completion_cb(librados::completion_t cb
, void *arg
);
1276 * a simple object read without keeping state
1279 int raw_obj_stat(rgw_raw_obj
& obj
, uint64_t *psize
, ceph::real_time
*pmtime
, uint64_t *epoch
,
1280 map
<string
, bufferlist
> *attrs
, bufferlist
*first_chunk
,
1281 RGWObjVersionTracker
*objv_tracker
, optional_yield y
);
1283 int obj_operate(const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, librados::ObjectWriteOperation
*op
);
1284 int obj_operate(const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, librados::ObjectReadOperation
*op
);
1286 int guard_reshard(BucketShard
*bs
,
1287 const rgw_obj
& obj_instance
,
1288 const RGWBucketInfo
& bucket_info
,
1289 std::function
<int(BucketShard
*)> call
);
1290 int block_while_resharding(RGWRados::BucketShard
*bs
,
1291 string
*new_bucket_id
,
1292 const RGWBucketInfo
& bucket_info
,
1295 void bucket_index_guard_olh_op(RGWObjState
& olh_state
, librados::ObjectOperation
& op
);
1296 int olh_init_modification(const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& olh_obj
, string
*op_tag
);
1297 int olh_init_modification_impl(const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& olh_obj
, string
*op_tag
);
1298 int bucket_index_link_olh(const RGWBucketInfo
& bucket_info
, RGWObjState
& olh_state
,
1299 const rgw_obj
& obj_instance
, bool delete_marker
,
1300 const string
& op_tag
, struct rgw_bucket_dir_entry_meta
*meta
,
1302 ceph::real_time unmod_since
, bool high_precision_time
,
1303 rgw_zone_set
*zones_trace
= nullptr,
1304 bool log_data_change
= false);
1305 int bucket_index_unlink_instance(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);
1306 int bucket_index_read_olh_log(const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& obj_instance
, uint64_t ver_marker
,
1307 map
<uint64_t, vector
<rgw_bucket_olh_log_entry
> > *log
, bool *is_truncated
);
1308 int bucket_index_trim_olh_log(const RGWBucketInfo
& bucket_info
, RGWObjState
& obj_state
, const rgw_obj
& obj_instance
, uint64_t ver
);
1309 int bucket_index_clear_olh(const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& obj_instance
);
1310 int apply_olh_log(RGWObjectCtx
& ctx
, RGWObjState
& obj_state
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
,
1311 bufferlist
& obj_tag
, map
<uint64_t, vector
<rgw_bucket_olh_log_entry
> >& log
,
1312 uint64_t *plast_ver
, rgw_zone_set
*zones_trace
= nullptr);
1313 int update_olh(RGWObjectCtx
& obj_ctx
, RGWObjState
*state
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, rgw_zone_set
*zones_trace
= nullptr);
1314 int set_olh(RGWObjectCtx
& obj_ctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& target_obj
, bool delete_marker
, rgw_bucket_dir_entry_meta
*meta
,
1315 uint64_t olh_epoch
, ceph::real_time unmod_since
, bool high_precision_time
,
1316 optional_yield y
, rgw_zone_set
*zones_trace
= nullptr, bool log_data_change
= false);
1317 int repair_olh(RGWObjState
* state
, const RGWBucketInfo
& bucket_info
,
1318 const rgw_obj
& obj
);
1319 int unlink_obj_instance(RGWObjectCtx
& obj_ctx
, RGWBucketInfo
& bucket_info
, const rgw_obj
& target_obj
,
1320 uint64_t olh_epoch
, optional_yield y
, rgw_zone_set
*zones_trace
= nullptr);
1322 void check_pending_olh_entries(map
<string
, bufferlist
>& pending_entries
, map
<string
, bufferlist
> *rm_pending_entries
);
1323 int remove_olh_pending_entries(const RGWBucketInfo
& bucket_info
, RGWObjState
& state
, const rgw_obj
& olh_obj
, map
<string
, bufferlist
>& pending_attrs
);
1324 int follow_olh(const RGWBucketInfo
& bucket_info
, RGWObjectCtx
& ctx
, RGWObjState
*state
, const rgw_obj
& olh_obj
, rgw_obj
*target
);
1325 int get_olh(const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, RGWOLHInfo
*olh
);
1327 void gen_rand_obj_instance_name(rgw_obj_key
*target_key
);
1328 void gen_rand_obj_instance_name(rgw_obj
*target
);
1330 int update_containers_stats(map
<string
, RGWBucketEnt
>& m
);
1331 int append_async(rgw_raw_obj
& obj
, size_t size
, bufferlist
& bl
);
1334 void set_atomic(void *ctx
, rgw_obj
& obj
) {
1335 RGWObjectCtx
*rctx
= static_cast<RGWObjectCtx
*>(ctx
);
1336 rctx
->set_atomic(obj
);
1338 void set_prefetch_data(void *ctx
, const rgw_obj
& obj
) {
1339 RGWObjectCtx
*rctx
= static_cast<RGWObjectCtx
*>(ctx
);
1340 rctx
->set_prefetch_data(obj
);
1342 int decode_policy(bufferlist
& bl
, ACLOwner
*owner
);
1343 int get_bucket_stats(RGWBucketInfo
& bucket_info
, int shard_id
, string
*bucket_ver
, string
*master_ver
,
1344 map
<RGWObjCategory
, RGWStorageStats
>& stats
, string
*max_marker
, bool* syncstopped
= NULL
);
1345 int get_bucket_stats_async(RGWBucketInfo
& bucket_info
, int shard_id
, RGWGetBucketStats_CB
*cb
);
1347 int put_bucket_instance_info(RGWBucketInfo
& info
, bool exclusive
, ceph::real_time mtime
, map
<string
, bufferlist
> *pattrs
);
1348 /* xxx dang obj_ctx -> svc */
1349 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
);
1350 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
);
1352 static void make_bucket_entry_name(const string
& tenant_name
, const string
& bucket_name
, string
& bucket_entry
);
1354 int get_bucket_info(RGWServices
*svc
,
1355 const string
& tenant_name
, const string
& bucket_name
,
1356 RGWBucketInfo
& info
,
1357 ceph::real_time
*pmtime
, optional_yield y
, map
<string
, bufferlist
> *pattrs
= NULL
);
1359 // Returns 0 on successful refresh. Returns error code if there was
1360 // an error or the version stored on the OSD is the same as that
1361 // presented in the BucketInfo structure.
1363 int try_refresh_bucket_info(RGWBucketInfo
& info
,
1364 ceph::real_time
*pmtime
,
1365 map
<string
, bufferlist
> *pattrs
= nullptr);
1367 int put_linked_bucket_info(RGWBucketInfo
& info
, bool exclusive
, ceph::real_time mtime
, obj_version
*pep_objv
,
1368 map
<string
, bufferlist
> *pattrs
, bool create_entry_point
);
1370 int cls_obj_prepare_op(BucketShard
& bs
, RGWModifyOp op
, string
& tag
, rgw_obj
& obj
, uint16_t bilog_flags
, optional_yield y
, rgw_zone_set
*zones_trace
= nullptr);
1371 int cls_obj_complete_op(BucketShard
& bs
, const rgw_obj
& obj
, RGWModifyOp op
, string
& tag
, int64_t pool
, uint64_t epoch
,
1372 rgw_bucket_dir_entry
& ent
, RGWObjCategory category
, list
<rgw_obj_index_key
> *remove_objs
, uint16_t bilog_flags
, rgw_zone_set
*zones_trace
= nullptr);
1373 int cls_obj_complete_add(BucketShard
& bs
, const rgw_obj
& obj
, string
& tag
, int64_t pool
, uint64_t epoch
, rgw_bucket_dir_entry
& ent
,
1374 RGWObjCategory category
, list
<rgw_obj_index_key
> *remove_objs
, uint16_t bilog_flags
, rgw_zone_set
*zones_trace
= nullptr);
1375 int cls_obj_complete_del(BucketShard
& bs
, string
& tag
, int64_t pool
, uint64_t epoch
, rgw_obj
& obj
,
1376 ceph::real_time
& removed_mtime
, list
<rgw_obj_index_key
> *remove_objs
, uint16_t bilog_flags
, rgw_zone_set
*zones_trace
= nullptr);
1377 int cls_obj_complete_cancel(BucketShard
& bs
, string
& tag
, rgw_obj
& obj
, uint16_t bilog_flags
, rgw_zone_set
*zones_trace
= nullptr);
1378 int cls_obj_set_bucket_tag_timeout(RGWBucketInfo
& bucket_info
, uint64_t timeout
);
1381 boost::container::flat_map
<std::string
, rgw_bucket_dir_entry
>;
1383 using check_filter_t
= bool (*)(const std::string
&);
1385 int cls_bucket_list_ordered(RGWBucketInfo
& bucket_info
,
1387 const rgw_obj_index_key
& start_after
,
1388 const string
& prefix
,
1389 const string
& delimiter
,
1390 const uint32_t num_entries
,
1391 const bool list_versions
,
1392 const uint16_t exp_factor
, // 0 means ignore
1396 rgw_obj_index_key
*last_entry
,
1398 check_filter_t force_check_filter
= nullptr);
1399 int cls_bucket_list_unordered(RGWBucketInfo
& bucket_info
,
1401 const rgw_obj_index_key
& start_after
,
1402 const string
& prefix
,
1403 uint32_t num_entries
,
1405 vector
<rgw_bucket_dir_entry
>& ent_list
,
1407 rgw_obj_index_key
*last_entry
,
1409 check_filter_t
= nullptr);
1410 int cls_bucket_head(const RGWBucketInfo
& bucket_info
, int shard_id
, vector
<rgw_bucket_dir_header
>& headers
, map
<int, string
> *bucket_instance_ids
= NULL
);
1411 int cls_bucket_head_async(const RGWBucketInfo
& bucket_info
, int shard_id
, RGWGetDirHeader_CB
*ctx
, int *num_aio
);
1413 int bi_get_instance(const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, rgw_bucket_dir_entry
*dirent
);
1414 int bi_get_olh(const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, rgw_bucket_olh_entry
*olh
);
1415 int bi_get(const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, BIIndexType index_type
, rgw_cls_bi_entry
*entry
);
1416 void bi_put(librados::ObjectWriteOperation
& op
, BucketShard
& bs
, rgw_cls_bi_entry
& entry
);
1417 int bi_put(BucketShard
& bs
, rgw_cls_bi_entry
& entry
);
1418 int bi_put(rgw_bucket
& bucket
, rgw_obj
& obj
, rgw_cls_bi_entry
& entry
);
1419 int bi_list(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
);
1420 int bi_list(BucketShard
& bs
, const string
& filter_obj
, const string
& marker
, uint32_t max
, list
<rgw_cls_bi_entry
> *entries
, bool *is_truncated
);
1421 int bi_list(rgw_bucket
& bucket
, const string
& obj_name
, const string
& marker
, uint32_t max
,
1422 list
<rgw_cls_bi_entry
> *entries
, bool *is_truncated
);
1423 int bi_remove(BucketShard
& bs
);
1425 int cls_obj_usage_log_add(const string
& oid
, rgw_usage_log_info
& info
);
1426 int cls_obj_usage_log_read(const string
& oid
, const string
& user
, const string
& bucket
, uint64_t start_epoch
,
1427 uint64_t end_epoch
, uint32_t max_entries
, string
& read_iter
, map
<rgw_user_bucket
,
1428 rgw_usage_log_entry
>& usage
, bool *is_truncated
);
1429 int cls_obj_usage_log_trim(const string
& oid
, const string
& user
, const string
& bucket
, uint64_t start_epoch
,
1430 uint64_t end_epoch
);
1431 int cls_obj_usage_log_clear(string
& oid
);
1433 int get_target_shard_id(const rgw::bucket_index_normal_layout
& layout
, const string
& obj_key
, int *shard_id
);
1435 int lock_exclusive(const rgw_pool
& pool
, const string
& oid
, ceph::timespan
& duration
, rgw_zone_id
& zone_id
, string
& owner_id
);
1436 int unlock(const rgw_pool
& pool
, const string
& oid
, rgw_zone_id
& zone_id
, string
& owner_id
);
1438 void update_gc_chain(rgw_obj
& head_obj
, RGWObjManifest
& manifest
, cls_rgw_obj_chain
*chain
);
1439 int send_chain_to_gc(cls_rgw_obj_chain
& chain
, const string
& tag
);
1440 void delete_objs_inline(cls_rgw_obj_chain
& chain
, const string
& tag
);
1441 int gc_operate(string
& oid
, librados::ObjectWriteOperation
*op
);
1442 int gc_aio_operate(const std::string
& oid
, librados::AioCompletion
*c
,
1443 librados::ObjectWriteOperation
*op
);
1444 int gc_operate(string
& oid
, librados::ObjectReadOperation
*op
, bufferlist
*pbl
);
1446 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
);
1447 int process_gc(bool expired_only
);
1448 bool process_expire_objects();
1449 int defer_gc(void *ctx
, const RGWBucketInfo
& bucket_info
, const rgw_obj
& obj
, optional_yield y
);
1452 int list_lc_progress(string
& marker
, uint32_t max_entries
,
1453 vector
<rgw::sal::Lifecycle::LCEntry
>& progress_map
, int& index
);
1455 int bucket_check_index(RGWBucketInfo
& bucket_info
,
1456 map
<RGWObjCategory
, RGWStorageStats
> *existing_stats
,
1457 map
<RGWObjCategory
, RGWStorageStats
> *calculated_stats
);
1458 int bucket_rebuild_index(RGWBucketInfo
& bucket_info
);
1459 int bucket_set_reshard(const RGWBucketInfo
& bucket_info
, const cls_rgw_bucket_instance_entry
& entry
);
1460 int remove_objs_from_index(RGWBucketInfo
& bucket_info
, list
<rgw_obj_index_key
>& oid_list
);
1461 int move_rados_obj(librados::IoCtx
& src_ioctx
,
1462 const string
& src_oid
, const string
& src_locator
,
1463 librados::IoCtx
& dst_ioctx
,
1464 const string
& dst_oid
, const string
& dst_locator
);
1465 int fix_head_obj_locator(const RGWBucketInfo
& bucket_info
, bool copy_obj
, bool remove_bad
, rgw_obj_key
& key
);
1466 int fix_tail_obj_locator(const RGWBucketInfo
& bucket_info
, rgw_obj_key
& key
, bool fix
, bool *need_fix
, optional_yield y
);
1468 int check_quota(const rgw_user
& bucket_owner
, rgw_bucket
& bucket
,
1469 RGWQuotaInfo
& user_quota
, RGWQuotaInfo
& bucket_quota
, uint64_t obj_size
,
1470 optional_yield y
, bool check_size_only
= false);
1472 int check_bucket_shards(const RGWBucketInfo
& bucket_info
, const rgw_bucket
& bucket
,
1475 int add_bucket_to_reshard(const RGWBucketInfo
& bucket_info
, uint32_t new_num_shards
);
1477 uint64_t instance_id();
1479 librados::Rados
* get_rados_handle();
1481 int delete_raw_obj_aio(const rgw_raw_obj
& obj
, list
<librados::AioCompletion
*>& handles
);
1482 int delete_obj_aio(const rgw_obj
& obj
, RGWBucketInfo
& info
, RGWObjState
*astate
,
1483 list
<librados::AioCompletion
*>& handles
, bool keep_index_consistent
,
1488 * Check the actual on-disk state of the object specified
1489 * by list_state, and fill in the time and size of object.
1490 * Then append any changes to suggested_updates for
1491 * the rgw class' dir_suggest_changes function.
1493 * Note that this can maul list_state; don't use it afterwards. Also
1494 * it expects object to already be filled in from list_state; it only
1495 * sets the size and mtime.
1497 * Returns 0 on success, -ENOENT if the object doesn't exist on disk,
1498 * and -errno on other failures. (-ENOENT is not a failure, and it
1499 * will encode that info as a suggested update.)
1501 int check_disk_state(librados::IoCtx io_ctx
,
1502 const RGWBucketInfo
& bucket_info
,
1503 rgw_bucket_dir_entry
& list_state
,
1504 rgw_bucket_dir_entry
& object
,
1505 bufferlist
& suggested_updates
,
1509 * Init pool iteration
1510 * pool: pool to use for the ctx initialization
1511 * ctx: context object to use for the iteration
1512 * Returns: 0 on success, -ERR# otherwise.
1514 int pool_iterate_begin(const rgw_pool
& pool
, RGWPoolIterCtx
& ctx
);
1517 * Init pool iteration
1519 * cursor: position to start iteration
1520 * ctx: context object to use for the iteration
1521 * Returns: 0 on success, -ERR# otherwise.
1523 int pool_iterate_begin(const rgw_pool
& pool
, const string
& cursor
, RGWPoolIterCtx
& ctx
);
1526 * Get pool iteration position
1527 * ctx: context object to use for the iteration
1528 * Returns: string representation of position
1530 string
pool_iterate_get_cursor(RGWPoolIterCtx
& ctx
);
1533 * Iterate over pool return object names, use optional filter
1534 * ctx: iteration context, initialized with pool_iterate_begin()
1535 * num: max number of objects to return
1536 * objs: a vector that the results will append into
1537 * is_truncated: if not NULL, will hold true iff iteration is complete
1538 * filter: if not NULL, will be used to filter returned objects
1539 * Returns: 0 on success, -ERR# otherwise.
1541 int pool_iterate(RGWPoolIterCtx
& ctx
, uint32_t num
, vector
<rgw_bucket_dir_entry
>& objs
,
1542 bool *is_truncated
, RGWAccessListFilter
*filter
);
1544 uint64_t next_bucket_id();
1547 * This is broken out to facilitate unit testing.
1549 static uint32_t calc_ordered_bucket_list_per_shard(uint32_t num_entries
,
1550 uint32_t num_shards
);