From: Kefu Chai Date: Mon, 13 Mar 2017 07:13:03 +0000 (+0800) Subject: osd: send pg-created message if any pg is newly created X-Git-Tag: v12.0.2~256^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a2e39d91c9508a27dc60c168dfb32fb352de44fe;p=ceph.git osd: send pg-created message if any pg is newly created add an option named "osd_created_report_interval" to specify the interval to check and send the "pg_created" mesages to mon because pg could update its state when it is still in the pg_stat_queue, for example, to change its state to PG_STATE_CLEAN, we cannot tell if we have sent a "pg-created" message for it or not without introducing a new member variable in PG. Signed-off-by: Kefu Chai --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index e7358ccd0b87..b9e2828c0adf 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -93,6 +93,7 @@ #include "messages/MOSDECSubOpWriteReply.h" #include "messages/MOSDECSubOpRead.h" #include "messages/MOSDECSubOpReadReply.h" +#include "messages/MOSDPGCreated.h" #include "messages/MOSDPGUpdateLogMissing.h" #include "messages/MOSDPGUpdateLogMissingReply.h" @@ -973,6 +974,11 @@ void OSDService::send_pg_temp() _sent_pg_temp(); } +void OSDService::send_pg_created(pg_t pgid) +{ + dout(20) << __func__ << dendl; + monc->send_mon_message(new MOSDPGCreated(pgid)); +} // -------------------------------------- // dispatch @@ -3723,7 +3729,7 @@ void OSD::build_past_intervals_parallel() * look up a pg. if we have it, great. if not, consider creating it IF the pg mapping * hasn't changed since the given epoch and we are the primary. */ -void OSD::handle_pg_peering_evt( +int OSD::handle_pg_peering_evt( spg_t pgid, const pg_history_t& orig_history, const pg_interval_map_t& pi, @@ -3732,14 +3738,14 @@ void OSD::handle_pg_peering_evt( { if (service.splitting(pgid)) { peering_wait_for_split[pgid].push_back(evt); - return; + return -EEXIST; } PG *pg = _lookup_lock_pg(pgid); if (!pg) { // same primary? if (!osdmap->have_pg_pool(pgid.pool())) - return; + return -EINVAL; int up_primary, acting_primary; vector up, acting; osdmap->pg_to_up_acting_osds( @@ -3753,7 +3759,7 @@ void OSD::handle_pg_peering_evt( dout(10) << __func__ << pgid << " acting changed in " << history.same_interval_since << " (msg from " << epoch << ")" << dendl; - return; + return -EINVAL; } if (service.splitting(pgid)) { @@ -3797,7 +3803,7 @@ void OSD::handle_pg_peering_evt( pg->queue_peering_event(evt); wake_pg_waiters(pg); pg->unlock(); - return; + return 0; } case RES_SELF: { old_pg_state->lock(); @@ -3832,7 +3838,7 @@ void OSD::handle_pg_peering_evt( pg->queue_peering_event(evt); wake_pg_waiters(pg); pg->unlock(); - return; + return 0; } case RES_PARENT: { assert(old_pg_state); @@ -3873,8 +3879,11 @@ void OSD::handle_pg_peering_evt( parent->queue_null(osdmap->get_epoch(), osdmap->get_epoch()); wake_pg_waiters(parent); parent->unlock(); - return; + return 0; } + default: + assert(0); + return 0; } } else { // already had it. did the mapping change? @@ -3882,12 +3891,11 @@ void OSD::handle_pg_peering_evt( dout(10) << *pg << __func__ << " acting changed in " << pg->info.history.same_interval_since << " (msg from " << epoch << ")" << dendl; - pg->unlock(); - return; + } else { + pg->queue_peering_event(evt); } - pg->queue_peering_event(evt); pg->unlock(); - return; + return -EEXIST; } } @@ -5426,6 +5434,7 @@ void OSD::send_pg_stats(const utime_t &now) had_for -= had_map_since; MPGStats *m = new MPGStats(monc->get_fsid(), osdmap->get_epoch(), had_for); + uint64_t tid = ++pg_stat_tid; m->set_tid(tid); m->osd_stat = cur_stat; @@ -7794,19 +7803,20 @@ void OSD::handle_pg_create(OpRequestRef op) continue; } - handle_pg_peering_evt( - pgid, - history, - pi, - osdmap->get_epoch(), - PG::CephPeeringEvtRef( - new PG::CephPeeringEvt( - osdmap->get_epoch(), - osdmap->get_epoch(), - PG::NullEvt())) - ); + if (handle_pg_peering_evt( + pgid, + history, + pi, + osdmap->get_epoch(), + PG::CephPeeringEvtRef( + new PG::CephPeeringEvt( + osdmap->get_epoch(), + osdmap->get_epoch(), + PG::NullEvt())) + ) == -EEXIST) { + service.send_pg_created(pgid.pgid); + } } - last_pg_create_epoch = m->epoch; maybe_update_heartbeat_peers(); diff --git a/src/osd/OSD.h b/src/osd/OSD.h index f1d107283a6a..9e95a01ddce8 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -945,6 +945,8 @@ public: void requeue_pg_temp(); void send_pg_temp(); + void send_pg_created(pg_t pgid); + void queue_for_peering(PG *pg); Mutex snap_sleep_lock; @@ -2029,7 +2031,7 @@ protected: void add_newly_split_pg(PG *pg, PG::RecoveryCtx *rctx); - void handle_pg_peering_evt( + int handle_pg_peering_evt( spg_t pgid, const pg_history_t& orig_history, const pg_interval_map_t& pi, diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 537b5241b5e0..8c5976b0a63c 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2702,6 +2702,10 @@ void PG::publish_stats_to_osd() if ((state & (PG_STATE_ACTIVE|PG_STATE_PEERED)) && !(info.stats.state & (PG_STATE_ACTIVE|PG_STATE_PEERED))) info.stats.last_became_peered = now; + if (!(state & PG_STATE_CREATING) && + (info.stats.state & PG_STATE_CREATING)) { + osd->send_pg_created(get_pgid().pgid); + } info.stats.state = state; }