From 2ee355113ed4374c664909a8cd7dc5dfdc4c9ed7 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 7 May 2014 11:02:16 -0700 Subject: [PATCH] osd_types: factor out is_new_interval from check_new_interval Signed-off-by: Samuel Just --- src/osd/osd_types.cc | 46 +++++++++++++++++++++++++++++++++++--------- src/osd/osd_types.h | 20 ++++++++++++++++++- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 15dd661d1761a..6bdbd61193268 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2186,6 +2186,30 @@ void pg_interval_t::generate_test_instances(list& o) o.back()->maybe_went_rw = true; } +bool pg_interval_t::is_new_interval( + int old_acting_primary, + int new_acting_primary, + const vector &old_acting, + const vector &new_acting, + int old_up_primary, + int new_up_primary, + const vector &old_up, + const vector &new_up, + OSDMapRef osdmap, + OSDMapRef lastmap, + int64_t pool_id, + pg_t pgid) { + return old_acting_primary != new_acting_primary || + new_acting != old_acting || + old_up_primary != new_up_primary || + new_up != old_up || + (!(lastmap->get_pools().count(pool_id))) || + (lastmap->get_pools().find(pool_id)->second.min_size != + osdmap->get_pools().find(pool_id)->second.min_size) || + pgid.is_split(lastmap->get_pg_num(pgid.pool()), + osdmap->get_pg_num(pgid.pool()), 0); +} + bool pg_interval_t::check_new_interval( int old_acting_primary, int new_acting_primary, @@ -2208,15 +2232,19 @@ bool pg_interval_t::check_new_interval( // NOTE: a change in the up set primary triggers an interval // change, even though the interval members in the pg_interval_t // do not change. - if (old_acting_primary != new_acting_primary || - new_acting != old_acting || - old_up_primary != new_up_primary || - new_up != old_up || - (!(lastmap->get_pools().count(pool_id))) || - (lastmap->get_pools().find(pool_id)->second.min_size != - osdmap->get_pools().find(pool_id)->second.min_size) || - pgid.is_split(lastmap->get_pg_num(pgid.pool()), - osdmap->get_pg_num(pgid.pool()), 0)) { + if (is_new_interval( + old_acting_primary, + new_acting_primary, + old_acting, + new_acting, + old_up_primary, + new_up_primary, + old_up, + new_up, + osdmap, + lastmap, + pool_id, + pgid)) { pg_interval_t& i = (*past_intervals)[same_interval_since]; i.first = same_interval_since; i.last = osdmap->get_epoch() - 1; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 0c68a531aafea..67ece00c38df6 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1703,13 +1703,31 @@ struct pg_interval_t { void dump(Formatter *f) const; static void generate_test_instances(list& o); + /** + * Determines whether there is an interval change + */ + static bool is_new_interval( + int old_acting_primary, ///< [in] primary as of lastmap + int new_acting_primary, ///< [in] primary as of lastmap + const vector &old_acting, ///< [in] acting as of lastmap + const vector &new_acting, ///< [in] acting as of osdmap + int old_up_primary, ///< [in] up primary of lastmap + int new_up_primary, ///< [in] up primary of osdmap + const vector &old_up, ///< [in] up as of lastmap + const vector &new_up, ///< [in] up as of osdmap + ceph::shared_ptr osdmap, ///< [in] current map + ceph::shared_ptr lastmap, ///< [in] last map + int64_t poolid, ///< [in] pool for pg + pg_t pgid ///< [in] pgid for pg + ); + /** * Integrates a new map into *past_intervals, returns true * if an interval was closed out. */ static bool check_new_interval( int old_acting_primary, ///< [in] primary as of lastmap - int new_acting_primary, ///< [in] primary as of lastmap + int new_acting_primary, ///< [in] primary as of osdmap const vector &old_acting, ///< [in] acting as of lastmap const vector &new_acting, ///< [in] acting as of osdmap int old_up_primary, ///< [in] up primary of lastmap -- 2.39.5