From 3b148cddc965737d4adb61756cde416a21a00296 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 11 Apr 2017 17:46:01 -0400 Subject: [PATCH] osd/PG: store last_interval_started in pg_info_t too We have a last_epoch_started value in pg_info_t; store the corresponding last_interval_started value alongside it. Signed-off-by: Sage Weil --- src/osd/PG.cc | 16 +++++++++++++++- src/osd/osd_types.cc | 13 ++++++++++--- src/osd/osd_types.h | 13 ++++++++++--- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 70c9e64605a..afaac9bc4b7 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -336,6 +336,10 @@ void PG::proc_master_log( info.last_epoch_started = oinfo.last_epoch_started; dirty_info = true; } + if (oinfo.last_interval_started > info.last_interval_started) { + info.last_interval_started = oinfo.last_interval_started; + dirty_info = true; + } if (info.history.merge(oinfo.history)) dirty_info = true; assert(cct->_conf->osd_find_best_info_ignore_history_les || @@ -1512,13 +1516,16 @@ void PG::activate(ObjectStore::Transaction& t, assert(cct->_conf->osd_find_best_info_ignore_history_les || info.last_epoch_started <= activation_epoch); info.last_epoch_started = activation_epoch; + info.last_interval_started = info.history.same_interval_since; } } else if (is_acting(pg_whoami)) { /* update last_epoch_started on acting replica to whatever the primary sent * unless it's smaller (could happen if we are going peered rather than * active, see doc/dev/osd_internals/last_epoch_started.rst) */ - if (info.last_epoch_started < activation_epoch) + if (info.last_epoch_started < activation_epoch) { info.last_epoch_started = activation_epoch; + info.last_interval_started = info.history.same_interval_since; + } } auto &missing = pg_log.get_missing(); @@ -1648,6 +1655,7 @@ void PG::activate(ObjectStore::Transaction& t, pi.last_complete = info.last_update; pi.set_last_backfill(hobject_t()); pi.last_epoch_started = info.last_epoch_started; + pi.last_interval_started = info.last_interval_started; pi.history = info.history; pi.hit_set = info.hit_set; pi.stats.stats.clear(); @@ -2162,6 +2170,7 @@ void PG::split_into(pg_t child_pgid, PG *child, unsigned split_bits) info.stats.stats_invalid = true; child->info.stats.stats_invalid = true; child->info.last_epoch_started = info.last_epoch_started; + child->info.last_interval_started = info.last_interval_started; child->snap_trimq = snap_trimq; @@ -3059,6 +3068,9 @@ void PG::append_log( if (info.last_epoch_started != info.history.last_epoch_started) { info.history.last_epoch_started = info.last_epoch_started; } + if (info.last_interval_started != info.history.last_interval_started) { + info.history.last_interval_started = info.last_interval_started; + } dout(10) << "append_log " << pg_log.get_log() << " " << logv << dendl; PGLogEntryHandler handler{this, &t}; @@ -4793,6 +4805,7 @@ void PG::share_pg_info() pg_shard_t peer = *i; if (peer_info.count(peer)) { peer_info[peer].last_epoch_started = info.last_epoch_started; + peer_info[peer].last_interval_started = info.last_interval_started; peer_info[peer].history.merge(info.history); } MOSDPGInfo *m = new MOSDPGInfo(get_osdmap()->get_epoch()); @@ -7114,6 +7127,7 @@ boost::statechart::result PG::RecoveryState::Active::react(const AllReplicasActi // info.last_epoch_started is set during activate() pg->info.history.last_epoch_started = pg->info.last_epoch_started; + pg->info.history.last_interval_started = pg->info.last_interval_started; pg->dirty_info = true; pg->share_pg_info(); diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 061938e0ff3..f0d9deb73d0 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2648,7 +2648,7 @@ void pg_history_t::generate_test_instances(list& o) void pg_info_t::encode(bufferlist &bl) const { - ENCODE_START(31, 26, bl); + ENCODE_START(32, 26, bl); ::encode(pgid.pgid, bl); ::encode(last_update, bl); ::encode(last_complete, bl); @@ -2667,12 +2667,13 @@ void pg_info_t::encode(bufferlist &bl) const ::encode(pgid.shard, bl); ::encode(last_backfill, bl); ::encode(last_backfill_bitwise, bl); + ::encode(last_interval_started, bl); ENCODE_FINISH(bl); } void pg_info_t::decode(bufferlist::iterator &bl) { - DECODE_START(31, bl); + DECODE_START(32, bl); ::decode(pgid.pgid, bl); ::decode(last_update, bl); ::decode(last_complete, bl); @@ -2690,6 +2691,11 @@ void pg_info_t::decode(bufferlist::iterator &bl) ::decode(pgid.shard, bl); ::decode(last_backfill, bl); ::decode(last_backfill_bitwise, bl); + if (struct_v >= 32) { + ::decode(last_interval_started, bl); + } else { + last_interval_started = last_epoch_started; + } DECODE_FINISH(bl); } @@ -3156,7 +3162,8 @@ public: return unique_ptr(new pi_compact_rep(*this)); } ostream &print(ostream &out) const override { - return out << "([" << first << "," << last << "] " << intervals << ")"; + return out << "([" << first << "," << last + << "] intervals=" << intervals << ")"; } void encode(bufferlist &bl) const override { ENCODE_START(1, 1, bl); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 31dd7167894..965c099f100 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2226,6 +2226,7 @@ struct pg_info_t { eversion_t last_update; ///< last object version applied to store. eversion_t last_complete; ///< last version pg was complete through. epoch_t last_epoch_started; ///< last epoch at which this pg started on this osd + epoch_t last_interval_started; ///< first epoch of last_epoch_started interval version_t last_user_version; ///< last user object version applied to store @@ -2247,6 +2248,7 @@ struct pg_info_t { l.last_update == r.last_update && l.last_complete == r.last_complete && l.last_epoch_started == r.last_epoch_started && + l.last_interval_started == r.last_interval_started && l.last_user_version == r.last_user_version && l.log_tail == r.log_tail && l.last_backfill == r.last_backfill && @@ -2258,14 +2260,18 @@ struct pg_info_t { } pg_info_t() - : last_epoch_started(0), last_user_version(0), + : last_epoch_started(0), + last_interval_started(0), + last_user_version(0), last_backfill(hobject_t::get_max()), last_backfill_bitwise(false) { } // cppcheck-suppress noExplicitConstructor pg_info_t(spg_t p) : pgid(p), - last_epoch_started(0), last_user_version(0), + last_epoch_started(0), + last_interval_started(0), + last_user_version(0), last_backfill(hobject_t::get_max()), last_backfill_bitwise(false) { } @@ -2309,7 +2315,8 @@ inline ostream& operator<<(ostream& out, const pg_info_t& pgi) out << " lb " << pgi.last_backfill << (pgi.last_backfill_bitwise ? " (bitwise)" : " (NIBBLEWISE)"); //out << " c " << pgi.epoch_created; - out << " local-les=" << pgi.last_epoch_started; + out << " local-lis/les=" << pgi.last_interval_started + << "/" << pgi.last_epoch_started; out << " n=" << pgi.stats.stats.sum.num_objects; out << " " << pgi.history << ")"; -- 2.47.3