From: Bobi Jam Date: Tue, 1 Jul 2014 08:14:47 +0000 (+0800) Subject: LU-5263 llite: update ras stride offset X-Git-Tag: 2.6.51~54 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9e280281b8daf8ad69d04a5371121224ace28fbc LU-5263 llite: update ras stride offset When a read ahead does not reach the end of the region reserved from ras, we'd set ras::ras_next_readahead back to where we left off; For stride read ahead, it needs to make sure that the offset is no less than ras_stride_offset, so that the stride read ahead can work correctly. Signed-off-by: Bobi Jam Change-Id: I4996f0d8174fa72ea4ef5994daddc0ab2f922f38 Reviewed-on: http://review.whamcloud.com/11181 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: wangdi Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 8ea255a..4aab3d1 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -474,10 +474,11 @@ static int ll_read_ahead_pages(const struct lu_env *env, /* FIXME: This assertion only is valid when it is for * forward read-ahead, it will be fixed when backward * read-ahead is implemented */ - LASSERTF(page_idx > ria->ria_stoff, "Invalid page_idx %lu" - "rs %lu re %lu ro %lu rl %lu rp %lu\n", page_idx, - ria->ria_start, ria->ria_end, ria->ria_stoff, - ria->ria_length, ria->ria_pages); + LASSERTF(page_idx >= ria->ria_stoff, + "Invalid page_idx %lu rs %lu re %lu ro %lu " + "rl %lu rp %lu\n", page_idx, + ria->ria_start, ria->ria_end, ria->ria_stoff, + ria->ria_length, ria->ria_pages); offset = page_idx - ria->ria_stoff; offset = offset % (ria->ria_length); if (offset > ria->ria_pages) { @@ -538,11 +539,23 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, ras->ras_window_len = bead->lrr_start + bead->lrr_count - ras->ras_window_start; } - /* Reserve a part of the read-ahead window that we'll be issuing */ - if (ras->ras_window_len) { - start = ras->ras_next_readahead; - end = ras->ras_window_start + ras->ras_window_len - 1; - } + /* Reserve a part of the read-ahead window that we'll be issuing */ + if (ras->ras_window_len > 0) { + /* + * Note: other thread might rollback the ras_next_readahead, + * if it can not get the full size of prepared pages, see the + * end of this function. For stride read ahead, it needs to + * make sure the offset is no less than ras_stride_offset, + * so that stride read ahead can work correctly. + */ + if (stride_io_mode(ras)) + start = max(ras->ras_next_readahead, + ras->ras_stride_offset); + else + start = ras->ras_next_readahead; + end = ras->ras_window_start + ras->ras_window_len - 1; + } + if (end != 0) { unsigned long rpc_boundary; /*