Skip to content

Commit 96f65fd

Browse files
authored
Merge pull request ceph#50599 from cbodley/wip-rgw-sal-forward
rgw: move forward_request_to_master() out of sal Reviewed-by: Daniel Gryniewicz <[email protected]>
2 parents 50aab7d + 0ead6ff commit 96f65fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1167
-2219
lines changed

src/rgw/driver/d4n/rgw_sal_d4n.cc

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,11 @@ std::unique_ptr<Object> D4NFilterBucket::get_object(const rgw_obj_key& k)
5959
return std::make_unique<D4NFilterObject>(std::move(o), this, filter);
6060
}
6161

62-
int D4NFilterUser::create_bucket(const DoutPrefixProvider* dpp,
63-
const rgw_bucket& b,
64-
const std::string& zonegroup_id,
65-
rgw_placement_rule& placement_rule,
66-
std::string& swift_ver_location,
67-
const RGWQuotaInfo * pquota_info,
68-
const RGWAccessControlPolicy& policy,
69-
Attrs& attrs,
70-
RGWBucketInfo& info,
71-
obj_version& ep_objv,
72-
bool exclusive,
73-
bool obj_lock_enabled,
74-
bool* existed,
75-
req_info& req_info,
76-
std::unique_ptr<Bucket>* bucket_out,
77-
optional_yield y)
62+
int D4NFilterBucket::create(const DoutPrefixProvider* dpp,
63+
const CreateParams& params,
64+
optional_yield y)
7865
{
79-
std::unique_ptr<Bucket> nb;
80-
int ret;
81-
82-
ret = next->create_bucket(dpp, b, zonegroup_id, placement_rule, swift_ver_location, pquota_info, policy, attrs, info, ep_objv, exclusive, obj_lock_enabled, existed, req_info, &nb, y);
83-
if (ret < 0)
84-
return ret;
85-
86-
Bucket* fb = new D4NFilterBucket(std::move(nb), this, filter);
87-
bucket_out->reset(fb);
88-
return 0;
66+
return next->create(dpp, params, y);
8967
}
9068

9169
int D4NFilterObject::copy_object(User* user,

src/rgw/driver/d4n/rgw_sal_d4n.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,6 @@ class D4NFilterUser : public FilterUser {
7171
FilterUser(std::move(_next)),
7272
filter(_filter) {}
7373
virtual ~D4NFilterUser() = default;
74-
75-
virtual int create_bucket(const DoutPrefixProvider* dpp,
76-
const rgw_bucket& b,
77-
const std::string& zonegroup_id,
78-
rgw_placement_rule& placement_rule,
79-
std::string& swift_ver_location,
80-
const RGWQuotaInfo* pquota_info,
81-
const RGWAccessControlPolicy& policy,
82-
Attrs& attrs,
83-
RGWBucketInfo& info,
84-
obj_version& ep_objv,
85-
bool exclusive,
86-
bool obj_lock_enabled,
87-
bool* existed,
88-
req_info& req_info,
89-
std::unique_ptr<Bucket>* bucket,
90-
optional_yield y) override;
9174
};
9275

9376
class D4NFilterBucket : public FilterBucket {
@@ -101,6 +84,9 @@ class D4NFilterBucket : public FilterBucket {
10184
virtual ~D4NFilterBucket() = default;
10285

10386
virtual std::unique_ptr<Object> get_object(const rgw_obj_key& key) override;
87+
virtual int create(const DoutPrefixProvider* dpp,
88+
const CreateParams& params,
89+
optional_yield y) override;
10490
};
10591

10692
class D4NFilterObject : public FilterObject {

src/rgw/driver/daos/rgw_sal_daos.cc

Lines changed: 16 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int DaosUser::create_bucket(
101101
std::unique_ptr<Bucket> bucket;
102102

103103
// Look up the bucket. Create it if it doesn't exist.
104-
ret = this->store->get_bucket(dpp, this, b, &bucket, y);
104+
ret = this->store->load_bucket(dpp, this, b, &bucket, y);
105105
if (ret != 0 && ret != -ENOENT) {
106106
return ret;
107107
}
@@ -404,23 +404,19 @@ std::unique_ptr<struct ds3_bucket_info> DaosBucket::get_encoded_info(
404404
return bucket_info;
405405
}
406406

407-
int DaosBucket::remove_bucket(const DoutPrefixProvider* dpp,
408-
bool delete_children, bool forward_to_master,
409-
req_info* req_info, optional_yield y) {
407+
int DaosBucket::remove(const DoutPrefixProvider* dpp,
408+
bool delete_children, optional_yield y) {
410409
ldpp_dout(dpp, 20) << "DEBUG: remove_bucket, delete_children="
411-
412-
<< delete_children
413-
414-
<< " forward_to_master=" << forward_to_master << dendl;
410+
<< delete_children << dendl;
415411

416412
return ds3_bucket_destroy(get_name().c_str(), delete_children, store->ds3,
417413
nullptr);
418414
}
419415

420-
int DaosBucket::remove_bucket_bypass_gc(int concurrent_max,
421-
bool keep_index_consistent,
422-
optional_yield y,
423-
const DoutPrefixProvider* dpp) {
416+
int DaosBucket::remove_bypass_gc(int concurrent_max,
417+
bool keep_index_consistent,
418+
optional_yield y,
419+
const DoutPrefixProvider* dpp) {
424420
ldpp_dout(dpp, 20) << "DEBUG: remove_bucket_bypass_gc, concurrent_max="
425421

426422
<< concurrent_max
@@ -804,19 +800,6 @@ int DaosStore::initialize(CephContext* cct, const DoutPrefixProvider* dpp) {
804800
return ret;
805801
}
806802

807-
const std::string& DaosZoneGroup::get_endpoint() const {
808-
if (!group.endpoints.empty()) {
809-
return group.endpoints.front();
810-
} else {
811-
// use zonegroup's master zone endpoints
812-
auto z = group.zones.find(group.master_zone);
813-
if (z != group.zones.end() && !z->second.endpoints.empty()) {
814-
return z->second.endpoints.front();
815-
}
816-
}
817-
return empty;
818-
}
819-
820803
bool DaosZoneGroup::placement_target_exists(std::string& target) const {
821804
return !!group.placement_targets.count(target);
822805
}
@@ -2253,65 +2236,22 @@ inline std::ostream& operator<<(std::ostream& out, const rgw_user* u) {
22532236
return out << s;
22542237
}
22552238

2256-
int DaosStore::get_bucket(const DoutPrefixProvider* dpp, User* u,
2257-
const rgw_bucket& b, std::unique_ptr<Bucket>* bucket,
2258-
optional_yield y) {
2259-
ldpp_dout(dpp, 20) << "DEBUG: get_bucket1: User: " << u << dendl;
2260-
int ret;
2261-
Bucket* bp;
2262-
2263-
bp = new DaosBucket(this, b, u);
2264-
ret = bp->load_bucket(dpp, y);
2265-
if (ret != 0) {
2266-
delete bp;
2267-
return ret;
2268-
}
2269-
2270-
bucket->reset(bp);
2271-
return 0;
2272-
}
2273-
2274-
int DaosStore::get_bucket(User* u, const RGWBucketInfo& i,
2275-
std::unique_ptr<Bucket>* bucket) {
2276-
DaosBucket* bp;
2277-
2278-
bp = new DaosBucket(this, i, u);
2239+
std::unique_ptr<Bucket> DaosStore::get_bucket(User* u, const RGWBucketInfo& i) {
22792240
/* Don't need to fetch the bucket info, use the provided one */
2280-
2281-
bucket->reset(bp);
2282-
return 0;
2241+
return std::make_unique<DaosBucket>(this, i, u);
22832242
}
22842243

2285-
int DaosStore::get_bucket(const DoutPrefixProvider* dpp, User* u,
2286-
const std::string& tenant, const std::string& name,
2287-
std::unique_ptr<Bucket>* bucket, optional_yield y) {
2288-
ldpp_dout(dpp, 20) << "get_bucket" << dendl;
2289-
rgw_bucket b;
2290-
2291-
b.tenant = tenant;
2292-
b.name = name;
2244+
int DaosStore::load_bucket(const DoutPrefixProvider* dpp, User* u,
2245+
const rgw_bucket& b, std::unique_ptr<Bucket>* bucket,
2246+
optional_yield y) {
2247+
ldpp_dout(dpp, 20) << "DEBUG: get_bucket1: User: " << u << dendl;
22932248

2294-
return get_bucket(dpp, u, b, bucket, y);
2249+
*bucket = std::make_unique<DaosBucket>(this, b, u);
2250+
return (*bucket)->load_bucket(dpp, y);
22952251
}
22962252

22972253
bool DaosStore::is_meta_master() { return true; }
22982254

2299-
int DaosStore::forward_request_to_master(const DoutPrefixProvider* dpp,
2300-
User* user, obj_version* objv,
2301-
bufferlist& in_data, JSONParser* jp,
2302-
req_info& info, optional_yield y) {
2303-
return DAOS_NOT_IMPLEMENTED_LOG(dpp);
2304-
}
2305-
2306-
int DaosStore::forward_iam_request_to_master(const DoutPrefixProvider* dpp,
2307-
const RGWAccessKey& key,
2308-
obj_version* objv,
2309-
bufferlist& in_data,
2310-
RGWXMLDecoder::XMLParser* parser,
2311-
req_info& info, optional_yield y) {
2312-
return DAOS_NOT_IMPLEMENTED_LOG(dpp);
2313-
}
2314-
23152255
std::string DaosStore::zone_unique_id(uint64_t unique_num) { return ""; }
23162256

23172257
std::string DaosStore::zone_unique_trans_id(const uint64_t unique_num) {

src/rgw/driver/daos/rgw_sal_daos.h

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,12 @@ class DaosBucket : public StoreBucket {
289289
virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) override;
290290
virtual int list(const DoutPrefixProvider* dpp, ListParams&, int,
291291
ListResults&, optional_yield y) override;
292-
virtual int remove_bucket(const DoutPrefixProvider* dpp, bool delete_children,
293-
bool forward_to_master, req_info* req_info,
294-
optional_yield y) override;
295-
virtual int remove_bucket_bypass_gc(int concurrent_max,
296-
bool keep_index_consistent,
297-
optional_yield y,
298-
const DoutPrefixProvider* dpp) override;
292+
virtual int remove(const DoutPrefixProvider* dpp, bool delete_children,
293+
optional_yield y) override;
294+
virtual int remove_bypass_gc(int concurrent_max,
295+
bool keep_index_consistent,
296+
optional_yield y,
297+
const DoutPrefixProvider* dpp) override;
299298
virtual RGWAccessControlPolicy& get_acl(void) override { return acls; }
300299
virtual int set_acl(const DoutPrefixProvider* dpp,
301300
RGWAccessControlPolicy& acl, optional_yield y) override;
@@ -403,8 +402,6 @@ class DaosZoneGroup : public StoreZoneGroup {
403402
virtual int equals(const std::string& other_zonegroup) const override {
404403
return group.equals(other_zonegroup);
405404
};
406-
/** Get the endpoint from zonegroup, or from master zone if not set */
407-
virtual const std::string& get_endpoint() const override;
408405
virtual bool placement_target_exists(std::string& target) const override;
409406
virtual bool is_master_zonegroup() const override {
410407
return group.is_master_zonegroup();
@@ -896,25 +893,11 @@ class DaosStore : public StoreDriver {
896893
const std::string& user_str, optional_yield y,
897894
std::unique_ptr<User>* user) override;
898895
virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) override;
899-
virtual int get_bucket(const DoutPrefixProvider* dpp, User* u,
900-
const rgw_bucket& b, std::unique_ptr<Bucket>* bucket,
901-
optional_yield y) override;
902-
virtual int get_bucket(User* u, const RGWBucketInfo& i,
903-
std::unique_ptr<Bucket>* bucket) override;
904-
virtual int get_bucket(const DoutPrefixProvider* dpp, User* u,
905-
const std::string& tenant, const std::string& name,
906-
std::unique_ptr<Bucket>* bucket,
907-
optional_yield y) override;
896+
std::unique_ptr<Bucket> get_bucket(User* u, const RGWBucketInfo& i) override;
897+
int load_bucket(const DoutPrefixProvider* dpp, User* u,
898+
const rgw_bucket& b, std::unique_ptr<Bucket>* bucket,
899+
optional_yield y) override;
908900
virtual bool is_meta_master() override;
909-
virtual int forward_request_to_master(const DoutPrefixProvider* dpp,
910-
User* user, obj_version* objv,
911-
bufferlist& in_data, JSONParser* jp,
912-
req_info& info,
913-
optional_yield y) override;
914-
virtual int forward_iam_request_to_master(
915-
const DoutPrefixProvider* dpp, const RGWAccessKey& key, obj_version* objv,
916-
bufferlist& in_data, RGWXMLDecoder::XMLParser* parser, req_info& info,
917-
optional_yield y) override;
918901
virtual Zone* get_zone() { return &zone; }
919902
virtual std::string zone_unique_id(uint64_t unique_num) override;
920903
virtual std::string zone_unique_trans_id(const uint64_t unique_num) override;

src/rgw/driver/dbstore/common/dbstore.cc

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -474,20 +474,16 @@ int DB::get_bucket_info(const DoutPrefixProvider *dpp, const std::string& query_
474474
}
475475

476476
int DB::create_bucket(const DoutPrefixProvider *dpp,
477-
const RGWUserInfo& owner, rgw_bucket& bucket,
478-
const string& zonegroup_id,
477+
const rgw_user& owner, const rgw_bucket& bucket,
478+
const std::string& zonegroup_id,
479479
const rgw_placement_rule& placement_rule,
480-
const string& swift_ver_location,
481-
const RGWQuotaInfo * pquota_info,
482-
map<std::string, bufferlist>& attrs,
483-
RGWBucketInfo& info,
484-
obj_version *pobjv,
480+
const std::map<std::string, bufferlist>& attrs,
481+
const std::optional<std::string>& swift_ver_location,
482+
const std::optional<RGWQuotaInfo>& quota,
483+
std::optional<ceph::real_time> creation_time,
485484
obj_version *pep_objv,
486-
real_time creation_time,
487-
rgw_bucket *pmaster_bucket,
488-
uint32_t *pmaster_num_shards,
489-
optional_yield y,
490-
bool exclusive)
485+
RGWBucketInfo& info,
486+
optional_yield y)
491487
{
492488
/*
493489
* XXX: Simple creation for now.
@@ -506,50 +502,48 @@ int DB::create_bucket(const DoutPrefixProvider *dpp,
506502
orig_info.bucket.name = bucket.name;
507503
ret = get_bucket_info(dpp, string("name"), "", orig_info, nullptr, nullptr, nullptr);
508504

509-
if (!ret && !orig_info.owner.id.empty() && exclusive) {
505+
if (!ret && !orig_info.owner.id.empty()) {
510506
/* already exists. Return the old info */
511-
512507
info = std::move(orig_info);
513508
return ret;
514509
}
515510

516511
RGWObjVersionTracker& objv_tracker = info.objv_tracker;
517-
518512
objv_tracker.read_version.clear();
513+
objv_tracker.generate_new_write_ver(cct);
519514

520-
if (pobjv) {
521-
objv_tracker.write_version = *pobjv;
522-
} else {
523-
objv_tracker.generate_new_write_ver(cct);
524-
}
525515
params.op.bucket.bucket_version = objv_tracker.write_version;
526516
objv_tracker.read_version = params.op.bucket.bucket_version;
527517

528-
uint64_t bid = next_bucket_id();
529-
string s = getDBname() + "." + std::to_string(bid);
530-
bucket.marker = bucket.bucket_id = s;
531-
532518
info.bucket = bucket;
533-
info.owner = owner.user_id;
519+
if (info.bucket.marker.empty()) {
520+
uint64_t bid = next_bucket_id();
521+
string s = getDBname() + "." + std::to_string(bid);
522+
info.bucket.marker = info.bucket.bucket_id = s;
523+
}
524+
525+
info.owner = owner;
534526
info.zonegroup = zonegroup_id;
535527
info.placement_rule = placement_rule;
536-
info.swift_ver_location = swift_ver_location;
537-
info.swift_versioning = (!swift_ver_location.empty());
528+
if (swift_ver_location) {
529+
info.swift_ver_location = *swift_ver_location;
530+
}
531+
info.swift_versioning = swift_ver_location.has_value();
538532

539533
info.requester_pays = false;
540-
if (real_clock::is_zero(creation_time)) {
541-
info.creation_time = ceph::real_clock::now();
534+
if (creation_time) {
535+
info.creation_time = *creation_time;
542536
} else {
543-
info.creation_time = creation_time;
537+
info.creation_time = ceph::real_clock::now();
544538
}
545-
if (pquota_info) {
546-
info.quota = *pquota_info;
539+
if (quota) {
540+
info.quota = *quota;
547541
}
548542

549543
params.op.bucket.info = info;
550544
params.op.bucket.bucket_attrs = attrs;
551545
params.op.bucket.mtime = ceph::real_time();
552-
params.op.user.uinfo.user_id.id = owner.user_id.id;
546+
params.op.user.uinfo.user_id.id = owner.id;
553547

554548
ret = ProcessOp(dpp, "InsertBucket", &params);
555549

src/rgw/driver/dbstore/common/dbstore.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,20 +1595,16 @@ class DB {
15951595
RGWBucketInfo& info, rgw::sal::Attrs* pattrs, ceph::real_time* pmtime,
15961596
obj_version* pbucket_version);
15971597
int create_bucket(const DoutPrefixProvider *dpp,
1598-
const RGWUserInfo& owner, rgw_bucket& bucket,
1598+
const rgw_user& owner, const rgw_bucket& bucket,
15991599
const std::string& zonegroup_id,
16001600
const rgw_placement_rule& placement_rule,
1601-
const std::string& swift_ver_location,
1602-
const RGWQuotaInfo * pquota_info,
1603-
std::map<std::string, bufferlist>& attrs,
1604-
RGWBucketInfo& info,
1605-
obj_version *pobjv,
1601+
const std::map<std::string, bufferlist>& attrs,
1602+
const std::optional<std::string>& swift_ver_location,
1603+
const std::optional<RGWQuotaInfo>& quota,
1604+
std::optional<ceph::real_time> creation_time,
16061605
obj_version *pep_objv,
1607-
real_time creation_time,
1608-
rgw_bucket *pmaster_bucket,
1609-
uint32_t *pmaster_num_shards,
1610-
optional_yield y,
1611-
bool exclusive);
1606+
RGWBucketInfo& info,
1607+
optional_yield y);
16121608

16131609
int next_bucket_id() { return ++max_bucket_id; };
16141610

0 commit comments

Comments
 (0)