]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_bucket.h
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / rgw_bucket.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #ifndef CEPH_RGW_BUCKET_H
5 #define CEPH_RGW_BUCKET_H
6
7 #include <string>
8 #include <memory>
9 #include <variant>
10
11 #include <boost/container/flat_map.hpp>
12 #include <boost/container/flat_set.hpp>
13
14 #include "include/types.h"
15 #include "rgw_common.h"
16 #include "rgw_tools.h"
17 #include "rgw_metadata.h"
18
19 #include "rgw_string.h"
20
21 #include "common/Formatter.h"
22 #include "common/lru_map.h"
23 #include "common/ceph_time.h"
24
25 #include "rgw_formats.h"
26
27 #include "services/svc_bucket_types.h"
28 #include "services/svc_bucket_sync.h"
29
30 // define as static when RGWBucket implementation completes
31 extern void rgw_get_buckets_obj(const rgw_user& user_id, string& buckets_obj_id);
32
33 class RGWSI_Meta;
34 class RGWBucketMetadataHandler;
35 class RGWBucketInstanceMetadataHandler;
36 class RGWUserCtl;
37 class RGWBucketCtl;
38 class RGWZone;
39 struct RGWZoneParams;
40 namespace rgw { namespace sal {
41 class RGWRadosStore;
42 class RGWBucketList;
43 } }
44
45 extern int rgw_bucket_parse_bucket_instance(const string& bucket_instance, string *bucket_name, string *bucket_id, int *shard_id);
46 extern int rgw_bucket_parse_bucket_key(CephContext *cct, const string& key,
47 rgw_bucket* bucket, int *shard_id);
48
49 extern std::string rgw_make_bucket_entry_name(const std::string& tenant_name,
50 const std::string& bucket_name);
51
52 extern void rgw_parse_url_bucket(const string& bucket,
53 const string& auth_tenant,
54 string &tenant_name, string &bucket_name);
55
56 // this is used as a filter to RGWRados::cls_bucket_list_ordered; it
57 // conforms to the type declaration of RGWRados::check_filter_t.
58 extern bool rgw_bucket_object_check_filter(const string& oid);
59
60 void init_default_bucket_layout(CephContext *cct, rgw::BucketLayout& layout,
61 const RGWZone& zone,
62 std::optional<uint32_t> shards,
63 std::optional<rgw::BucketIndexType> type);
64
65 struct RGWBucketCompleteInfo {
66 RGWBucketInfo info;
67 map<string, bufferlist> attrs;
68
69 void dump(Formatter *f) const;
70 void decode_json(JSONObj *obj);
71 };
72
73 class RGWBucketEntryMetadataObject : public RGWMetadataObject {
74 RGWBucketEntryPoint ep;
75 map<string, bufferlist> attrs;
76 public:
77 RGWBucketEntryMetadataObject(RGWBucketEntryPoint& _ep, const obj_version& v, real_time m) : ep(_ep) {
78 objv = v;
79 mtime = m;
80 set_pattrs (&attrs);
81 }
82 RGWBucketEntryMetadataObject(RGWBucketEntryPoint& _ep, const obj_version& v, real_time m, std::map<string, bufferlist>&& _attrs) :
83 ep(_ep), attrs(std::move(_attrs)) {
84 objv = v;
85 mtime = m;
86 set_pattrs (&attrs);
87 }
88
89 void dump(Formatter *f) const override {
90 ep.dump(f);
91 }
92
93 RGWBucketEntryPoint& get_ep() {
94 return ep;
95 }
96
97 map<string, bufferlist>& get_attrs() {
98 return attrs;
99 }
100 };
101
102 class RGWBucketInstanceMetadataObject : public RGWMetadataObject {
103 RGWBucketCompleteInfo info;
104 public:
105 RGWBucketInstanceMetadataObject() {}
106 RGWBucketInstanceMetadataObject(RGWBucketCompleteInfo& i, const obj_version& v, real_time m) : info(i) {
107 objv = v;
108 mtime = m;
109 }
110
111 void dump(Formatter *f) const override {
112 info.dump(f);
113 }
114
115 void decode_json(JSONObj *obj) {
116 info.decode_json(obj);
117 }
118
119 RGWBucketCompleteInfo& get_bci() {
120 return info;
121 }
122 RGWBucketInfo& get_bucket_info() {
123 return info.info;
124 }
125 };
126
127 /**
128 * Store a list of the user's buckets, with associated functinos.
129 */
130 class RGWUserBuckets
131 {
132 std::map<std::string, RGWBucketEnt> buckets;
133
134 public:
135 RGWUserBuckets() = default;
136 RGWUserBuckets(RGWUserBuckets&&) = default;
137
138 RGWUserBuckets& operator=(const RGWUserBuckets&) = default;
139
140 void encode(bufferlist& bl) const {
141 using ceph::encode;
142 encode(buckets, bl);
143 }
144 void decode(bufferlist::const_iterator& bl) {
145 using ceph::decode;
146 decode(buckets, bl);
147 }
148 /**
149 * Check if the user owns a bucket by the given name.
150 */
151 bool owns(string& name) {
152 map<string, RGWBucketEnt>::iterator iter;
153 iter = buckets.find(name);
154 return (iter != buckets.end());
155 }
156
157 /**
158 * Add a (created) bucket to the user's bucket list.
159 */
160 void add(const RGWBucketEnt& bucket) {
161 buckets[bucket.bucket.name] = bucket;
162 }
163
164 /**
165 * Remove a bucket from the user's list by name.
166 */
167 void remove(const string& name) {
168 map<string, RGWBucketEnt>::iterator iter;
169 iter = buckets.find(name);
170 if (iter != buckets.end()) {
171 buckets.erase(iter);
172 }
173 }
174
175 /**
176 * Get the user's buckets as a map.
177 */
178 map<string, RGWBucketEnt>& get_buckets() { return buckets; }
179
180 /**
181 * Cleanup data structure
182 */
183 void clear() { buckets.clear(); }
184
185 size_t count() { return buckets.size(); }
186 };
187 WRITE_CLASS_ENCODER(RGWUserBuckets)
188
189 class RGWBucketMetadataHandlerBase : public RGWMetadataHandler_GenericMetaBE {
190 public:
191 virtual ~RGWBucketMetadataHandlerBase() {}
192 virtual void init(RGWSI_Bucket *bucket_svc,
193 RGWBucketCtl *bucket_ctl) = 0;
194
195 };
196
197 class RGWBucketInstanceMetadataHandlerBase : public RGWMetadataHandler_GenericMetaBE {
198 public:
199 virtual ~RGWBucketInstanceMetadataHandlerBase() {}
200 virtual void init(RGWSI_Zone *zone_svc,
201 RGWSI_Bucket *bucket_svc,
202 RGWSI_BucketIndex *bi_svc) = 0;
203 };
204
205 class RGWBucketMetaHandlerAllocator {
206 public:
207 static RGWBucketMetadataHandlerBase *alloc();
208 };
209
210 class RGWBucketInstanceMetaHandlerAllocator {
211 public:
212 static RGWBucketInstanceMetadataHandlerBase *alloc();
213 };
214
215 class RGWArchiveBucketMetaHandlerAllocator {
216 public:
217 static RGWBucketMetadataHandlerBase *alloc();
218 };
219
220 class RGWArchiveBucketInstanceMetaHandlerAllocator {
221 public:
222 static RGWBucketInstanceMetadataHandlerBase *alloc();
223 };
224
225 /**
226 * Get all the buckets owned by a user and fill up an RGWUserBuckets with them.
227 * Returns: 0 on success, -ERR# on failure.
228 */
229 extern int rgw_read_user_buckets(const DoutPrefixProvider *dpp,
230 rgw::sal::RGWRadosStore *store,
231 const rgw_user& user_id,
232 rgw::sal::RGWBucketList& buckets,
233 const string& marker,
234 const string& end_marker,
235 uint64_t max,
236 bool need_stats,
237 optional_yield y);
238
239 extern int rgw_remove_object(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, const RGWBucketInfo& bucket_info, const rgw_bucket& bucket, rgw_obj_key& key);
240 extern int rgw_remove_bucket_bypass_gc(rgw::sal::RGWRadosStore *store, rgw_bucket& bucket, int concurrent_max, optional_yield y);
241
242 extern int rgw_object_get_attr(rgw::sal::RGWRadosStore* store, const RGWBucketInfo& bucket_info,
243 const rgw_obj& obj, const char* attr_name,
244 bufferlist& out_bl, optional_yield y);
245
246 extern void check_bad_user_bucket_mapping(rgw::sal::RGWRadosStore *store, const rgw_user& user_id, bool fix, optional_yield y, const DoutPrefixProvider *dpp);
247
248 struct RGWBucketAdminOpState {
249 rgw_user uid;
250 std::string display_name;
251 std::string bucket_name;
252 std::string bucket_id;
253 std::string object_name;
254 std::string new_bucket_name;
255
256 bool list_buckets;
257 bool stat_buckets;
258 bool check_objects;
259 bool fix_index;
260 bool delete_child_objects;
261 bool bucket_stored;
262 bool sync_bucket;
263 int max_aio = 0;
264
265 rgw_bucket bucket;
266
267 RGWQuotaInfo quota;
268
269 void set_fetch_stats(bool value) { stat_buckets = value; }
270 void set_check_objects(bool value) { check_objects = value; }
271 void set_fix_index(bool value) { fix_index = value; }
272 void set_delete_children(bool value) { delete_child_objects = value; }
273
274 void set_max_aio(int value) { max_aio = value; }
275
276 void set_user_id(const rgw_user& user_id) {
277 if (!user_id.empty())
278 uid = user_id;
279 }
280 void set_tenant(const std::string& tenant_str) {
281 uid.tenant = tenant_str;
282 }
283 void set_bucket_name(const std::string& bucket_str) {
284 bucket_name = bucket_str;
285 }
286 void set_object(std::string& object_str) {
287 object_name = object_str;
288 }
289 void set_new_bucket_name(std::string& new_bucket_str) {
290 new_bucket_name = new_bucket_str;
291 }
292 void set_quota(RGWQuotaInfo& value) {
293 quota = value;
294 }
295
296
297 void set_sync_bucket(bool value) { sync_bucket = value; }
298
299 rgw_user& get_user_id() { return uid; }
300 std::string& get_user_display_name() { return display_name; }
301 std::string& get_bucket_name() { return bucket_name; }
302 std::string& get_object_name() { return object_name; }
303 std::string& get_tenant() { return uid.tenant; }
304
305 rgw_bucket& get_bucket() { return bucket; }
306 void set_bucket(rgw_bucket& _bucket) {
307 bucket = _bucket;
308 bucket_stored = true;
309 }
310
311 void set_bucket_id(const string& bi) {
312 bucket_id = bi;
313 }
314 const string& get_bucket_id() { return bucket_id; }
315
316 bool will_fetch_stats() { return stat_buckets; }
317 bool will_fix_index() { return fix_index; }
318 bool will_delete_children() { return delete_child_objects; }
319 bool will_check_objects() { return check_objects; }
320 bool is_user_op() { return !uid.empty(); }
321 bool is_system_op() { return uid.empty(); }
322 bool has_bucket_stored() { return bucket_stored; }
323 int get_max_aio() { return max_aio; }
324 bool will_sync_bucket() { return sync_bucket; }
325
326 RGWBucketAdminOpState() : list_buckets(false), stat_buckets(false), check_objects(false),
327 fix_index(false), delete_child_objects(false),
328 bucket_stored(false), sync_bucket(true) {}
329 };
330
331 /*
332 * A simple wrapper class for administrative bucket operations
333 */
334
335 class RGWBucket
336 {
337 RGWUserBuckets buckets;
338 rgw::sal::RGWRadosStore *store;
339 RGWAccessHandle handle;
340
341 RGWUserInfo user_info;
342 rgw_bucket bucket;
343
344 bool failure;
345
346 RGWBucketInfo bucket_info;
347 RGWObjVersionTracker ep_objv; // entrypoint object version
348
349 public:
350 RGWBucket() : store(NULL), handle(NULL), failure(false) {}
351 int init(rgw::sal::RGWRadosStore *storage, RGWBucketAdminOpState& op_state, optional_yield y,
352 const DoutPrefixProvider *dpp, std::string *err_msg = NULL, map<string, bufferlist> *pattrs = NULL);
353
354 int check_bad_index_multipart(RGWBucketAdminOpState& op_state,
355 RGWFormatterFlusher& flusher,
356 const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
357
358 int check_object_index(const DoutPrefixProvider *dpp,
359 RGWBucketAdminOpState& op_state,
360 RGWFormatterFlusher& flusher,
361 optional_yield y,
362 std::string *err_msg = NULL);
363
364 int check_index(const DoutPrefixProvider *dpp,
365 RGWBucketAdminOpState& op_state,
366 map<RGWObjCategory, RGWStorageStats>& existing_stats,
367 map<RGWObjCategory, RGWStorageStats>& calculated_stats,
368 std::string *err_msg = NULL);
369
370 int link(RGWBucketAdminOpState& op_state, optional_yield y, const DoutPrefixProvider *dpp,
371 map<string, bufferlist>& attrs, std::string *err_msg = NULL);
372 int chown(RGWBucketAdminOpState& op_state, const string& marker,
373 optional_yield y, const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
374 int unlink(RGWBucketAdminOpState& op_state, optional_yield y, const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
375 int set_quota(RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
376
377 int remove_object(const DoutPrefixProvider *dpp, RGWBucketAdminOpState& op_state, std::string *err_msg = NULL);
378 int policy_bl_to_stream(bufferlist& bl, ostream& o);
379 int get_policy(RGWBucketAdminOpState& op_state, RGWAccessControlPolicy& policy, optional_yield y, const DoutPrefixProvider *dpp);
380 int sync(RGWBucketAdminOpState& op_state, map<string, bufferlist> *attrs, const DoutPrefixProvider *dpp, std::string *err_msg = NULL);
381
382 void clear_failure() { failure = false; }
383
384 const RGWBucketInfo& get_bucket_info() const { return bucket_info; }
385 };
386
387 class RGWBucketAdminOp
388 {
389 public:
390 static int get_policy(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
391 RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
392 static int get_policy(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
393 RGWAccessControlPolicy& policy, const DoutPrefixProvider *dpp);
394 static int dump_s3_policy(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
395 ostream& os, const DoutPrefixProvider *dpp);
396
397 static int unlink(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp);
398 static int link(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err_msg = NULL);
399 static int chown(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const string& marker, const DoutPrefixProvider *dpp, string *err_msg = NULL);
400
401 static int check_index(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
402 RGWFormatterFlusher& flusher, optional_yield y, const DoutPrefixProvider *dpp);
403
404 static int remove_bucket(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, optional_yield y,
405 const DoutPrefixProvider *dpp, bool bypass_gc = false, bool keep_index_consistent = true);
406 static int remove_object(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp);
407 static int info(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y, const DoutPrefixProvider *dpp);
408 static int limit_check(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
409 const std::list<std::string>& user_ids,
410 RGWFormatterFlusher& flusher, optional_yield y,
411 const DoutPrefixProvider *dpp,
412 bool warnings_only = false);
413 static int set_quota(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp);
414
415 static int list_stale_instances(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
416 RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
417
418 static int clear_stale_instances(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
419 RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
420 static int fix_lc_shards(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
421 RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
422 static int fix_obj_expiry(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state,
423 RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp, bool dry_run = false);
424
425 static int sync_bucket(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const DoutPrefixProvider *dpp, string *err_msg = NULL);
426 };
427
428 struct rgw_ep_info {
429 RGWBucketEntryPoint &ep;
430 map<std::string, buffer::list>& attrs;
431 RGWObjVersionTracker ep_objv;
432 rgw_ep_info(RGWBucketEntryPoint &ep, map<string, bufferlist>& attrs)
433 : ep(ep), attrs(attrs) {}
434 };
435
436 class RGWBucketCtl
437 {
438 CephContext *cct;
439
440 struct Svc {
441 RGWSI_Zone *zone{nullptr};
442 RGWSI_Bucket *bucket{nullptr};
443 RGWSI_Bucket_Sync *bucket_sync{nullptr};
444 RGWSI_BucketIndex *bi{nullptr};
445 } svc;
446
447 struct Ctl {
448 RGWUserCtl *user{nullptr};
449 } ctl;
450
451 RGWBucketMetadataHandler *bm_handler;
452 RGWBucketInstanceMetadataHandler *bmi_handler;
453
454 RGWSI_Bucket_BE_Handler bucket_be_handler; /* bucket backend handler */
455 RGWSI_BucketInstance_BE_Handler bi_be_handler; /* bucket instance backend handler */
456
457 int call(std::function<int(RGWSI_Bucket_X_Ctx& ctx)> f);
458
459 public:
460 RGWBucketCtl(RGWSI_Zone *zone_svc,
461 RGWSI_Bucket *bucket_svc,
462 RGWSI_Bucket_Sync *bucket_sync_svc,
463 RGWSI_BucketIndex *bi_svc);
464
465 void init(RGWUserCtl *user_ctl,
466 RGWBucketMetadataHandler *_bm_handler,
467 RGWBucketInstanceMetadataHandler *_bmi_handler,
468 RGWDataChangesLog *datalog,
469 const DoutPrefixProvider *dpp);
470
471 struct Bucket {
472 struct GetParams {
473 RGWObjVersionTracker *objv_tracker{nullptr};
474 real_time *mtime{nullptr};
475 map<string, bufferlist> *attrs{nullptr};
476 rgw_cache_entry_info *cache_info{nullptr};
477 boost::optional<obj_version> refresh_version;
478 std::optional<RGWSI_MetaBackend_CtxParams> bectx_params;
479
480 GetParams() {}
481
482 GetParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
483 objv_tracker = _objv_tracker;
484 return *this;
485 }
486
487 GetParams& set_mtime(ceph::real_time *_mtime) {
488 mtime = _mtime;
489 return *this;
490 }
491
492 GetParams& set_attrs(map<string, bufferlist> *_attrs) {
493 attrs = _attrs;
494 return *this;
495 }
496
497 GetParams& set_cache_info(rgw_cache_entry_info *_cache_info) {
498 cache_info = _cache_info;
499 return *this;
500 }
501
502 GetParams& set_refresh_version(const obj_version& _refresh_version) {
503 refresh_version = _refresh_version;
504 return *this;
505 }
506
507 GetParams& set_bectx_params(std::optional<RGWSI_MetaBackend_CtxParams> _bectx_params) {
508 bectx_params = _bectx_params;
509 return *this;
510 }
511 };
512
513 struct PutParams {
514 RGWObjVersionTracker *objv_tracker{nullptr};
515 ceph::real_time mtime;
516 bool exclusive{false};
517 map<string, bufferlist> *attrs{nullptr};
518
519 PutParams() {}
520
521 PutParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
522 objv_tracker = _objv_tracker;
523 return *this;
524 }
525
526 PutParams& set_mtime(const ceph::real_time& _mtime) {
527 mtime = _mtime;
528 return *this;
529 }
530
531 PutParams& set_exclusive(bool _exclusive) {
532 exclusive = _exclusive;
533 return *this;
534 }
535
536 PutParams& set_attrs(map<string, bufferlist> *_attrs) {
537 attrs = _attrs;
538 return *this;
539 }
540 };
541
542 struct RemoveParams {
543 RGWObjVersionTracker *objv_tracker{nullptr};
544
545 RemoveParams() {}
546
547 RemoveParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
548 objv_tracker = _objv_tracker;
549 return *this;
550 }
551 };
552 };
553
554 struct BucketInstance {
555 struct GetParams {
556 real_time *mtime{nullptr};
557 map<string, bufferlist> *attrs{nullptr};
558 rgw_cache_entry_info *cache_info{nullptr};
559 boost::optional<obj_version> refresh_version;
560 RGWObjVersionTracker *objv_tracker{nullptr};
561 std::optional<RGWSI_MetaBackend_CtxParams> bectx_params;
562
563 GetParams() {}
564
565 GetParams& set_mtime(ceph::real_time *_mtime) {
566 mtime = _mtime;
567 return *this;
568 }
569
570 GetParams& set_attrs(map<string, bufferlist> *_attrs) {
571 attrs = _attrs;
572 return *this;
573 }
574
575 GetParams& set_cache_info(rgw_cache_entry_info *_cache_info) {
576 cache_info = _cache_info;
577 return *this;
578 }
579
580 GetParams& set_refresh_version(const obj_version& _refresh_version) {
581 refresh_version = _refresh_version;
582 return *this;
583 }
584
585 GetParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
586 objv_tracker = _objv_tracker;
587 return *this;
588 }
589
590 GetParams& set_bectx_params(std::optional<RGWSI_MetaBackend_CtxParams> _bectx_params) {
591 bectx_params = _bectx_params;
592 return *this;
593 }
594 };
595
596 struct PutParams {
597 std::optional<RGWBucketInfo *> orig_info; /* nullopt: orig_info was not fetched,
598 nullptr: orig_info was not found (new bucket instance */
599 ceph::real_time mtime;
600 bool exclusive{false};
601 map<string, bufferlist> *attrs{nullptr};
602 RGWObjVersionTracker *objv_tracker{nullptr};
603
604 PutParams() {}
605
606 PutParams& set_orig_info(RGWBucketInfo *pinfo) {
607 orig_info = pinfo;
608 return *this;
609 }
610
611 PutParams& set_mtime(const ceph::real_time& _mtime) {
612 mtime = _mtime;
613 return *this;
614 }
615
616 PutParams& set_exclusive(bool _exclusive) {
617 exclusive = _exclusive;
618 return *this;
619 }
620
621 PutParams& set_attrs(map<string, bufferlist> *_attrs) {
622 attrs = _attrs;
623 return *this;
624 }
625
626 PutParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
627 objv_tracker = _objv_tracker;
628 return *this;
629 }
630 };
631
632 struct RemoveParams {
633 RGWObjVersionTracker *objv_tracker{nullptr};
634
635 RemoveParams() {}
636
637 RemoveParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
638 objv_tracker = _objv_tracker;
639 return *this;
640 }
641 };
642 };
643
644 /* bucket entrypoint */
645 int read_bucket_entrypoint_info(const rgw_bucket& bucket,
646 RGWBucketEntryPoint *info,
647 optional_yield y,
648 const DoutPrefixProvider *dpp,
649 const Bucket::GetParams& params = {});
650 int store_bucket_entrypoint_info(const rgw_bucket& bucket,
651 RGWBucketEntryPoint& info,
652 optional_yield y,
653 const DoutPrefixProvider *dpp,
654 const Bucket::PutParams& params = {});
655 int remove_bucket_entrypoint_info(const rgw_bucket& bucket,
656 optional_yield y,
657 const DoutPrefixProvider *dpp,
658 const Bucket::RemoveParams& params = {});
659
660 /* bucket instance */
661 int read_bucket_instance_info(const rgw_bucket& bucket,
662 RGWBucketInfo *info,
663 optional_yield y,
664 const DoutPrefixProvider *dpp,
665 const BucketInstance::GetParams& params = {});
666 int store_bucket_instance_info(const rgw_bucket& bucket,
667 RGWBucketInfo& info,
668 optional_yield y,
669 const DoutPrefixProvider *dpp,
670 const BucketInstance::PutParams& params = {});
671 int remove_bucket_instance_info(const rgw_bucket& bucket,
672 RGWBucketInfo& info,
673 optional_yield y,
674 const DoutPrefixProvider *dpp,
675 const BucketInstance::RemoveParams& params = {});
676
677 /*
678 * bucket_id may or may not be provided
679 *
680 * ep_objv_tracker might not be populated even if provided. Will only be set if entrypoint is read
681 * (that is: if bucket_id is empty).
682 */
683 int read_bucket_info(const rgw_bucket& bucket,
684 RGWBucketInfo *info,
685 optional_yield y,
686 const DoutPrefixProvider *dpp,
687 const BucketInstance::GetParams& params = {},
688 RGWObjVersionTracker *ep_objv_tracker = nullptr);
689
690
691 int set_bucket_instance_attrs(RGWBucketInfo& bucket_info,
692 map<string, bufferlist>& attrs,
693 RGWObjVersionTracker *objv_tracker,
694 optional_yield y,
695 const DoutPrefixProvider *dpp);
696
697 /* user/bucket */
698 int link_bucket(const rgw_user& user_id,
699 const rgw_bucket& bucket,
700 ceph::real_time creation_time,
701 optional_yield y,
702 const DoutPrefixProvider *dpp,
703 bool update_entrypoint = true,
704 rgw_ep_info *pinfo = nullptr);
705
706 int unlink_bucket(const rgw_user& user_id,
707 const rgw_bucket& bucket,
708 optional_yield y,
709 const DoutPrefixProvider *dpp,
710 bool update_entrypoint = true);
711
712 int chown(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
713 const rgw_user& user_id, const std::string& display_name,
714 const std::string& marker, optional_yield y, const DoutPrefixProvider *dpp);
715
716 int set_acl(ACLOwner& owner, rgw_bucket& bucket,
717 RGWBucketInfo& bucket_info, bufferlist& bl, optional_yield y,
718 const DoutPrefixProvider *dpp);
719
720 int read_buckets_stats(map<string, RGWBucketEnt>& m,
721 optional_yield y,
722 const DoutPrefixProvider *dpp);
723
724 int read_bucket_stats(const rgw_bucket& bucket,
725 RGWBucketEnt *result,
726 optional_yield y,
727 const DoutPrefixProvider *dpp);
728
729 /* quota related */
730 int sync_user_stats(const DoutPrefixProvider *dpp,
731 const rgw_user& user_id, const RGWBucketInfo& bucket_info,
732 optional_yield y,
733 RGWBucketEnt* pent = nullptr);
734
735 /* bucket sync */
736 int get_sync_policy_handler(std::optional<rgw_zone_id> zone,
737 std::optional<rgw_bucket> bucket,
738 RGWBucketSyncPolicyHandlerRef *phandler,
739 optional_yield y,
740 const DoutPrefixProvider *dpp);
741 int bucket_exports_data(const rgw_bucket& bucket,
742 optional_yield y,
743 const DoutPrefixProvider *dpp);
744 int bucket_imports_data(const rgw_bucket& bucket,
745 optional_yield y,
746 const DoutPrefixProvider *dpp);
747
748 private:
749 int convert_old_bucket_info(RGWSI_Bucket_X_Ctx& ctx,
750 const rgw_bucket& bucket,
751 optional_yield y,
752 const DoutPrefixProvider *dpp);
753
754 int do_store_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx,
755 const rgw_bucket& bucket,
756 RGWBucketInfo& info,
757 optional_yield y,
758 const DoutPrefixProvider *dpp,
759 const BucketInstance::PutParams& params);
760
761 int do_store_linked_bucket_info(RGWSI_Bucket_X_Ctx& ctx,
762 RGWBucketInfo& info,
763 RGWBucketInfo *orig_info,
764 bool exclusive, real_time mtime,
765 obj_version *pep_objv,
766 map<string, bufferlist> *pattrs,
767 bool create_entry_point,
768 optional_yield,
769 const DoutPrefixProvider *dpp);
770
771 int do_link_bucket(RGWSI_Bucket_EP_Ctx& ctx,
772 const rgw_user& user,
773 const rgw_bucket& bucket,
774 ceph::real_time creation_time,
775 bool update_entrypoint,
776 rgw_ep_info *pinfo,
777 optional_yield y,
778 const DoutPrefixProvider *dpp);
779
780 int do_unlink_bucket(RGWSI_Bucket_EP_Ctx& ctx,
781 const rgw_user& user_id,
782 const rgw_bucket& bucket,
783 bool update_entrypoint,
784 optional_yield y,
785 const DoutPrefixProvider *dpp);
786
787 };
788
789 bool rgw_find_bucket_by_id(const DoutPrefixProvider *dpp, CephContext *cct, RGWMetadataManager *mgr, const string& marker,
790 const string& bucket_id, rgw_bucket* bucket_out);
791
792 #endif