From 5c664aeb6d11d3201d9646c4b639720ee5db7bdc Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 4 Sep 2009 14:29:34 -0700 Subject: [PATCH] uclient: Fix in the readahead logic --- src/client/Client.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 9c8b73af141fb..dd16050d31783 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; -- 2.39.5