From 99a67f6c39ddb6cae8cb028e48e7693fb4a722c9 Mon Sep 17 00:00:00 2001 From: sageweil Date: Sun, 10 Jun 2007 19:54:25 +0000 Subject: [PATCH] * small flash crowd candidate check cleanup git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1414 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/pgs/osd/OSD.h | 12 ++++++------ branches/sage/pgs/osd/ReplicatedPG.cc | 6 +++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/branches/sage/pgs/osd/OSD.h b/branches/sage/pgs/osd/OSD.h index d067260c4729d..a63c0ab7a3e0d 100644 --- a/branches/sage/pgs/osd/OSD.h +++ b/branches/sage/pgs/osd/OSD.h @@ -100,17 +100,17 @@ public: r.average_iat = r.average_iat*(1.0-alpha) + iat*alpha; } - bool have(object_t oid) { + bool have(object_t oid) const { return iat_map.count(oid); } - double get_average_iat(object_t oid) { - assert(have(oid)); - return iat_map[oid].average_iat; + double get_average_iat(object_t oid) const { + hash_map::const_iterator p = iat_map.find(oid); + assert(p != iat_map.end()); + return p->second.average_iat; } - bool is_flash_crowd_candidate(object_t oid) { - assert(have(oid)); + bool is_flash_crowd_candidate(object_t oid) const { return get_average_iat(oid) <= g_conf.osd_flash_crowd_iat_threshold; } }; diff --git a/branches/sage/pgs/osd/ReplicatedPG.cc b/branches/sage/pgs/osd/ReplicatedPG.cc index 27482ac595d65..c802c00f1ac83 100644 --- a/branches/sage/pgs/osd/ReplicatedPG.cc +++ b/branches/sage/pgs/osd/ReplicatedPG.cc @@ -124,7 +124,11 @@ bool ReplicatedPG::preprocess_op(MOSDOp *op) } // -- flash crowd? - if (!op->get_source().is_osd()) { + if (!op->get_source().is_osd() && + is_primary()) { + // add sample + osd->iat_averager.add_sample( op->get_oid(), (double)g_clock.now() ); + // candidate? bool is_flash_crowd_candidate = osd->iat_averager.is_flash_crowd_candidate( op->get_oid() ); bool is_balanced = false; -- 2.39.5