summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Just <sam.just@inktank.com>2013-04-15 16:33:48 -0700
committerSamuel Just <sam.just@inktank.com>2013-06-06 09:28:55 -0700
commit4ee638cc3b1d74e678a3f78b3a57baf57a5d407c (patch)
tree6d1f727e91bc4d7a56d694d92111f3e3524a1c35
parent8c6a912ae46c4d3aeb7c1000d221f67e158ec5c8 (diff)
downloadceph-4ee638cc3b1d74e678a3f78b3a57baf57a5d407c.tar.gz
PG: don't write out pg map epoch every handle_activate_map
We don't actually need to write out the pg map epoch on every activate_map as long as: a) the osd does not trim past the oldest pg map persisted b) the pg does update the persisted map epoch from time to time. To that end, we now keep a reference to the last map persisted. The OSD already does not trim past the oldest live OSDMapRef. Second, handle_activate_map will trim if the difference between the current map and the last_persisted_map is large enough. Fixes: #4731 Signed-off-by: Samuel Just <sam.just@inktank.com> Reviewed-by: Greg Farnum <greg@inktank.com>
-rw-r--r--src/common/config_opts.h4
-rw-r--r--src/osd/PG.cc15
-rw-r--r--src/osd/PG.h1
3 files changed, 18 insertions, 2 deletions
diff --git a/src/common/config_opts.h b/src/common/config_opts.h
index d2a9c49d5ac..067a1c63777 100644
--- a/src/common/config_opts.h
+++ b/src/common/config_opts.h
@@ -362,6 +362,10 @@ OPTION(osd_use_stale_snap, OPT_BOOL, false)
OPTION(osd_rollback_to_cluster_snap, OPT_STR, "")
OPTION(osd_default_notify_timeout, OPT_U32, 30) // default notify timeout in seconds
OPTION(osd_kill_backfill_at, OPT_INT, 0)
+
+// Bounds how infrequently a new map epoch will be persisted for a pg
+OPTION(osd_pg_epoch_persisted_max_stale, OPT_U32, 200)
+
OPTION(osd_min_pg_log_entries, OPT_U32, 1000) // number of entries to keep in the pg log when trimming it
OPTION(osd_max_pg_log_entries, OPT_U32, 10000) // max entries, say when degraded, before we trim
OPTION(osd_op_complaint_time, OPT_FLOAT, 30) // how many seconds old makes an op complaint-worthy
diff --git a/src/osd/PG.cc b/src/osd/PG.cc
index e4297e20e3d..47c85c62a3b 100644
--- a/src/osd/PG.cc
+++ b/src/osd/PG.cc
@@ -62,7 +62,7 @@ void PGPool::update(OSDMapRef map)
PG::PG(OSDService *o, OSDMapRef curmap,
const PGPool &_pool, pg_t p, const hobject_t& loid,
const hobject_t& ioid) :
- osd(o), osdmap_ref(curmap), pool(_pool),
+ osd(o), osdmap_ref(curmap), last_persisted_osdmap_ref(curmap), pool(_pool),
_lock("PG::_lock"),
ref(0), deleting(false), dirty_info(false), dirty_log(false),
info(p), coll(p), log_oid(loid), biginfo_oid(ioid),
@@ -2330,6 +2330,7 @@ void PG::init(int role, vector<int>& newup, vector<int>& newacting, pg_history_t
void PG::write_info(ObjectStore::Transaction& t)
{
+ last_persisted_osdmap_ref = osdmap_ref;
// pg state
bufferlist infobl;
__u8 struct_v = 5;
@@ -5220,7 +5221,17 @@ void PG::handle_activate_map(RecoveryCtx *rctx)
dout(10) << "handle_activate_map " << dendl;
ActMap evt;
recovery_state.handle_event(evt, rctx);
- dirty_info = true;
+ if (osdmap_ref->get_epoch() - last_persisted_osdmap_ref->get_epoch() >
+ g_conf->osd_pg_epoch_persisted_max_stale) {
+ dout(20) << __func__ << ": Dirtying info: last_persisted is "
+ << last_persisted_osdmap_ref->get_epoch()
+ << " while current is " << osdmap_ref->get_epoch() << dendl;
+ dirty_info = true;
+ } else {
+ dout(20) << __func__ << ": Not dirtying info: last_persisted is "
+ << last_persisted_osdmap_ref->get_epoch()
+ << " while current is " << osdmap_ref->get_epoch() << dendl;
+ }
}
void PG::handle_loaded(RecoveryCtx *rctx)
diff --git a/src/osd/PG.h b/src/osd/PG.h
index 4317832697e..1290626a7ec 100644
--- a/src/osd/PG.h
+++ b/src/osd/PG.h
@@ -354,6 +354,7 @@ public:
protected:
OSDService *osd;
OSDMapRef osdmap_ref;
+ OSDMapRef last_persisted_osdmap_ref;
PGPool pool;
OSDMapRef get_osdmap() const {