From 17b270a04fbf023f84b02334927fa1b3ae04b74c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 15 Feb 2018 21:24:17 -0600 Subject: [PATCH] osd/osd_types: make pg merge an interval boundary Both the merge itself *and* the pending merge are interval transitions. Signed-off-by: Sage Weil --- src/osd/osd_types.cc | 14 +++++ src/osd/osd_types.h | 2 + src/osdc/Objecter.cc | 4 ++ src/osdc/Objecter.h | 1 + src/test/osd/types.cc | 134 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+) diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 7a5e7cfa3b8a3..1b88cc6ff772e 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -3417,6 +3417,8 @@ bool PastIntervals::is_new_interval( int new_min_size, unsigned old_pg_num, unsigned new_pg_num, + unsigned old_pg_num_pending, + unsigned new_pg_num_pending, bool old_sort_bitwise, bool new_sort_bitwise, bool old_recovery_deletes, @@ -3429,6 +3431,16 @@ bool PastIntervals::is_new_interval( old_min_size != new_min_size || old_size != new_size || pgid.is_split(old_pg_num, new_pg_num, 0) || + // pre-merge source + pgid.is_merge(old_pg_num_pending, new_pg_num_pending, 0) || + // merge source + pgid.is_merge(old_pg_num, new_pg_num, 0) || + // pre-merge target + (pgid.ps() < new_pg_num_pending && + pgid.is_split(new_pg_num_pending, old_pg_num_pending, 0)) || + // merge target + (pgid.ps() < new_pg_num && + pgid.is_split(new_pg_num, old_pg_num, 0)) || old_sort_bitwise != new_sort_bitwise || old_recovery_deletes != new_recovery_deletes; } @@ -3469,6 +3481,8 @@ bool PastIntervals::is_new_interval( pi->min_size, plast->get_pg_num(), pi->get_pg_num(), + plast->get_pg_num_pending(), + pi->get_pg_num_pending(), lastmap->test_flag(CEPH_OSDMAP_SORTBITWISE), osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE), lastmap->test_flag(CEPH_OSDMAP_RECOVERY_DELETES), diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 91fa9e31653ff..57b022cf6af2b 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2780,6 +2780,8 @@ public: int new_min_size, unsigned old_pg_num, unsigned new_pg_num, + unsigned old_pg_num_pending, + unsigned new_pg_num_pending, bool old_sort_bitwise, bool new_sort_bitwise, bool old_recovery_deletes, diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 9049bde3c65ac..f9178ab8afb06 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -2861,6 +2861,7 @@ int Objecter::_calc_target(op_target_t *t, Connection *con, bool any_change) int size = pi->size; int min_size = pi->min_size; unsigned pg_num = pi->get_pg_num(); + unsigned pg_num_pending = pi->get_pg_num_pending(); int up_primary, acting_primary; vector up, acting; osdmap->pg_to_up_acting_osds(pgid, &up, &up_primary, @@ -2884,6 +2885,8 @@ int Objecter::_calc_target(op_target_t *t, Connection *con, bool any_change) min_size, t->pg_num, pg_num, + t->pg_num_pending, + pg_num_pending, t->sort_bitwise, sort_bitwise, t->recovery_deletes, @@ -2918,6 +2921,7 @@ int Objecter::_calc_target(op_target_t *t, Connection *con, bool any_change) t->min_size = min_size; t->pg_num = pg_num; t->pg_num_mask = pi->get_pg_num_mask(); + t->pg_num_pending = pg_num_pending; osdmap->get_primary_shard( pg_t(ceph_stable_mod(pgid.ps(), t->pg_num, t->pg_num_mask), pgid.pool()), &t->actual_pgid); diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 8d215b91ada36..30b27930f72ca 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1298,6 +1298,7 @@ public: spg_t actual_pgid; ///< last (actual) spg_t we mapped to unsigned pg_num = 0; ///< last pg_num we mapped to unsigned pg_num_mask = 0; ///< last pg_num_mask we mapped to + unsigned pg_num_pending = 0; ///< last pg_num we mapped to vector up; ///< set of up osds for last pg we mapped to vector acting; ///< set of acting osds for last pg we mapped to int up_primary = -1; ///< last up_primary we mapped to diff --git a/src/test/osd/types.cc b/src/test/osd/types.cc index 58bd183fa9592..0c5ad7a3fccda 100644 --- a/src/test/osd/types.cc +++ b/src/test/osd/types.cc @@ -149,6 +149,7 @@ for (unsigned i = 0; i < 4; ++i) { OSDMap::Incremental inc(epoch + 1); inc.new_pools[pool_id].min_size = min_size; inc.new_pools[pool_id].set_pg_num(pg_num); + inc.new_pools[pool_id].set_pg_num_pending(pg_num, 1); inc.new_up_thru[osd_id] = epoch + 1; osdmap->apply_incremental(inc); lastmap->apply_incremental(inc); @@ -312,6 +313,139 @@ for (unsigned i = 0; i < 4; ++i) { &past_intervals)); } + // + // PG is pre-merge source + // + { + std::shared_ptr osdmap(new OSDMap()); + osdmap->set_max_osd(10); + osdmap->set_state(osd_id, CEPH_OSD_EXISTS); + osdmap->set_epoch(epoch); + OSDMap::Incremental inc(epoch + 1); + inc.new_pools[pool_id].min_size = min_size; + inc.new_pools[pool_id].set_pg_num(pg_num); + inc.new_pools[pool_id].set_pg_num_pending(pg_num - 1, epoch + 1); + osdmap->apply_incremental(inc); + cout << "pg_num " << pg_num << std::endl; + PastIntervals past_intervals; + + ASSERT_TRUE(past_intervals.empty()); + ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, + new_primary, + old_acting, + new_acting, + old_up_primary, + new_up_primary, + old_up, + new_up, + same_interval_since, + last_epoch_clean, + osdmap, + lastmap, + pg_t(pg_num - 1, pool_id), + recoverable.get(), + &past_intervals)); + } + + // + // PG is merge source + // + { + std::shared_ptr osdmap(new OSDMap()); + osdmap->set_max_osd(10); + osdmap->set_state(osd_id, CEPH_OSD_EXISTS); + osdmap->set_epoch(epoch); + OSDMap::Incremental inc(epoch + 1); + inc.new_pools[pool_id].min_size = min_size; + inc.new_pools[pool_id].set_pg_num(pg_num - 1); + osdmap->apply_incremental(inc); + + PastIntervals past_intervals; + + ASSERT_TRUE(past_intervals.empty()); + ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, + new_primary, + old_acting, + new_acting, + old_up_primary, + new_up_primary, + old_up, + new_up, + same_interval_since, + last_epoch_clean, + osdmap, + lastmap, + pg_t(pg_num - 1, pool_id), + recoverable.get(), + &past_intervals)); + } + + // + // PG is pre-merge target + // + { + std::shared_ptr osdmap(new OSDMap()); + osdmap->set_max_osd(10); + osdmap->set_state(osd_id, CEPH_OSD_EXISTS); + osdmap->set_epoch(epoch); + OSDMap::Incremental inc(epoch + 1); + inc.new_pools[pool_id].min_size = min_size; + inc.new_pools[pool_id].set_pg_num_pending(pg_num - 1, epoch + 1); + osdmap->apply_incremental(inc); + + PastIntervals past_intervals; + + ASSERT_TRUE(past_intervals.empty()); + ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, + new_primary, + old_acting, + new_acting, + old_up_primary, + new_up_primary, + old_up, + new_up, + same_interval_since, + last_epoch_clean, + osdmap, + lastmap, + pg_t(pg_num / 2 - 1, pool_id), + recoverable.get(), + &past_intervals)); + } + + // + // PG is merge target + // + { + std::shared_ptr osdmap(new OSDMap()); + osdmap->set_max_osd(10); + osdmap->set_state(osd_id, CEPH_OSD_EXISTS); + osdmap->set_epoch(epoch); + OSDMap::Incremental inc(epoch + 1); + inc.new_pools[pool_id].min_size = min_size; + inc.new_pools[pool_id].set_pg_num(pg_num - 1); + osdmap->apply_incremental(inc); + + PastIntervals past_intervals; + + ASSERT_TRUE(past_intervals.empty()); + ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, + new_primary, + old_acting, + new_acting, + old_up_primary, + new_up_primary, + old_up, + new_up, + same_interval_since, + last_epoch_clean, + osdmap, + lastmap, + pg_t(pg_num / 2 - 1, pool_id), + recoverable.get(), + &past_intervals)); + } + // // PG size has changed // -- 2.39.5