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