From: Samuel Just Date: Wed, 7 May 2014 18:02:16 +0000 (-0700) Subject: osd_types: factor out is_new_interval from check_new_interval X-Git-Tag: v0.80.11~73^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a44b7b4bd870cc72e50a49900cd81fde6d40845b;p=ceph.git osd_types: factor out is_new_interval from check_new_interval Signed-off-by: Samuel Just (cherry picked from commit 2ee355113ed4374c664909a8cd7dc5dfdc4c9ed7) --- diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index d08e9b7d9db22..087236124f3f5 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2196,6 +2196,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, @@ -2218,15 +2242,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 a296df046939e..6e60cc8714e6a 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1752,13 +1752,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