From 43426ddc367bfcad4ea67b7a96e838d5fc7af01f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 3 Sep 2009 16:35:07 -0700 Subject: [PATCH] uclient: tweak readahead logic 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 8e4d08496926f..30184be1af2a4 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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; -- 2.39.5