From: Jianpeng Ma Date: Mon, 2 Mar 2015 03:36:24 +0000 (+0800) Subject: osdc: Make last missing bh to wake up the reader. X-Git-Tag: v9.0.0~185^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d582bda090b3339d03e25b0e6d0971ad0267f476;p=ceph.git osdc: Make last missing bh to wake up the reader. Avoid wakeup early and wait again. Signed-off-by: Jianpeng Ma --- 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();