From d582bda090b3339d03e25b0e6d0971ad0267f476 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Mon, 2 Mar 2015 11:36:24 +0800 Subject: [PATCH] osdc: Make last missing bh to wake up the reader. Avoid wakeup early and wait again. Signed-off-by: Jianpeng Ma --- src/osdc/ObjectCacher.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index eef961ff560a0..0935fae16d226 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -1142,6 +1142,7 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish, if (!missing.empty() || !rx.empty()) { // read missing + map::iterator last = missing.end(); for (map::iterator bh_it = missing.begin(); bh_it != missing.end(); ++bh_it) { @@ -1162,16 +1163,21 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish, delete bh_it->second; } else { bh_read(bh_it->second, rd->fadvise_flags); - if (success && onfinish) { - ldout(cct, 10) << "readx missed, waiting on " << *bh_it->second - << " off " << bh_it->first << dendl; - bh_it->second->waitfor_read[bh_it->first].push_back( new C_RetryRead(this, rd, oset, onfinish) ); - } + if ((success && onfinish) || last != missing.end()) + last = bh_it; } bytes_not_in_cache += bh_it->second->length(); success = false; } + //add wait in last bh avoid wakeup early. Because read is order + if (last != missing.end()) { + ldout(cct, 10) << "readx missed, waiting on " << *last->second + << " off " << last->first << dendl; + last->second->waitfor_read[last->first].push_back( new C_RetryRead(this, rd, oset, onfinish) ); + + } + // bump rx for (map::iterator bh_it = rx.begin(); bh_it != rx.end(); -- 2.39.5