]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
uclient: tweak readahead logic
authorSage Weil <sage@newdream.net>
Thu, 3 Sep 2009 23:35:07 +0000 (16:35 -0700)
committerSage Weil <sage@newdream.net>
Thu, 3 Sep 2009 23:35:18 +0000 (16:35 -0700)
Trim readahead extent to align to a stripe unit boundary,
always.  This let's us, say, set the max to be 1 stripe unit,
and then we never read beyond the current su.

Only initiate readahead if it's > len.  Otherwise we just
make things slower by breaking the read into two ops!

src/client/Client.cc

index 8e4d08496926f3fb39de0491bfdc27d3dbdefd99..30184be1af2a459e53fe62e4f43f0a11f3d5ca28 100644 (file)
@@ -4093,9 +4093,14 @@ int Client::_read_async(Fh *f, __u64 off, __u64 len, bufferlist *bl)
     loff_t p = ceph_file_layout_period(in->layout);
     if (g_conf.client_readahead_max_periods)
       l = MIN(l, g_conf.client_readahead_max_periods * p);
+
     if (l >= 2*p)
-      // align with period
+      // align large readahead with period
       l -= (off+l) % p;
+    else 
+      // align all readahead with stripe unit
+      l -= (off+l) % ceph_file_layout_su(in->layout);
+
     // don't read past end of file
     if (off+l > in->size)
       l = in->size - off;
@@ -4103,7 +4108,7 @@ int Client::_read_async(Fh *f, __u64 off, __u64 len, bufferlist *bl)
     dout(10) << "readahead " << f->nr_consec_read << " reads " 
             << f->consec_read_bytes << " bytes ... readahead " << off << "~" << l
             << " (caller wants " << off << "~" << len << ")" << dendl;
-    if (l > 0) {
+    if (l > len) {
       objectcacher->file_read(in->ino, &in->layout, in->snapid,
                              off, l, NULL, 0, 0);
       dout(10) << "readahead initiated" << dendl;