]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_mon: use the same `store` instace
authorMatan Breizman <mbreizma@redhat.com>
Wed, 19 Jul 2023 09:39:31 +0000 (09:39 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Mon, 23 Oct 2023 13:35:23 +0000 (13:35 +0000)
Fixes: https://tracker.ceph.com/issues/61820
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
(cherry picked from commit e48ef1f6c52cf769374f891a2d699f508aeabf5e)

src/ceph_mon.cc

index ebd110b4254b863c87ab99d8e5d2be34107cf909..96cdab43b9f8b152893fefffb4832cfb037a4203 100644 (file)
@@ -367,6 +367,8 @@ int main(int argc, const char **argv)
     exit(1);
   }
 
+  MonitorDBStore *store = new MonitorDBStore(g_conf()->mon_data);
+
   // -- mkfs --
   if (mkfs) {
 
@@ -522,9 +524,8 @@ int main(int argc, const char **argv)
     }
 
     // go
-    MonitorDBStore store(g_conf()->mon_data);
     ostringstream oss;
-    int r = store.create_and_open(oss);
+    int r = store->create_and_open(oss);
     if (oss.tellp())
       derr << oss.str() << dendl;
     if (r < 0) {
@@ -534,13 +535,13 @@ int main(int argc, const char **argv)
     }
     ceph_assert(r == 0);
 
-    Monitor mon(g_ceph_context, g_conf()->name.get_id(), &store, 0, 0, &monmap);
+    Monitor mon(g_ceph_context, g_conf()->name.get_id(), store, 0, 0, &monmap);
     r = mon.mkfs(osdmapbl);
     if (r < 0) {
       derr << argv[0] << ": error creating monfs: " << cpp_strerror(r) << dendl;
       exit(1);
     }
-    store.close();
+    store->close();
     dout(0) << argv[0] << ": created monfs at " << g_conf()->mon_data 
            << " for " << g_conf()->name << dendl;
     return 0;
@@ -618,8 +619,6 @@ int main(int argc, const char **argv)
   // set up signal handlers, now that we've daemonized/forked.
   init_async_signal_handler();
 
-  MonitorDBStore *store = new MonitorDBStore(g_conf()->mon_data);
-
   // make sure we aren't upgrading too fast
   {
     string val;