]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW - Split RGWRados initialization 46115/head
authorDaniel Gryniewicz <dang@redhat.com>
Mon, 2 May 2022 14:15:40 +0000 (10:15 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Mon, 2 May 2022 16:01:09 +0000 (12:01 -0400)
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 <dang@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_sal.cc

index 3524c501e0461ef108fe1b401777e15e5fde6128..bab53d500d474fb40003a1e51cabcd942507b6c5 100644 (file)
@@ -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();
 }
 
 /**
index 0fd7c4ec7a08e269795f481afd2233f88ff5b063..80b382ce9dec056f0cd27f8b4bc4d0e7fb5cfee6 100644 (file)
@@ -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<std::string, std::string>& meta);
index 988b231decc5a17a771c982af34691004bd445e5..78f63156e78d0209c4dd812ae1eba3b8507b4b99 100644 (file)
@@ -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;
     }