diff options
author | Loic Dachary <ldachary@redhat.com> | 2017-04-10 22:51:18 +0200 |
---|---|---|
committer | Loic Dachary <ldachary@redhat.com> | 2017-04-10 23:21:29 +0200 |
commit | 83b695f08e6efa400a581a1cd56ae030661c3fbb (patch) | |
tree | e7684c9e149728c94675f59e9bbc743f358fbcd8 /src | |
parent | mon: set-device-class implicitly creates OSD (diff) | |
download | ceph-83b695f08e6efa400a581a1cd56ae030661c3fbb.tar.xz ceph-83b695f08e6efa400a581a1cd56ae030661c3fbb.zip |
osd: split mon_cmd_maybe_osd_create out of update_crush_location
Signed-off-by: Loic Dachary <loic@dachary.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/osd/OSD.cc | 73 | ||||
-rw-r--r-- | src/osd/OSD.h | 1 |
2 files changed, 40 insertions, 34 deletions
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 4350b5de28c..ea67e40f843 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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); } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 33f54765e73..90821997caa 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -2414,6 +2414,7 @@ protected: } private: + int mon_cmd_maybe_osd_create(string &cmd); int update_crush_location(); static int write_meta(ObjectStore *store, |