From: Kefu Chai Date: Mon, 13 Mar 2017 07:50:17 +0000 (+0800) Subject: mon: handle MOSDPGCreated messages X-Git-Tag: v12.0.2~256^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a316eb3078e8599a706b10c1b515545860919eda;p=ceph.git mon: handle MOSDPGCreated messages MOSDPGCreated messages are used to prune the creating_pgs_by_osd_epoch and creating_pgs, by updating created_pools. as once a pool is created we will not send MOSDPGCreate to its acting_primary OSD anymore. Signed-off-by: Kefu Chai --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 19657f85d0a7..24ac15d4bcf8 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3748,6 +3748,7 @@ void Monitor::dispatch_op(MonOpRequestRef op) case MSG_OSD_BOOT: case MSG_OSD_ALIVE: case MSG_OSD_PGTEMP: + case MSG_OSD_PG_CREATED: case MSG_REMOVE_SNAPS: paxos_service[PAXOS_OSDMAP]->dispatch(op); break; diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 020c88ac15fa..fea6682a3ce4 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -42,6 +42,7 @@ #include "messages/MPoolOp.h" #include "messages/MPoolOpReply.h" #include "messages/MOSDPGCreate.h" +#include "messages/MOSDPGCreated.h" #include "messages/MOSDPGTemp.h" #include "messages/MMonCommand.h" #include "messages/MRemoveSnaps.h" @@ -1524,6 +1525,8 @@ bool OSDMonitor::preprocess_query(MonOpRequestRef op) return preprocess_boot(op); case MSG_OSD_ALIVE: return preprocess_alive(op); + case MSG_OSD_PG_CREATED: + return preprocess_pg_created(op); case MSG_OSD_PGTEMP: return preprocess_pgtemp(op); case MSG_OSD_BEACON: @@ -1559,6 +1562,8 @@ bool OSDMonitor::prepare_update(MonOpRequestRef op) return prepare_boot(op); case MSG_OSD_ALIVE: return prepare_alive(op); + case MSG_OSD_PG_CREATED: + return prepare_pg_created(op); case MSG_OSD_PGTEMP: return prepare_pgtemp(op); case MSG_OSD_BEACON: @@ -2616,6 +2621,43 @@ void OSDMonitor::_reply_map(MonOpRequestRef op, epoch_t e) send_latest(op, e); } +// pg_created +bool OSDMonitor::preprocess_pg_created(MonOpRequestRef op) +{ + op->mark_osdmon_event(__func__); + auto m = static_cast(op->get_req()); + dout(10) << __func__ << " " << *m << dendl; + auto session = m->get_session(); + if (!session) { + dout(10) << __func__ << ": no monitor session!" << dendl; + return true; + } + if (!session->is_capable("osd", MON_CAP_X)) { + derr << __func__ << " received from entity " + << "with insufficient privileges " << session->caps << dendl; + return true; + } + // always forward the "created!" to the leader + return false; +} + +bool OSDMonitor::prepare_pg_created(MonOpRequestRef op) +{ + op->mark_osdmon_event(__func__); + auto m = static_cast(op->get_req()); + dout(10) << __func__ << " " << *m << dendl; + auto src = m->get_orig_source(); + auto from = src.num(); + if (!src.is_osd() || + !mon->osdmon()->osdmap.is_up(from) || + m->get_orig_source_inst() != mon->osdmon()->osdmap.get_inst(from)) { + dout(1) << __func__ << " ignoring stats from non-active osd." << dendl; + return false; + } + pending_created_pgs.push_back(m->pgid); + return true; +} + // ------------- // pg_temp changes diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index ad6966021ac9..54886e242028 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -280,6 +280,9 @@ private: bool preprocess_pgtemp(MonOpRequestRef op); bool prepare_pgtemp(MonOpRequestRef op); + bool preprocess_pg_created(MonOpRequestRef op); + bool prepare_pg_created(MonOpRequestRef op); + int _check_remove_pool(int64_t pool, const pg_pool_t *pi, ostream *ss); bool _check_become_tier( int64_t tier_pool_id, const pg_pool_t *tier_pool,