]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
uclient: use objectcacher->is_cached to make readahead smarter
authorSage Weil <sage@newdream.net>
Fri, 4 Sep 2009 22:11:08 +0000 (15:11 -0700)
committerSage Weil <sage@newdream.net>
Fri, 4 Sep 2009 22:11:08 +0000 (15:11 -0700)
Only initiate readahead if we have less than 1/2 of what we
want to readahead.  Otherwise we still do small reads, just way
ahead of the current read position.

src/client/Client.cc

index dd16050d31783c5f68bdc0b5d060d410764506d1..7889f8fba4880ad010a476dfaa96ea74966da413 100644 (file)
@@ -4112,13 +4112,19 @@ int Client::_read_async(Fh *f, __u64 off, __u64 len, bufferlist *bl)
     if (off+l > in->size)
       l = in->size - off;
     
-    dout(10) << "readahead " << f->nr_consec_read << " reads " 
+    loff_t min = MIN((loff_t)len, l/2);
+
+    dout(20) << "readahead " << f->nr_consec_read << " reads " 
             << f->consec_read_bytes << " bytes ... readahead " << off << "~" << l
+            << " min " << min
             << " (caller wants " << off << "~" << len << ")" << dendl;
     if (l > (loff_t)len) {
-      objectcacher->file_read(in->ino, &in->layout, in->snapid,
-                             off, l, NULL, 0, 0);
-      dout(10) << "readahead initiated" << dendl;
+      if (objectcacher->file_is_cached(in->ino, &in->layout, in->snapid, off, min))
+       dout(20) << "readahead already have min" << dendl;
+      else {
+       objectcacher->file_read(in->ino, &in->layout, in->snapid, off, l, NULL, 0, 0);
+       dout(20) << "readahead initiated" << dendl;
+      }
     }
   }