From: Greg Farnum Date: Fri, 4 Sep 2009 21:29:34 +0000 (-0700) Subject: uclient: Fix in the readahead logic X-Git-Tag: v0.14~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5c664aeb6d11d3201d9646c4b639720ee5db7bdc;p=ceph.git uclient: Fix in the readahead logic --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 9c8b73af141..dd16050d317 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -4081,6 +4081,10 @@ int Client::_read_async(Fh *f, __u64 off, __u64 len, bufferlist *bl) if (in->cap_refs[CEPH_CAP_FILE_CACHE] == 0) in->get_cap_ref(CEPH_CAP_FILE_CACHE); + dout(10) << "readahead=" << readahead << " nr_consec=" << f->nr_consec_read + << " max_byes=" << g_conf.client_readahead_max_bytes + << " max_periods=" << g_conf.client_readahead_max_periods << dendl; + // readahead? if (readahead && f->nr_consec_read && @@ -4098,10 +4102,12 @@ int Client::_read_async(Fh *f, __u64 off, __u64 len, bufferlist *bl) if (l >= 2*p) // 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); - + else { + // align readahead with stripe unit if we cross su boundary + int su = ceph_file_layout_su(in->layout); + if ((off+l)/su != off/su) l -= (off+l) % su; + } + // don't read past end of file if (off+l > in->size) l = in->size - off;