| 3648 | } |
| 3649 | |
| 3650 | bool OSDMonitor::prepare_boot(MonOpRequestRef op) |
| 3651 | { |
| 3652 | op->mark_osdmon_event(__func__); |
| 3653 | auto m = op->get_req<MOSDBoot>(); |
| 3654 | dout(7) << __func__ << " from " << m->get_source() |
| 3655 | << " sb " << m->sb |
| 3656 | << " client_addrs" << m->get_connection()->get_peer_addrs() |
| 3657 | << " cluster_addrs " << m->cluster_addrs |
| 3658 | << " hb_back_addrs " << m->hb_back_addrs |
| 3659 | << " hb_front_addrs " << m->hb_front_addrs |
| 3660 | << dendl; |
| 3661 | |
| 3662 | ceph_assert(m->get_orig_source().is_osd()); |
| 3663 | int from = m->get_orig_source().num(); |
| 3664 | |
| 3665 | // does this osd exist? |
| 3666 | if (from >= osdmap.get_max_osd()) { |
| 3667 | dout(1) << "boot from osd." << from << " >= max_osd " |
| 3668 | << osdmap.get_max_osd() << dendl; |
| 3669 | return false; |
| 3670 | } |
| 3671 | |
| 3672 | int oldstate = osdmap.exists(from) ? osdmap.get_state(from) : CEPH_OSD_NEW; |
| 3673 | if (pending_inc.new_state.count(from)) |
| 3674 | oldstate ^= pending_inc.new_state[from]; |
| 3675 | |
| 3676 | // already up? mark down first? |
| 3677 | if (osdmap.is_up(from)) { |
| 3678 | dout(7) << __func__ << " was up, first marking down osd." << from << " " |
| 3679 | << osdmap.get_addrs(from) << dendl; |
| 3680 | // preprocess should have caught these; if not, assert. |
| 3681 | ceph_assert(!osdmap.get_addrs(from).legacy_equals( |
| 3682 | m->get_orig_source_addrs()) || |
| 3683 | !osdmap.get_cluster_addrs(from).legacy_equals(m->cluster_addrs)); |
| 3684 | ceph_assert(osdmap.get_uuid(from) == m->sb.osd_fsid); |
| 3685 | |
| 3686 | if (pending_inc.new_state.count(from) == 0 || |
| 3687 | (pending_inc.new_state[from] & CEPH_OSD_UP) == 0) { |
| 3688 | // mark previous guy down |
| 3689 | pending_inc.new_state[from] = CEPH_OSD_UP; |
| 3690 | } |
| 3691 | wait_for_finished_proposal(op, new C_RetryMessage(this, op)); |
| 3692 | } else if (pending_inc.new_up_client.count(from)) { |
| 3693 | // already prepared, just wait |
| 3694 | dout(7) << __func__ << " already prepared, waiting on " |
| 3695 | << m->get_orig_source_addr() << dendl; |
| 3696 | wait_for_finished_proposal(op, new C_RetryMessage(this, op)); |
| 3697 | } else { |
| 3698 | // mark new guy up. |
| 3699 | pending_inc.new_up_client[from] = m->get_orig_source_addrs(); |
| 3700 | pending_inc.new_up_cluster[from] = m->cluster_addrs; |
| 3701 | pending_inc.new_hb_back_up[from] = m->hb_back_addrs; |
| 3702 | pending_inc.new_hb_front_up[from] = m->hb_front_addrs; |
| 3703 | |
| 3704 | down_pending_out.erase(from); // if any |
| 3705 | |
| 3706 | if (m->sb.weight) |
| 3707 | osd_weight[from] = m->sb.weight; |
nothing calls this directly
no test coverage detected