summaryrefslogtreecommitdiff
path: root/src/mon/OSDMonitor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/mon/OSDMonitor.cc')
-rw-r--r--src/mon/OSDMonitor.cc75
1 files changed, 39 insertions, 36 deletions
diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc
index 14878c4821e..d8648627ad4 100644
--- a/src/mon/OSDMonitor.cc
+++ b/src/mon/OSDMonitor.cc
@@ -812,6 +812,11 @@ bool OSDMonitor::prepare_boot(MOSDBoot *m)
if (m->sb.weight)
osd_weight[from] = m->sb.weight;
+ // set uuid?
+ dout(10) << " setting osd." << from << " uuid to " << m->sb.osd_fsid << dendl;
+ if (osdmap.get_uuid(from) != m->sb.osd_fsid)
+ pending_inc.new_uuid[from] = m->sb.osd_fsid;
+
// fresh osd?
if (m->sb.newest_map == 0 && osdmap.exists(from)) {
const osd_info_t& i = osdmap.get_info(from);
@@ -2022,51 +2027,49 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
}
}
else if (m->cmd[1] == "create") {
- int i;
- if (m->cmd.size() > 2) {
- i = atoi(m->cmd[2].c_str());
- if (i < 0) {
- ss << i << " is not a valid osd id";
- err = -ERANGE;
- goto out;
- }
- if (osdmap.exists(i)) {
- ss << i << " already exists";
- err = -EEXIST;
+ int i = -1;
+
+ // optional uuid provided?
+ uuid_d uuid;
+ if (m->cmd.size() > 2 && uuid.parse(m->cmd[2].c_str())) {
+ dout(10) << " osd create got uuid " << uuid << dendl;
+ i = osdmap.identify_osd(uuid);
+ if (i >= 0) {
+ // osd already exists
+ err = 0;
+ ss << i;
+ getline(ss, rs);
goto out;
}
- if (i >= osdmap.get_max_osd()) {
- if (i >= pending_inc.new_max_osd)
- pending_inc.new_max_osd = i + 1;
- }
- if (pending_inc.new_up_client.count(i) ||
- (pending_inc.new_state.count(i) &&
- (pending_inc.new_state[i] & CEPH_OSD_EXISTS))) {
- ss << i << " already exists";
- getline(ss, rs);
- paxos->wait_for_commit(new Monitor::C_Command(mon, m, -EEXIST, rs, paxos->get_version()));
+ i = pending_inc.identify_osd(uuid);
+ if (i >= 0) {
+ // osd is about to exist
+ paxos->wait_for_commit(new C_RetryMessage(this, m));
return true;
}
- } else {
- // allocate a new id
- for (i=0; i < osdmap.get_max_osd(); i++) {
- if (!osdmap.exists(i) &&
- pending_inc.new_up_client.count(i) == 0 &&
- (pending_inc.new_state.count(i) == 0 ||
- (pending_inc.new_state[i] & CEPH_OSD_EXISTS) == 0))
- goto done;
- }
- // hrm. raise max_osd
- if (pending_inc.new_max_osd < 0)
- pending_inc.new_max_osd = osdmap.get_max_osd() + 1;
- else
- pending_inc.new_max_osd++;
- i = pending_inc.new_max_osd - 1;
}
+ // allocate a new id
+ for (i=0; i < osdmap.get_max_osd(); i++) {
+ if (!osdmap.exists(i) &&
+ pending_inc.new_up_client.count(i) == 0 &&
+ (pending_inc.new_state.count(i) == 0 ||
+ (pending_inc.new_state[i] & CEPH_OSD_EXISTS) == 0))
+ goto done;
+ }
+
+ // raise max_osd
+ if (pending_inc.new_max_osd < 0)
+ pending_inc.new_max_osd = osdmap.get_max_osd() + 1;
+ else
+ pending_inc.new_max_osd++;
+ i = pending_inc.new_max_osd - 1;
+
done:
dout(10) << " creating osd." << i << dendl;
pending_inc.new_state[i] |= CEPH_OSD_EXISTS | CEPH_OSD_NEW;
+ if (!uuid.is_zero())
+ pending_inc.new_uuid[i] = uuid;
ss << i;
getline(ss, rs);
paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));