From: Adam C. Emerson Date: Wed, 23 Jan 2019 21:01:40 +0000 (-0500) Subject: rgw: Get rid of num_rados_handles infrastructure in RGWRados X-Git-Tag: v14.2.3~17^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=398c1271ebbe3d02c4e5ae4f54a49f2eeb1cf339;p=ceph.git rgw: Get rid of num_rados_handles infrastructure in RGWRados Since we aren't supporting multiple handles, don't have the overhead. Signed-off-by: Adam C. Emerson (cherry picked from commit 042776bbf64c34dc817980d52cebdd069492b0e6) --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 60134d8707d4..8e47d0f9ea2d 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1410,17 +1410,13 @@ int RGWRados::init_rados() } } - auto handles = std::vector{static_cast(1)}; - - for (auto& r : handles) { - ret = r.init_with_context(cct); - if (ret < 0) { - return ret; - } - ret = r.connect(); - if (ret < 0) { - return ret; - } + ret = rados.init_with_context(cct); + if (ret < 0) { + return ret; + } + ret = rados.connect(); + if (ret < 0) { + return ret; } auto crs = std::unique_ptr{ @@ -1433,15 +1429,13 @@ int RGWRados::init_rados() meta_mgr = new RGWMetadataManager(cct, this); data_log = new RGWDataChangesLog(cct, this); cr_registry = crs.release(); - - std::swap(handles, rados); return ret; } int RGWRados::register_to_service_map(const string& daemon_type, const map& meta) { map metadata = meta; - metadata["num_handles"] = stringify(rados.size()); + metadata["num_handles"] = "1"s; metadata["zonegroup_id"] = svc.zone->get_zonegroup().get_id(); metadata["zonegroup_name"] = svc.zone->get_zonegroup().get_name(); metadata["zone_name"] = svc.zone->zone_name(); @@ -1450,7 +1444,7 @@ int RGWRados::register_to_service_map(const string& daemon_type, const map&& status) { - int ret = rados[0].service_daemon_update_status(move(status)); + int ret = rados.service_daemon_update_status(move(status)); if (ret < 0) { ldout(cct, 0) << "ERROR: service_daemon_update_status() returned ret=" << ret << ": " << cpp_strerror(-ret) << dendl; return ret; @@ -10079,28 +10073,7 @@ void RGWStoreManager::close_storage(RGWRados *store) librados::Rados* RGWRados::get_rados_handle() { - if (rados.size() == 1) { - return &rados[0]; - } else { - handle_lock.get_read(); - pthread_t id = pthread_self(); - std::map:: iterator it = rados_map.find(id); - - if (it != rados_map.end()) { - handle_lock.put_read(); - return &rados[it->second]; - } else { - handle_lock.put_read(); - handle_lock.get_write(); - const uint32_t handle = next_rados_handle; - rados_map[id] = handle; - if (++next_rados_handle == rados.size()) { - next_rados_handle = 0; - } - handle_lock.put_write(); - return &rados[handle]; - } - } + return &rados; } int RGWRados::delete_raw_obj_aio(const rgw_raw_obj& obj, list& handles) diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index ab8676a064f0..22319caaebf9 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1270,10 +1270,7 @@ class RGWRados : public AdminSocketHook protected: CephContext *cct; - std::vector rados; - uint32_t next_rados_handle; - RWLock handle_lock; - std::map rados_map; + librados::Rados rados; using RGWChainedCacheImpl_bucket_info_entry = RGWChainedCacheImpl; RGWChainedCacheImpl_bucket_info_entry *binfo_cache; @@ -1307,8 +1304,6 @@ public: bucket_id_lock("rados_bucket_id"), bucket_index_max_shards(0), max_bucket_id(0), cct(NULL), - next_rados_handle(0), - handle_lock("rados_handle_lock"), binfo_cache(NULL), obj_tombstone_cache(nullptr), pools_initialized(false), quota_handler(NULL),