From 03de3b16b1f57d635aa460ba4ef6b32ccc914e19 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 27 Jul 2015 12:17:45 -0400 Subject: [PATCH] osd/PG: do some new interval work on init() too Some work we need to do on any new interval, *including* when the PG is first created and there is no "interval change". Factor out the (mostly new) bits of start_peering_interval() that also need to happen on the initial interval after the PG is first instantiated into on_new_interval(). Signed-off-by: Sage Weil --- src/osd/PG.cc | 61 ++++++++++++++++++++++++++++----------------------- src/osd/PG.h | 1 + 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 35f19d3bf4a78..62571083b9b85 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2612,7 +2612,7 @@ void PG::init( pg_log.mark_log_for_rewrite(); } - reg_next_scrub(); + on_new_interval(); dirty_info = true; dirty_big_info = true; @@ -4673,8 +4673,6 @@ void PG::start_peering_interval( else set_role(-1); - reg_next_scrub(); - // did acting, up, primary|acker change? if (!lastmap) { dout(10) << " no lastmap" << dendl; @@ -4720,30 +4718,7 @@ void PG::start_peering_interval( info.history.same_primary_since = osdmap->get_epoch(); } - // initialize features - acting_features = CEPH_FEATURES_SUPPORTED_DEFAULT; - upacting_features = CEPH_FEATURES_SUPPORTED_DEFAULT; - for (vector::iterator p = acting.begin(); p != acting.end(); ++p) { - if (*p == CRUSH_ITEM_NONE) - continue; - uint64_t f = osdmap->get_xinfo(*p).features; - acting_features &= f; - upacting_features &= f; - } - for (vector::iterator p = up.begin(); p != up.end(); ++p) { - if (*p == CRUSH_ITEM_NONE) - continue; - upacting_features &= osdmap->get_xinfo(*p).features; - } - - if (g_conf->osd_debug_randomize_hobject_sort_order) { - // randomly use a nibblewise sort (when we otherwise might have - // done bitwise) based on some *deterministic* function such that - // all peers/osds will agree. - randomly_sort_nibblewise = (info.history.same_interval_since + info.pgid.ps()) & 1; - } else { - randomly_sort_nibblewise = false; - } + on_new_interval(); dout(10) << " up " << oldup << " -> " << up << ", acting " << oldacting << " -> " << acting @@ -4831,6 +4806,38 @@ void PG::start_peering_interval( } } +void PG::on_new_interval() +{ + const OSDMapRef osdmap = get_osdmap(); + + reg_next_scrub(); + + // initialize features + acting_features = CEPH_FEATURES_SUPPORTED_DEFAULT; + upacting_features = CEPH_FEATURES_SUPPORTED_DEFAULT; + for (vector::iterator p = acting.begin(); p != acting.end(); ++p) { + if (*p == CRUSH_ITEM_NONE) + continue; + uint64_t f = osdmap->get_xinfo(*p).features; + acting_features &= f; + upacting_features &= f; + } + for (vector::iterator p = up.begin(); p != up.end(); ++p) { + if (*p == CRUSH_ITEM_NONE) + continue; + upacting_features &= osdmap->get_xinfo(*p).features; + } + + if (g_conf->osd_debug_randomize_hobject_sort_order) { + // randomly use a nibblewise sort (when we otherwise might have + // done bitwise) based on some *deterministic* function such that + // all peers/osds will agree. + randomly_sort_nibblewise = (info.history.same_interval_since + info.pgid.ps()) & 1; + } else { + randomly_sort_nibblewise = false; + } +} + void PG::proc_primary_info(ObjectStore::Transaction &t, const pg_info_t &oinfo) { assert(!is_primary()); diff --git a/src/osd/PG.h b/src/osd/PG.h index 2a1cbd97c157d..733df0e3c593d 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -2204,6 +2204,7 @@ public: const vector& newup, int up_primary, const vector& newacting, int acting_primary, ObjectStore::Transaction *t); + void on_new_interval(); void start_flush(ObjectStore::Transaction *t, list *on_applied, list *on_safe); -- 2.39.5