]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc: Make last missing bh to wake up the reader.
authorJianpeng Ma <jianpeng.ma@intel.com>
Mon, 2 Mar 2015 03:36:24 +0000 (11:36 +0800)
committerLoic Dachary <ldachary@redhat.com>
Sun, 6 Sep 2015 12:07:54 +0000 (14:07 +0200)
Avoid wakeup early and wait again.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
(cherry picked from commit d582bda090b3339d03e25b0e6d0971ad0267f476)

src/osdc/ObjectCacher.cc

index ec4650d8a178752ce702500ee632189e05f561b0..5d54ed8a88f9afe23ab2c9f4c1c4fbc8169f93d6 100644 (file)
@@ -1142,6 +1142,7 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
 
     if (!missing.empty() || !rx.empty()) {
       // read missing
+      map<loff_t, BufferHead*>::iterator last = missing.end();
       for (map<loff_t, BufferHead*>::iterator bh_it = missing.begin();
            bh_it != missing.end();
            ++bh_it) {
@@ -1163,15 +1164,20 @@ 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;
        }
        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<loff_t, BufferHead*>::iterator bh_it = rx.begin();
            bh_it != rx.end();