]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: split mon_cmd_maybe_osd_create out of update_crush_location
authorLoic Dachary <ldachary@redhat.com>
Mon, 10 Apr 2017 20:51:18 +0000 (22:51 +0200)
committerLoic Dachary <ldachary@redhat.com>
Mon, 10 Apr 2017 21:21:29 +0000 (23:21 +0200)
Signed-off-by: Loic Dachary <loic@dachary.org>
src/osd/OSD.cc
src/osd/OSD.h

index 4350b5de28c0c91795b59ff6012975c0af0b9c7c..ea67e40f8433ef01a719f746a83c04e8dab32539 100644 (file)
@@ -3021,6 +3021,44 @@ int OSD::shutdown()
   return r;
 }
 
+int OSD::mon_cmd_maybe_osd_create(string &cmd)
+{
+  bool created = false;
+  while (true) {
+    dout(10) << __func__ << " cmd: " << cmd << dendl;
+    vector<string> vcmd{cmd};
+    bufferlist inbl;
+    C_SaferCond w;
+    string outs;
+    monc->start_mon_command(vcmd, inbl, NULL, &outs, &w);
+    int r = w.wait();
+    if (r < 0) {
+      if (r == -ENOENT && !created) {
+       string newcmd = "{\"prefix\": \"osd create\", \"id\": " + stringify(whoami)
+         + ", \"uuid\": \"" + stringify(superblock.osd_fsid) + "\"}";
+       vector<string> vnewcmd{newcmd};
+       bufferlist inbl;
+       C_SaferCond w;
+       string outs;
+       monc->start_mon_command(vnewcmd, inbl, NULL, &outs, &w);
+       int r = w.wait();
+       if (r < 0) {
+         derr << __func__ << " fail: osd does not exist and created failed: "
+              << cpp_strerror(r) << dendl;
+         return r;
+       }
+       created = true;
+       continue;
+      }
+      derr << __func__ << " fail: '" << outs << "': " << cpp_strerror(r) << dendl;
+      return r;
+    }
+    break;
+  }
+
+  return 0;
+}
+
 int OSD::update_crush_location()
 {
   if (!cct->_conf->osd_crush_update_on_start) {
@@ -3059,40 +3097,7 @@ int OSD::update_crush_location()
   }
   cmd += "]}";
 
-  bool created = false;
-  while (true) {
-    dout(10) << __func__ << " cmd: " << cmd << dendl;
-    vector<string> vcmd{cmd};
-    bufferlist inbl;
-    C_SaferCond w;
-    string outs;
-    monc->start_mon_command(vcmd, inbl, NULL, &outs, &w);
-    int r = w.wait();
-    if (r < 0) {
-      if (r == -ENOENT && !created) {
-       string newcmd = "{\"prefix\": \"osd create\", \"id\": " + stringify(whoami)
-         + ", \"uuid\": \"" + stringify(superblock.osd_fsid) + "\"}";
-       vector<string> vnewcmd{newcmd};
-       bufferlist inbl;
-       C_SaferCond w;
-       string outs;
-       monc->start_mon_command(vnewcmd, inbl, NULL, &outs, &w);
-       int r = w.wait();
-       if (r < 0) {
-         derr << __func__ << " fail: osd does not exist and created failed: "
-              << cpp_strerror(r) << dendl;
-         return r;
-       }
-       created = true;
-       continue;
-      }
-      derr << __func__ << " fail: '" << outs << "': " << cpp_strerror(r) << dendl;
-      return r;
-    }
-    break;
-  }
-
-  return 0;
+  return mon_cmd_maybe_osd_create(cmd);
 }
 
 
index 33f54765e73ec273dc891ce1704bb183227223b2..90821997caa26c55e7a944747999071f5d75b48f 100644 (file)
@@ -2414,6 +2414,7 @@ protected:
   }
 
 private:
+  int mon_cmd_maybe_osd_create(string &cmd);
   int update_crush_location();
 
   static int write_meta(ObjectStore *store,