From 97e44b644e85c46044c5ce7add8637bf42437600 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 7 Sep 2018 04:53:55 -0700 Subject: [PATCH] rgw-admin: api adjustments now compiles Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 200 +++++++++++++++++++----------------- src/rgw/rgw_orphan.cc | 4 +- src/rgw/rgw_rados.h | 4 +- src/rgw/services/svc_zone.h | 7 +- 4 files changed, 111 insertions(+), 104 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index af05dbe73de..9e1b9fbdb48 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -51,6 +51,9 @@ extern "C" { #include "rgw_role.h" #include "rgw_reshard.h" #include "rgw_http_client_curl.h" +#include "rgw_zone.h" + +#include "services/svc_sync_modules.h" #define dout_context g_ceph_context #define dout_subsys ceph_subsys_rgw @@ -1602,12 +1605,12 @@ static boost::optional get_remote_conn(RGWRados *store, { boost::optional conn; if (remote == zonegroup.get_id()) { - conn.emplace(store->ctx(), store, remote, zonegroup.endpoints); + conn.emplace(store->ctx(), store->svc.zone, remote, zonegroup.endpoints); } else { for (const auto& z : zonegroup.zones) { const auto& zone = z.second; if (remote == zone.id) { - conn.emplace(store->ctx(), store, remote, zone.endpoints); + conn.emplace(store->ctx(), store->svc.zone, remote, zone.endpoints); break; } } @@ -1700,17 +1703,17 @@ static int commit_period(RGWRealm& realm, RGWPeriod& period, return -EINVAL; } // are we the period's master zone? - if (store->get_zone_params().get_id() == master_zone) { + if (store->svc.zone->get_zone_params().get_id() == master_zone) { // read the current period RGWPeriod current_period; - int ret = current_period.init(g_ceph_context, store, realm.get_id()); + int ret = current_period.init(g_ceph_context, store->svc.sysobj, realm.get_id()); if (ret < 0) { cerr << "Error initializing current period: " << cpp_strerror(-ret) << std::endl; return ret; } // the master zone can commit locally - ret = period.commit(realm, current_period, cerr, force); + ret = period.commit(store, realm, current_period, cerr, force); if (ret < 0) { cerr << "failed to commit period: " << cpp_strerror(-ret) << std::endl; } @@ -1801,7 +1804,7 @@ static int update_period(const string& realm_id, const string& realm_name, Formatter *formatter, bool force) { RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0 ) { cerr << "Error initializing realm " << cpp_strerror(-ret) << std::endl; return ret; @@ -1811,7 +1814,7 @@ static int update_period(const string& realm_id, const string& realm_name, epoch = atoi(period_epoch.c_str()); } RGWPeriod period(period_id, epoch); - ret = period.init(g_ceph_context, store, realm.get_id()); + ret = period.init(g_ceph_context, store->svc.sysobj, realm.get_id()); if (ret < 0) { cerr << "period init failed: " << cpp_strerror(-ret) << std::endl; return ret; @@ -1883,7 +1886,7 @@ static int do_period_pull(RGWRESTConn *remote_conn, const string& url, cerr << "request failed: " << cpp_strerror(-ret) << std::endl; return ret; } - ret = period->init(g_ceph_context, store, false); + ret = period->init(g_ceph_context, store->svc.sysobj, false); if (ret < 0) { cerr << "faile to init period " << cpp_strerror(-ret) << std::endl; return ret; @@ -1908,7 +1911,7 @@ static int read_current_period_id(RGWRados* store, const std::string& realm_id, std::string* period_id) { RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { std::cerr << "failed to read realm: " << cpp_strerror(-ret) << std::endl; return ret; @@ -2002,7 +2005,7 @@ static void get_md_sync_status(list& status) push_ss(ss, status) << "incremental sync: " << num_inc << "/" << total_shards << " shards"; map master_shards_info; - string master_period = store->get_current_period_id(); + string master_period = store->svc.zone->get_current_period_id(); ret = sync.read_master_log_shards_info(master_period, &master_shards_info); if (ret < 0) { @@ -2073,15 +2076,15 @@ static void get_data_sync_status(const string& source_zone, list& status { stringstream ss; - auto ziter = store->zone_by_id.find(source_zone); - if (ziter == store->zone_by_id.end()) { + RGWZone *sz; + + if (!store->svc.zone->find_zone_by_id(source_zone, &sz)) { push_ss(ss, status, tab) << string("zone not found"); flush_ss(ss, status); return; } - RGWZone& sz = ziter->second; - if (!store->zone_syncs_from(store->get_zone(), sz)) { + if (!store->svc.zone->zone_syncs_from(store->svc.zone->get_zone(), *sz)) { push_ss(ss, status, tab) << string("not syncing from zone"); flush_ss(ss, status); return; @@ -2240,9 +2243,9 @@ static void tab_dump(const string& header, int width, const list& entrie static void sync_status(Formatter *formatter) { - RGWRealm& realm = store->realm; - RGWZoneGroup& zonegroup = store->get_zonegroup(); - RGWZone& zone = store->get_zone(); + RGWRealm& realm = store->svc.zone->get_realm(); + RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup(); + RGWZone& zone = store->svc.zone->get_zone(); int width = 15; @@ -2252,7 +2255,7 @@ static void sync_status(Formatter *formatter) list md_status; - if (store->is_meta_master()) { + if (store->svc.zone->is_meta_master()) { md_status.push_back("no sync (zone is master)"); } else { get_md_sync_status(md_status); @@ -2262,13 +2265,15 @@ static void sync_status(Formatter *formatter) list data_status; - for (auto iter : store->zone_conn_map) { + auto& zone_conn_map = store->svc.zone->get_zone_conn_map(); + + for (auto iter : zone_conn_map) { const string& source_id = iter.first; string source_str = "source: "; string s = source_str + source_id; - auto siter = store->zone_by_id.find(source_id); - if (siter != store->zone_by_id.end()) { - s += string(" (") + siter->second.name + ")"; + RGWZone *sz; + if (store->svc.zone->find_zone_by_id(source_id, &sz)) { + s += string(" (") + sz->name + ")"; } data_status.push_back(s); get_data_sync_status(source_id, data_status, source_str.size()); @@ -2384,9 +2389,9 @@ static int bucket_sync_status(RGWRados *store, const RGWBucketInfo& info, const std::string& source_zone_id, std::ostream& out) { - RGWRealm& realm = store->realm; - RGWZoneGroup& zonegroup = store->get_zonegroup(); - RGWZone& zone = store->get_zone(); + RGWRealm& realm = store->svc.zone->get_realm(); + RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup(); + RGWZone& zone = store->svc.zone->get_zone(); constexpr int width = 15; out << indented{width, "realm"} << realm.get_id() << " (" << realm.get_name() << ")\n"; @@ -2399,6 +2404,7 @@ static int bucket_sync_status(RGWRados *store, const RGWBucketInfo& info, return 0; } + auto& zone_conn_map = store->svc.zone->get_zone_conn_map(); if (!source_zone_id.empty()) { auto z = zonegroup.zones.find(source_zone_id); if (z == zonegroup.zones.end()) { @@ -2406,8 +2412,8 @@ static int bucket_sync_status(RGWRados *store, const RGWBucketInfo& info, << zonegroup.get_name() << dendl; return -EINVAL; } - auto c = store->zone_conn_map.find(source_zone_id); - if (c == store->zone_conn_map.end()) { + auto c = zone_conn_map.find(source_zone_id); + if (c == zone_conn_map.end()) { lderr(store->ctx()) << "No connection to zone " << z->second.name << dendl; return -EINVAL; } @@ -2416,8 +2422,8 @@ static int bucket_sync_status(RGWRados *store, const RGWBucketInfo& info, } for (const auto& z : zonegroup.zones) { - auto c = store->zone_conn_map.find(z.second.id); - if (c != store->zone_conn_map.end()) { + auto c = zone_conn_map.find(z.second.id); + if (c != zone_conn_map.end()) { bucket_source_sync_status(store, zone, z.second, c->second, info, width, out); } @@ -3302,7 +3308,7 @@ int main(int argc, const char **argv) } if (!source_zone_name.empty()) { - if (!store->find_zone_id_by_name(source_zone_name, &source_zone)) { + if (!store->svc.zone->find_zone_id_by_name(source_zone_name, &source_zone)) { cerr << "WARNING: cannot find source zone id for name=" << source_zone_name << std::endl; source_zone = source_zone_name; } @@ -3336,7 +3342,7 @@ int main(int argc, const char **argv) return EINVAL; } RGWPeriod period(period_id); - int ret = period.init(g_ceph_context, store); + int ret = period.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "period.init failed: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3357,7 +3363,7 @@ int main(int argc, const char **argv) } if (staging) { RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0 ) { cerr << "Error initializing realm " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3368,7 +3374,7 @@ int main(int argc, const char **argv) epoch = 1; } RGWPeriod period(period_id, epoch); - int ret = period.init(g_ceph_context, store, realm_id, realm_name); + int ret = period.init(g_ceph_context, store->svc.sysobj, realm_id, realm_name); if (ret < 0) { cerr << "period init failed: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3392,7 +3398,7 @@ int main(int argc, const char **argv) case OPT_PERIOD_LIST: { list periods; - int ret = store->list_periods(periods); + int ret = store->svc.zone->list_periods(periods); if (ret < 0) { cerr << "failed to list periods: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3420,13 +3426,13 @@ int main(int argc, const char **argv) if (url.empty()) { // load current period for endpoints RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl; return -ret; } RGWPeriod current_period(realm.get_current_period()); - ret = current_period.init(g_ceph_context, store); + ret = current_period.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init current period: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3463,7 +3469,7 @@ int main(int argc, const char **argv) case OPT_GLOBAL_QUOTA_DISABLE: { if (realm_id.empty()) { - RGWRealm realm(g_ceph_context, store); + RGWRealm realm(g_ceph_context, store->svc.sysobj); if (!realm_name.empty()) { // look up realm_id for the given realm_name int ret = realm.read_id(realm_name, realm_id); @@ -3484,7 +3490,7 @@ int main(int argc, const char **argv) } RGWPeriodConfig period_config; - int ret = period_config.read(store, realm_id); + int ret = period_config.read(store->svc.sysobj, realm_id); if (ret < 0 && ret != -ENOENT) { cerr << "ERROR: failed to read period config: " << cpp_strerror(-ret) << std::endl; @@ -3515,7 +3521,7 @@ int main(int argc, const char **argv) if (opt_cmd != OPT_GLOBAL_QUOTA_GET) { // write the modified period config - ret = period_config.write(store, realm_id); + ret = period_config.write(store->svc.sysobj, realm_id); if (ret < 0) { cerr << "ERROR: failed to write period config: " << cpp_strerror(-ret) << std::endl; @@ -3541,7 +3547,7 @@ int main(int argc, const char **argv) return EINVAL; } - RGWRealm realm(realm_name, g_ceph_context, store); + RGWRealm realm(realm_name, g_ceph_context, store->svc.sysobj); int ret = realm.create(); if (ret < 0) { cerr << "ERROR: couldn't create realm " << realm_name << ": " << cpp_strerror(-ret) << std::endl; @@ -3566,7 +3572,7 @@ int main(int argc, const char **argv) cerr << "missing realm name or id" << std::endl; return EINVAL; } - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "realm.init failed: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3582,7 +3588,7 @@ int main(int argc, const char **argv) case OPT_REALM_GET: { RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { if (ret == -ENOENT && realm_name.empty() && realm_id.empty()) { cerr << "missing realm name or id, or default realm not found" << std::endl; @@ -3597,7 +3603,7 @@ int main(int argc, const char **argv) break; case OPT_REALM_GET_DEFAULT: { - RGWRealm realm(g_ceph_context, store); + RGWRealm realm(g_ceph_context, store->svc.sysobj); string default_id; int ret = realm.read_default_id(default_id); if (ret == -ENOENT) { @@ -3612,14 +3618,14 @@ int main(int argc, const char **argv) break; case OPT_REALM_LIST: { - RGWRealm realm(g_ceph_context, store); + RGWRealm realm(g_ceph_context, store->svc.sysobj); string default_id; int ret = realm.read_default_id(default_id); if (ret < 0 && ret != -ENOENT) { cerr << "could not determine default realm: " << cpp_strerror(-ret) << std::endl; } list realms; - ret = store->list_realms(realms); + ret = store->svc.zone->list_realms(realms); if (ret < 0) { cerr << "failed to list realms: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3638,7 +3644,7 @@ int main(int argc, const char **argv) return -ret; } list periods; - ret = store->list_periods(period_id, periods); + ret = store->svc.zone->list_periods(period_id, periods); if (ret < 0) { cerr << "list periods failed: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3662,7 +3668,7 @@ int main(int argc, const char **argv) cerr << "missing realm name or id" << std::endl; return EINVAL; } - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "realm.init failed: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3685,7 +3691,7 @@ int main(int argc, const char **argv) } RGWRealm realm(realm_id, realm_name); bool new_realm = false; - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0 && ret != -ENOENT) { cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3732,7 +3738,7 @@ int main(int argc, const char **argv) case OPT_REALM_DEFAULT: { RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3774,7 +3780,7 @@ int main(int argc, const char **argv) return -ret; } RGWRealm realm; - realm.init(g_ceph_context, store, false); + realm.init(g_ceph_context, store->svc.sysobj, false); try { decode_json_obj(realm, &p); } catch (JSONDecoder::err& e) { @@ -3826,14 +3832,14 @@ int main(int argc, const char **argv) } RGWZoneGroup zonegroup(zonegroup_id,zonegroup_name); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to initialize zonegroup " << zonegroup_name << " id " << zonegroup_id << " :" << cpp_strerror(-ret) << std::endl; return -ret; } RGWZoneParams zone(zone_id, zone_name); - ret = zone.init(g_ceph_context, store); + ret = zone.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3884,13 +3890,13 @@ int main(int argc, const char **argv) return EINVAL; } RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl; return -ret; } - RGWZoneGroup zonegroup(zonegroup_name, is_master, g_ceph_context, store, realm.get_id(), endpoints); + RGWZoneGroup zonegroup(zonegroup_name, is_master, g_ceph_context, store->svc.sysobj, realm.get_id(), endpoints); zonegroup.api_name = (api_name.empty() ? zonegroup_name : api_name); ret = zonegroup.create(); if (ret < 0) { @@ -3917,7 +3923,7 @@ int main(int argc, const char **argv) } RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3937,7 +3943,7 @@ int main(int argc, const char **argv) return EINVAL; } RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3952,7 +3958,7 @@ int main(int argc, const char **argv) case OPT_ZONEGROUP_GET: { RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3965,14 +3971,14 @@ int main(int argc, const char **argv) case OPT_ZONEGROUP_LIST: { RGWZoneGroup zonegroup; - int ret = zonegroup.init(g_ceph_context, store, false); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj, false); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; } list zonegroups; - ret = store->list_zonegroups(zonegroups); + ret = store->svc.zone->list_zonegroups(zonegroups); if (ret < 0) { cerr << "failed to list zonegroups: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -3992,14 +3998,14 @@ int main(int argc, const char **argv) case OPT_ZONEGROUP_MODIFY: { RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl; return -ret; } RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - ret = zonegroup.init(g_ceph_context, store); + ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4032,7 +4038,7 @@ int main(int argc, const char **argv) need_update = true; } else if (!realm_name.empty()) { // get realm id from name - RGWRealm realm{g_ceph_context, store}; + RGWRealm realm{g_ceph_context, store->svc.sysobj}; ret = realm.read_id(realm_name, zonegroup.realm_id); if (ret < 0) { cerr << "failed to find realm by name " << realm_name << std::endl; @@ -4063,7 +4069,7 @@ int main(int argc, const char **argv) case OPT_ZONEGROUP_SET: { RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); bool default_realm_not_exist = (ret == -ENOENT && realm_id.empty() && realm_name.empty()); if (ret < 0 && !default_realm_not_exist ) { @@ -4072,7 +4078,7 @@ int main(int argc, const char **argv) } RGWZoneGroup zonegroup; - ret = zonegroup.init(g_ceph_context, store, false); + ret = zonegroup.init(g_ceph_context, store->svc.sysobj, false); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4110,7 +4116,7 @@ int main(int argc, const char **argv) case OPT_ZONEGROUP_REMOVE: { RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4156,7 +4162,7 @@ int main(int argc, const char **argv) return EINVAL; } RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4171,7 +4177,7 @@ int main(int argc, const char **argv) case OPT_ZONEGROUP_PLACEMENT_LIST: { RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4192,7 +4198,7 @@ int main(int argc, const char **argv) } RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4252,7 +4258,7 @@ int main(int argc, const char **argv) RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); /* if the user didn't provide zonegroup info , create stand alone zone */ if (!zonegroup_id.empty() || !zonegroup_name.empty()) { - ret = zonegroup.init(g_ceph_context, store); + ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "unable to initialize zonegroup " << zonegroup_name << ": " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4263,7 +4269,7 @@ int main(int argc, const char **argv) } RGWZoneParams zone(zone_id, zone_name); - ret = zone.init(g_ceph_context, store, false); + ret = zone.init(g_ceph_context, store->svc.sysobj, false); if (ret < 0) { cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4320,7 +4326,7 @@ int main(int argc, const char **argv) case OPT_ZONE_DEFAULT: { RGWZoneGroup zonegroup(zonegroup_id,zonegroup_name); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "WARNING: failed to initialize zonegroup " << zonegroup_name << std::endl; } @@ -4329,7 +4335,7 @@ int main(int argc, const char **argv) return EINVAL; } RGWZoneParams zone(zone_id, zone_name); - ret = zone.init(g_ceph_context, store); + ret = zone.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4348,14 +4354,14 @@ int main(int argc, const char **argv) return EINVAL; } RGWZoneParams zone(zone_id, zone_name); - int ret = zone.init(g_ceph_context, store); + int ret = zone.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl; return -ret; } list zonegroups; - ret = store->list_zonegroups(zonegroups); + ret = store->svc.zone->list_zonegroups(zonegroups); if (ret < 0) { cerr << "failed to list zonegroups: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4363,7 +4369,7 @@ int main(int argc, const char **argv) for (list::iterator iter = zonegroups.begin(); iter != zonegroups.end(); ++iter) { RGWZoneGroup zonegroup(string(), *iter); - int ret = zonegroup.init(g_ceph_context, store); + int ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "WARNING: failed to initialize zonegroup " << zonegroup_name << std::endl; continue; @@ -4385,7 +4391,7 @@ int main(int argc, const char **argv) case OPT_ZONE_GET: { RGWZoneParams zone(zone_id, zone_name); - int ret = zone.init(g_ceph_context, store); + int ret = zone.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4397,7 +4403,7 @@ int main(int argc, const char **argv) case OPT_ZONE_SET: { RGWZoneParams zone(zone_name); - int ret = zone.init(g_ceph_context, store, false); + int ret = zone.init(g_ceph_context, store->svc.sysobj, false); if (ret < 0) { return -ret; } @@ -4417,7 +4423,7 @@ int main(int argc, const char **argv) if(zone.realm_id.empty()) { RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0 && ret != -ENOENT) { cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4480,14 +4486,14 @@ int main(int argc, const char **argv) case OPT_ZONE_LIST: { list zones; - int ret = store->list_zones(zones); + int ret = store->svc.zone->list_zones(zones); if (ret < 0) { cerr << "failed to list zones: " << cpp_strerror(-ret) << std::endl; return -ret; } RGWZoneParams zone; - ret = zone.init(g_ceph_context, store, false); + ret = zone.init(g_ceph_context, store->svc.sysobj, false); if (ret < 0) { cerr << "failed to init zone: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4507,7 +4513,7 @@ int main(int argc, const char **argv) case OPT_ZONE_MODIFY: { RGWZoneParams zone(zone_id, zone_name); - int ret = zone.init(g_ceph_context, store); + int ret = zone.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zone: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4529,7 +4535,7 @@ int main(int argc, const char **argv) need_zone_update = true; } else if (!realm_name.empty()) { // get realm id from name - RGWRealm realm{g_ceph_context, store}; + RGWRealm realm{g_ceph_context, store->svc.sysobj}; ret = realm.read_id(realm_name, zone.realm_id); if (ret < 0) { cerr << "failed to find realm by name " << realm_name << std::endl; @@ -4565,7 +4571,7 @@ int main(int argc, const char **argv) } RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - ret = zonegroup.init(g_ceph_context, store); + ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4615,7 +4621,7 @@ int main(int argc, const char **argv) return EINVAL; } RGWZoneParams zone(zone_id,zone_name); - int ret = zone.init(g_ceph_context, store); + int ret = zone.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4627,7 +4633,7 @@ int main(int argc, const char **argv) return -ret; } RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); - ret = zonegroup.init(g_ceph_context, store); + ret = zonegroup.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "WARNING: failed to initialize zonegroup " << zonegroup_name << std::endl; } else { @@ -4655,7 +4661,7 @@ int main(int argc, const char **argv) } RGWZoneParams zone(zone_id, zone_name); - int ret = zone.init(g_ceph_context, store); + int ret = zone.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "failed to init zone: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4736,7 +4742,7 @@ int main(int argc, const char **argv) case OPT_ZONE_PLACEMENT_LIST: { RGWZoneParams zone(zone_id, zone_name); - int ret = zone.init(g_ceph_context, store); + int ret = zone.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4962,7 +4968,7 @@ int main(int argc, const char **argv) // load the period RGWPeriod period(period_id); - int ret = period.init(g_ceph_context, store); + int ret = period.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "period init failed: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4996,13 +5002,13 @@ int main(int argc, const char **argv) { // read realm and staging period RGWRealm realm(realm_id, realm_name); - int ret = realm.init(g_ceph_context, store); + int ret = realm.init(g_ceph_context, store->svc.sysobj); if (ret < 0) { cerr << "Error initializing realm: " << cpp_strerror(-ret) << std::endl; return -ret; } RGWPeriod period(RGWPeriod::get_staging_id(realm.get_id()), 1); - ret = period.init(g_ceph_context, store, realm.get_id()); + ret = period.init(g_ceph_context, store->svc.sysobj, realm.get_id()); if (ret < 0) { cerr << "period init failed: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -5522,7 +5528,7 @@ next: exit(1); } - int ret = store->add_bucket_placement(pool); + int ret = store->svc.zone->add_bucket_placement(pool); if (ret < 0) cerr << "failed to add bucket placement: " << cpp_strerror(-ret) << std::endl; } @@ -5533,14 +5539,14 @@ next: exit(1); } - int ret = store->remove_bucket_placement(pool); + int ret = store->svc.zone->remove_bucket_placement(pool); if (ret < 0) cerr << "failed to remove bucket placement: " << cpp_strerror(-ret) << std::endl; } if (opt_cmd == OPT_POOLS_LIST) { set pools; - int ret = store->list_placement_set(pools); + int ret = store->svc.zone->list_placement_set(pools); if (ret < 0) { cerr << "could not list placement set: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -6911,8 +6917,8 @@ next: } RGWSyncModuleInstanceRef sync_module; - int ret = store->svc.sync_modules->get_manager()->create_instance(g_ceph_context, store->get_zone().tier_type, - store->get_zone_params().tier_config, &sync_module); + int ret = store->svc.sync_modules->get_manager()->create_instance(g_ceph_context, store->svc.zone->get_zone().tier_type, + store->svc.zone->get_zone_params().tier_config, &sync_module); if (ret < 0) { lderr(cct) << "ERROR: failed to init sync module instance, ret=" << ret << dendl; return ret; @@ -6972,13 +6978,13 @@ next: return ret; } RGWPeriod period; - ret = period.init(g_ceph_context, store, realm_id, realm_name, true); + ret = period.init(g_ceph_context, store->svc.sysobj, realm_id, realm_name, true); if (ret < 0) { cerr << "failed to init period " << ": " << cpp_strerror(-ret) << std::endl; return ret; } - if (!store->is_meta_master()) { + if (!store->svc.zone->is_meta_master()) { cerr << "failed to update bucket sync: only allowed on meta master zone " << std::endl; cerr << period.get_master_zone() << " | " << period.get_realm() << std::endl; return EINVAL; diff --git a/src/rgw/rgw_orphan.cc b/src/rgw/rgw_orphan.cc index 707cc54fb66..68b8af80220 100644 --- a/src/rgw/rgw_orphan.cc +++ b/src/rgw/rgw_orphan.cc @@ -11,6 +11,8 @@ #include "rgw_rados.h" #include "rgw_orphan.h" +#include "services/svc_zone.h" + #define dout_subsys ceph_subsys_rgw #define DEFAULT_NUM_SHARDS 64 @@ -141,7 +143,7 @@ int RGWOrphanStore::list_jobs(map & job_list) int RGWOrphanStore::init() { - rgw_pool& log_pool = store->get_zone_params().log_pool; + rgw_pool& log_pool = store->svc.zone->get_zone_params().log_pool; int r = rgw_init_ioctx(store->get_rados_handle(), log_pool, ioctx); if (r < 0) { cerr << "ERROR: failed to open log pool (" << log_pool << " ret=" << r << std::endl; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index afee1367a3d..f0553a6fd4c 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -28,6 +28,7 @@ #include "rgw_sync_log_trim.h" #include "services/svc_rados.h" +#include "services/svc_zone.h" class RGWWatcher; class SafeTimer; @@ -1480,9 +1481,6 @@ public: rgw_bucket *master_bucket, uint32_t *master_num_shards, bool exclusive = true); - int add_bucket_placement(const rgw_pool& new_pool); - int remove_bucket_placement(const rgw_pool& new_pool); - int list_placement_set(set& names); int create_pools(vector& pools, vector& retcodes); RGWCoroutinesManagerRegistry *get_cr_registry() { return cr_registry; } diff --git a/src/rgw/services/svc_zone.h b/src/rgw/services/svc_zone.h index 54c05df707b..b26684cc2bc 100644 --- a/src/rgw/services/svc_zone.h +++ b/src/rgw/services/svc_zone.h @@ -54,9 +54,6 @@ class RGWSI_Zone : public RGWServiceInstance int convert_regionmap(); int update_placement_map(); - int add_bucket_placement(const rgw_pool& new_pool); - int remove_bucket_placement(const rgw_pool& old_pool); - int list_placement_set(set& names); public: RGWSI_Zone(RGWService *svc, CephContext *cct): RGWServiceInstance(svc, cct) {} @@ -111,6 +108,10 @@ public: string *pselected_rule_name, RGWZonePlacementInfo *rule_info); int select_bucket_location_by_rule(const string& location_rule, RGWZonePlacementInfo *rule_info); + int add_bucket_placement(const rgw_pool& new_pool); + int remove_bucket_placement(const rgw_pool& old_pool); + int list_placement_set(set& names); + bool is_meta_master() const; bool need_to_log_data() const; -- 2.39.5