Readahead policy for reading backward. Signed-off-by: Wu Fengguang DESC readahead: backward prefetching method - add use case comment EDESC From: Wu Fengguang Backward prefetching is vital to structural analysis and some other scientific applications. Comment this use case. Signed-off-by: Wu Fengguang Signed-off-by: Andrew Morton --- linux-2.6.19-rc5-mm2.orig/mm/readahead.c +++ linux-2.6.19-rc5-mm2/mm/readahead.c @@ -1476,6 +1476,52 @@ initial_readahead(struct address_space * } /* + * Backward prefetching. + * + * No look-ahead and thrashing safety guard: should be unnecessary. + * + * Important for certain scientific arenas(i.e. structural analysis). + */ +static int +try_backward_prefetching(struct file_ra_state *ra, pgoff_t offset, + unsigned long size, unsigned long ra_max) +{ + pgoff_t prev = ra->prev_page; + + /* Reading backward? */ + if (offset >= prev) + return 0; + + /* Close enough? */ + size += readahead_hit_rate; + if (offset + 2 * size <= prev) + return 0; + + if (ra_class_new(ra) == RA_CLASS_BACKWARD && ra_has_index(ra, prev)) { + prev = ra->la_index; + size += 2 * ra_readahead_size(ra); + } else + size *= 2; + + if (size > ra_max) + size = ra_max; + if (size > prev) + size = prev; + + /* The readahead-request covers the read-request? */ + if (offset < prev - size) + return 0; + + offset = prev - size; + + ra_set_class(ra, RA_CLASS_BACKWARD); + ra_set_index(ra, offset, offset); + ra_set_size(ra, size, 0); + + return 1; +} + +/* * ra_min is mainly determined by the size of cache memory. Reasonable? * * Table of concrete numbers for 4KB page size: -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/