Move the call to thrashing_recovery_readahead() before state_based_readahead().

That catches the rare case where thrashing happened on the time we are to read
the page at ra->lookahead_index. Obviously this case should be handled by
thrashing_recovery_readahead() instead of state_based_readahead().

Signed-off-by: Fengguang Wu <[EMAIL PROTECTED]>
---
 mm/readahead.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

--- linux-2.6.21-rc3-mm2.orig/mm/readahead.c
+++ linux-2.6.21-rc3-mm2/mm/readahead.c
@@ -1638,6 +1638,13 @@ page_cache_readahead_adaptive(struct add
                return initial_readahead(mapping, filp, ra, req_size);
 
        /*
+        * Recover from possible thrashing.
+        */
+       if (!page && offset - ra->prev_page <= 1 && ra_has_index(ra, offset))
+               return thrashing_recovery_readahead(mapping, filp, ra,
+                                                               offset, ra_max);
+
+       /*
         * State based sequential read-ahead.
         */
        if (offset == ra->prev_page + 1 &&
@@ -1647,13 +1654,6 @@ page_cache_readahead_adaptive(struct add
                                                offset, req_size, ra_max);
 
        /*
-        * Recover from possible thrashing.
-        */
-       if (!page && offset - ra->prev_page <= 1 && ra_has_index(ra, offset))
-               return thrashing_recovery_readahead(mapping, filp, ra,
-                                                               offset, ra_max);
-
-       /*
         * Backward read-ahead.
         */
        if (!page && try_backward_prefetching(ra, offset, req_size, ra_max))

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to