From fca65ff52a5f7d49bcac83b3b2232963a879e446 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 25 Jul 2012 10:58:07 -0700 Subject: [PATCH] osd: move calculation of past_interval range into helper PG::generate_past_intervals() first calculates the range over which it needs to generate past intervals. Do this in a helper function. Signed-off-by: Sage Weil Reviewed-by: Yehuda Sadeh Reviewed-by: Josh Durgin --- src/osd/PG.cc | 35 ++++++++++++++++++++++++----------- src/osd/PG.h | 2 ++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 18a882ddaf867..e3e214436d992 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -710,30 +710,43 @@ bool PG::needs_recovery() const return ret; } -void PG::generate_past_intervals() +bool PG::_calc_past_interval_range(epoch_t *start, epoch_t *end) { - epoch_t end_epoch = info.history.same_interval_since; + *end = info.history.same_interval_since; + // Do we already have the intervals we want? map::const_iterator pif = past_intervals.begin(); if (pif != past_intervals.end()) { if (pif->first <= info.history.last_epoch_clean) { dout(10) << __func__ << ": already have past intervals back to " << info.history.last_epoch_clean << dendl; - return; + return false; } - end_epoch = past_intervals.begin()->first; + *end = past_intervals.begin()->first; } - epoch_t cur_epoch = MAX(MAX(info.history.epoch_created, - info.history.last_epoch_clean), - osd->superblock.oldest_map); - OSDMapRef last_map, cur_map; - if (cur_epoch >= end_epoch) { - dout(10) << __func__ << " start epoch " << cur_epoch - << " >= end epoch " << end_epoch + *start = MAX(MAX(info.history.epoch_created, + info.history.last_epoch_clean), + osd->superblock.oldest_map); + if (*start >= *end) { + dout(10) << __func__ << " start epoch " << *start + << " >= end epoch " << *end << ", nothing to do" << dendl; + return false; + } + + return true; +} + + +void PG::generate_past_intervals() +{ + epoch_t cur_epoch, end_epoch; + if (!_calc_past_interval_range(&cur_epoch, &end_epoch)) { return; } + + OSDMapRef last_map, cur_map; vector acting, up, old_acting, old_up; cur_map = osd->get_map(cur_epoch); diff --git a/src/osd/PG.h b/src/osd/PG.h index b915121183df1..e785ebf046e01 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -640,6 +640,8 @@ public: bool needs_recovery() const; void mark_clean(); ///< mark an active pg clean + + bool _calc_past_interval_range(epoch_t *start, epoch_t *end); void generate_past_intervals(); void trim_past_intervals(); void build_prior(std::auto_ptr &prior_set); -- 2.39.5