From: Yehuda Sadeh Date: Tue, 20 Nov 2018 12:45:17 +0000 (-0800) Subject: rgw: fixes following rebase X-Git-Tag: v14.1.0~616^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f7b13f1d5828eef404b2f719918d18d80b463c2;p=ceph.git rgw: fixes following rebase Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index b028acffab54..ff8bd0ebeb89 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2691,11 +2691,11 @@ static int trim_sync_error_log(int shard_id, const ceph::real_time& start_time, } JSONFormattable& get_tier_config(RGWRados *store) { - return store->get_zone_params().tier_config; + return store->svc.zone->get_zone_params().tier_config; } const string& get_tier_type(RGWRados *store) { - return store->get_zone().tier_type; + return store->svc.zone->get_zone().tier_type; } int main(int argc, const char **argv) diff --git a/src/rgw/rgw_cr_tools.cc b/src/rgw/rgw_cr_tools.cc index d25c3166caf5..c13521835dcb 100644 --- a/src/rgw/rgw_cr_tools.cc +++ b/src/rgw/rgw_cr_tools.cc @@ -5,6 +5,7 @@ #include "rgw_user.h" #include "rgw_op.h" #include "rgw_acl_s3.h" +#include "rgw_zone.h" #define dout_context g_ceph_context #define dout_subsys ceph_subsys_rgw @@ -92,7 +93,7 @@ int RGWGetUserInfoCR::Request::_send_request() template<> int RGWGetBucketInfoCR::Request::_send_request() { - RGWObjectCtx obj_ctx(store); + RGWSysObjectCtx obj_ctx(store->svc.sysobj->init_obj_ctx()); return store->get_bucket_info(obj_ctx, params.tenant, params.bucket_name, result->bucket_info, &result->mtime, &result->attrs); } @@ -101,29 +102,31 @@ template<> int RGWBucketCreateLocalCR::Request::_send_request() { CephContext *cct = store->ctx(); + auto& zone_svc = store->svc.zone; + auto& sysobj_svc = store->svc.sysobj; const auto& user_info = params.user_info.get(); const auto& user = user_info->user_id; const auto& bucket_name = params.bucket_name; auto& placement_rule = params.placement_rule; - const auto& zonegroup = store->get_zonegroup(); + const auto& zonegroup = zone_svc->get_zonegroup(); if (!placement_rule.empty() && !zonegroup.placement_targets.count(placement_rule)) { ldout(cct, 0) << "placement target (" << placement_rule << ")" << " doesn't exist in the placement targets of zonegroup" - << " (" << store->get_zonegroup().api_name << ")" << dendl; + << " (" << zone_svc->get_zonegroup().api_name << ")" << dendl; return -ERR_INVALID_LOCATION_CONSTRAINT; } /* we need to make sure we read bucket info, it's not read before for this * specific request */ - RGWObjectCtx obj_ctx(store); + RGWSysObjectCtx sysobj_ctx(sysobj_svc->init_obj_ctx()); RGWBucketInfo bucket_info; map bucket_attrs; - int ret = store->get_bucket_info(obj_ctx, user.tenant, bucket_name, + int ret = store->get_bucket_info(sysobj_ctx, user.tenant, bucket_name, bucket_info, nullptr, &bucket_attrs); if (ret < 0 && ret != -ENOENT) return ret; @@ -148,14 +151,14 @@ int RGWBucketCreateLocalCR::Request::_send_request() uint32_t *pmaster_num_shards = nullptr; real_time creation_time; - string zonegroup_id = store->get_zonegroup().get_id(); + string zonegroup_id = zone_svc->get_zonegroup().get_id(); if (bucket_exists) { string selected_placement_rule; rgw_bucket bucket; bucket.tenant = user.tenant; bucket.name = bucket_name; - ret = store->select_bucket_placement(*user_info, zonegroup_id, + ret = zone_svc->select_bucket_placement(*user_info, zonegroup_id, placement_rule, &selected_placement_rule, nullptr); if (selected_placement_rule != bucket_info.placement_rule) { diff --git a/src/rgw/rgw_pubsub.cc b/src/rgw/rgw_pubsub.cc index e7e4fa09338a..32d4261ba5cc 100644 --- a/src/rgw/rgw_pubsub.cc +++ b/src/rgw/rgw_pubsub.cc @@ -407,7 +407,7 @@ int RGWUserPubSub::Sub::list_events(const string& marker, int max_events, RGWBucketInfo bucket_info; string tenant; - RGWObjectCtx obj_ctx(store); + RGWSysObjectCtx obj_ctx(store->svc.sysobj->init_obj_ctx()); ret = store->get_bucket_info(obj_ctx, tenant, sub_conf.dest.bucket_name, bucket_info, nullptr, nullptr); if (ret == -ENOENT) { result->is_truncated = false; @@ -472,8 +472,8 @@ int RGWUserPubSub::Sub::remove_event(const string& event_id) RGWBucketInfo bucket_info; string tenant; - RGWObjectCtx obj_ctx(store); - ret = store->get_bucket_info(obj_ctx, tenant, sub_conf.dest.bucket_name, bucket_info, nullptr, nullptr); + RGWSysObjectCtx sysobj_ctx(store->svc.sysobj->init_obj_ctx()); + ret = store->get_bucket_info(sysobj_ctx, tenant, sub_conf.dest.bucket_name, bucket_info, nullptr, nullptr); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: failed to read bucket info for events bucket: bucket=" << sub_conf.dest.bucket_name << " ret=" << ret << dendl; return ret; @@ -481,9 +481,10 @@ int RGWUserPubSub::Sub::remove_event(const string& event_id) rgw_bucket& bucket = bucket_info.bucket; + RGWObjectCtx obj_ctx(store); rgw_obj obj(bucket, event_id); - obj_ctx.obj.set_atomic(obj); + obj_ctx.set_atomic(obj); RGWRados::Object del_target(store, bucket_info, obj_ctx, obj); RGWRados::Object::Delete del_op(&del_target); diff --git a/src/rgw/rgw_pubsub.h b/src/rgw/rgw_pubsub.h index 9f12cf1f7e06..2c62af19f96c 100644 --- a/src/rgw/rgw_pubsub.h +++ b/src/rgw/rgw_pubsub.h @@ -3,6 +3,9 @@ #include "rgw_common.h" #include "rgw_tools.h" +#include "rgw_zone.h" + +#include "services/svc_sys_obj.h" struct rgw_pubsub_event { @@ -209,7 +212,7 @@ class RGWUserPubSub RGWRados *store; rgw_user user; - RGWObjectCtx obj_ctx; + RGWSysObjectCtx obj_ctx; rgw_raw_obj user_meta_obj; @@ -238,7 +241,7 @@ class RGWUserPubSub public: RGWUserPubSub(RGWRados *_store, const rgw_user& _user) : store(_store), user(_user), - obj_ctx(store) { + obj_ctx(store->svc.sysobj->init_obj_ctx()) { get_user_meta_obj(&user_meta_obj); } @@ -302,15 +305,15 @@ public: } void get_user_meta_obj(rgw_raw_obj *obj) const { - *obj = rgw_raw_obj(store->get_zone_params().log_pool, user_meta_oid()); + *obj = rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, user_meta_oid()); } void get_bucket_meta_obj(const rgw_bucket& bucket, rgw_raw_obj *obj) const { - *obj = rgw_raw_obj(store->get_zone_params().log_pool, bucket_meta_oid(bucket)); + *obj = rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, bucket_meta_oid(bucket)); } void get_sub_meta_obj(const string& name, rgw_raw_obj *obj) const { - *obj = rgw_raw_obj(store->get_zone_params().log_pool, sub_meta_oid(name)); + *obj = rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, sub_meta_oid(name)); } int get_user_topics(rgw_pubsub_user_topics *result); diff --git a/src/rgw/rgw_sync_module_pubsub.cc b/src/rgw/rgw_sync_module_pubsub.cc index c0dba42455a8..7b8be230bb74 100644 --- a/src/rgw/rgw_sync_module_pubsub.cc +++ b/src/rgw/rgw_sync_module_pubsub.cc @@ -720,7 +720,7 @@ class PSSubscription { string addr; if (split_endpoint(sub_conf->push_endpoint, &addr, &sub->push.path)) { list endpoints{addr}; - sub->push.conn = std::make_shared(sync_env->cct, sync_env->store, remote_id, endpoints); + sub->push.conn = std::make_shared(sync_env->cct, sync_env->store->svc.zone, remote_id, endpoints); } else { ldout(sync_env->cct, 20) << "failed to split push endpoint: " << sub_conf->push_endpoint << dendl; } @@ -917,7 +917,7 @@ class PSManager rgw_raw_obj obj; ups.get_sub_meta_obj(sub_name, &obj); bool empty_on_enoent = false; - call(new ReadInfoCR(sync_env->async_rados, sync_env->store, + call(new ReadInfoCR(sync_env->async_rados, sync_env->store->svc.sysobj, obj, &user_sub_conf, empty_on_enoent)); } @@ -1098,7 +1098,7 @@ public: using ReadInfoCR = RGWSimpleRadosReadCR; yield { bool empty_on_enoent = true; - call(new ReadInfoCR(sync_env->async_rados, sync_env->store, + call(new ReadInfoCR(sync_env->async_rados, sync_env->store->svc.sysobj, bucket_obj, &bucket_topics, empty_on_enoent)); } @@ -1112,7 +1112,7 @@ public: using ReadUserTopicsInfoCR = RGWSimpleRadosReadCR; yield { bool empty_on_enoent = true; - call(new ReadUserTopicsInfoCR(sync_env->async_rados, sync_env->store, + call(new ReadUserTopicsInfoCR(sync_env->async_rados, sync_env->store->svc.sysobj, user_obj, &user_topics, empty_on_enoent)); } @@ -1388,7 +1388,7 @@ public: void init(RGWDataSyncEnv *sync_env, uint64_t instance_id) override { PSManagerRef mgr = PSManager::get_shared(sync_env, env); - env->init_instance(sync_env->store->get_realm(), instance_id, mgr); + env->init_instance(sync_env->store->svc.zone->get_realm(), instance_id, mgr); } RGWCoroutine *start_sync(RGWDataSyncEnv *sync_env) override { diff --git a/src/rgw/rgw_sync_module_pubsub_rest.cc b/src/rgw/rgw_sync_module_pubsub_rest.cc index d8106df69b5d..960bf5b4c04d 100644 --- a/src/rgw/rgw_sync_module_pubsub_rest.cc +++ b/src/rgw/rgw_sync_module_pubsub_rest.cc @@ -650,9 +650,7 @@ public: return ret; } - RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); - - ret = store->get_bucket_info(obj_ctx, s->owner.get_id().tenant, bucket_name, + ret = store->get_bucket_info(*s->sysobj_ctx, s->owner.get_id().tenant, bucket_name, bucket_info, nullptr, nullptr); if (ret < 0) { return ret; @@ -727,9 +725,7 @@ public: return ret; } - RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); - - ret = store->get_bucket_info(obj_ctx, s->owner.get_id().tenant, bucket_name, + ret = store->get_bucket_info(*s->sysobj_ctx, s->owner.get_id().tenant, bucket_name, bucket_info, nullptr, nullptr); if (ret < 0) { return ret; @@ -800,9 +796,7 @@ public: return ret; } - RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); - - ret = store->get_bucket_info(obj_ctx, s->owner.get_id().tenant, bucket_name, + ret = store->get_bucket_info(*s->sysobj_ctx, s->owner.get_id().tenant, bucket_name, bucket_info, nullptr, nullptr); if (ret < 0) { return ret; diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index ac6b744e4ced..a9b934a02bd0 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -18,8 +18,10 @@ #include "rgw_putobj_processor.h" #include "rgw_aio_throttle.h" #include "rgw_compression.h" +#include "rgw_zone.h" #include "services/svc_sys_obj.h" +#include "services/svc_zone_utils.h" #define dout_subsys ceph_subsys_rgw #define dout_context g_ceph_context @@ -277,7 +279,7 @@ void rgw_filter_attrset(map& unfiltered_attrset, const strin RGWDataAccess::RGWDataAccess(RGWRados *_store) : store(_store) { - obj_ctx = std::make_unique(store); + sysobj_ctx = std::make_unique(store->svc.sysobj->init_obj_ctx()); } @@ -300,7 +302,7 @@ int RGWDataAccess::Bucket::finish_init() int RGWDataAccess::Bucket::init() { - int ret = sd->store->get_bucket_info(*sd->obj_ctx, + int ret = sd->store->get_bucket_info(*sd->sysobj_ctx, tenant, name, bucket_info, &mtime, @@ -346,7 +348,7 @@ int RGWDataAccess::Object::put(bufferlist& data, auto& owner = bucket->policy.get_owner(); - string req_id = store->unique_id(store->get_new_req_id()); + string req_id = store->svc.zone_utils->unique_id(store->get_new_req_id()); AtomicObjectProcessor processor(&aio, store, bucket_info, owner.get_id(), @@ -363,7 +365,7 @@ int RGWDataAccess::Object::put(bufferlist& data, CompressorRef plugin; boost::optional compressor; - const auto& compression_type = store->get_zone_params().get_compression_type(bucket_info.placement_rule); + const auto& compression_type = store->svc.zone->get_zone_params().get_compression_type(bucket_info.placement_rule); if (compression_type != "none") { plugin = Compressor::create(store->ctx(), compression_type); if (!plugin) { @@ -442,6 +444,8 @@ int RGWDataAccess::Object::put(bufferlist& data, void RGWDataAccess::Object::set_policy(const RGWAccessControlPolicy& policy) { policy.encode(aclbl.emplace()); +} + int rgw_tools_init(CephContext *cct) { ext_mime_map = new std::map; diff --git a/src/rgw/rgw_tools.h b/src/rgw/rgw_tools.h index 1ca2452a6f17..b77e99c4f679 100644 --- a/src/rgw/rgw_tools.h +++ b/src/rgw/rgw_tools.h @@ -85,7 +85,7 @@ using RGWMD5Etag = RGWEtag; class RGWDataAccess { RGWRados *store; - std::unique_ptr obj_ctx; + std::unique_ptr sysobj_ctx; public: RGWDataAccess(RGWRados *_store); diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index f982915382ce..caedfb3146d7 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -488,7 +488,7 @@ struct RGWZoneGroupPlacementTarget { std::string name; set tags; - bool user_permitted(list& user_tags) const { + bool user_permitted(const list& user_tags) const { if (tags.empty()) { return true; } diff --git a/src/rgw/services/svc_zone.cc b/src/rgw/services/svc_zone.cc index 614f11d0b9ad..13dbdd2a0e1e 100644 --- a/src/rgw/services/svc_zone.cc +++ b/src/rgw/services/svc_zone.cc @@ -937,7 +937,7 @@ bool RGWSI_Zone::is_syncing_bucket_meta(const rgw_bucket& bucket) } -int RGWSI_Zone::select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_id, const string& request_rule, +int RGWSI_Zone::select_new_bucket_location(const RGWUserInfo& user_info, const string& zonegroup_id, const string& request_rule, string *pselected_rule_name, RGWZonePlacementInfo *rule_info) { @@ -1035,7 +1035,7 @@ int RGWSI_Zone::select_bucket_location_by_rule(const string& location_rule, RGWZ return 0; } -int RGWSI_Zone::select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& placement_rule, +int RGWSI_Zone::select_bucket_placement(const RGWUserInfo& user_info, const string& zonegroup_id, const string& placement_rule, string *pselected_rule_name, RGWZonePlacementInfo *rule_info) { if (!get_zone_params().placement_pools.empty()) { diff --git a/src/rgw/services/svc_zone.h b/src/rgw/services/svc_zone.h index fd9ec109b91a..469f7f631e2f 100644 --- a/src/rgw/services/svc_zone.h +++ b/src/rgw/services/svc_zone.h @@ -103,10 +103,10 @@ public: RGWRESTConn *get_zone_conn_by_name(const string& name); bool find_zone_id_by_name(const string& name, string *id); - int select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& rule, + int select_bucket_placement(const RGWUserInfo& user_info, const string& zonegroup_id, const string& rule, string *pselected_rule_name, RGWZonePlacementInfo *rule_info); int select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info); - int select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_id, const string& rule, + int select_new_bucket_location(const RGWUserInfo& user_info, const string& zonegroup_id, const string& rule, string *pselected_rule_name, RGWZonePlacementInfo *rule_info); int select_bucket_location_by_rule(const string& location_rule, RGWZonePlacementInfo *rule_info);