From c9fdc3260a5c23a541d310eaa8fcedbe879c3f67 Mon Sep 17 00:00:00 2001 From: Daniel Gryniewicz Date: Mon, 2 May 2022 10:15:40 -0400 Subject: [PATCH] RGW - Split RGWRados initialization The inter-connectedness of RadosStore and RGWRados resulted in a segfault during RGWRados::init_complete due to the rados pointer not being set in RadosStore yet. Split the calls to RGWRados::initialize and RGWRados::init_complete, so that we can set up RadosStore between them, allowing the services created in RGWRados::init_complete to access the RadosStore. Fixes: https://tracker.ceph.com/issues/55512 Signed-off-by: Daniel Gryniewicz --- src/rgw/rgw_rados.cc | 8 ++------ src/rgw/rgw_rados.h | 6 +++--- src/rgw/rgw_sal.cc | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 3524c501e0461..bab53d500d474 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1355,7 +1355,7 @@ int RGWRados::init_ctl(const DoutPrefixProvider *dpp) * Initialize the RADOS instance and prepare to do other ops * Returns 0 on success, -ERR# on failure. */ -int RGWRados::initialize(const DoutPrefixProvider *dpp) +int RGWRados::init_begin(const DoutPrefixProvider *dpp) { int ret; @@ -1377,11 +1377,7 @@ int RGWRados::initialize(const DoutPrefixProvider *dpp) host_id = svc.zone_utils->gen_host_id(); - ret = init_rados(); - if (ret < 0) - return ret; - - return init_complete(dpp); + return init_rados(); } /** diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 0fd7c4ec7a08e..80b382ce9dec0 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -581,16 +581,16 @@ public: CephContext *ctx() { return cct; } /** do all necessary setup of the storage device */ - int initialize(CephContext *_cct, const DoutPrefixProvider *dpp) { + int init_begin(CephContext *_cct, const DoutPrefixProvider *dpp) { set_context(_cct); - return initialize(dpp); + return init_begin(dpp); } /** Initialize the RADOS instance and prepare to do other ops */ int init_svc(bool raw, const DoutPrefixProvider *dpp); int init_ctl(const DoutPrefixProvider *dpp); virtual int init_rados(); + int init_begin(const DoutPrefixProvider *dpp); int init_complete(const DoutPrefixProvider *dpp); - int initialize(const DoutPrefixProvider *dpp); void finalize(); int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type, const std::map& meta); diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index 988b231decc5a..78f63156e78d0 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -95,7 +95,7 @@ rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* d .set_run_quota_threads(quota_threads) .set_run_sync_thread(run_sync_thread) .set_run_reshard_thread(run_reshard_thread) - .initialize(cct, dpp) < 0) { + .init_begin(cct, dpp) < 0) { delete store; return nullptr; } @@ -103,6 +103,10 @@ rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* d delete store; return nullptr; } + if (rados->init_complete(dpp) < 0) { + delete store; + return nullptr; + } return store; } else if (svc.compare("d3n") == 0) { @@ -118,7 +122,15 @@ rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* d .set_run_quota_threads(quota_threads) .set_run_sync_thread(run_sync_thread) .set_run_reshard_thread(run_reshard_thread) - .initialize(cct, dpp) < 0) { + .init_begin(cct, dpp) < 0) { + delete store; + return nullptr; + } + if (store->initialize(cct, dpp) < 0) { + delete store; + return nullptr; + } + if (rados->init_complete(dpp) < 0) { delete store; return nullptr; } -- 2.39.5