Commit 577a3dd8 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

[PATCH] readahead: trivial, small comments update

On top of "[PATCH 2/2] readahead: improve sequential read detection".
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 671ccb4b
...@@ -192,18 +192,16 @@ static int read_pages(struct address_space *mapping, struct file *filp, ...@@ -192,18 +192,16 @@ static int read_pages(struct address_space *mapping, struct file *filp,
* size: Number of pages in that read * size: Number of pages in that read
* Together, these form the "current window". * Together, these form the "current window".
* Together, start and size represent the `readahead window'. * Together, start and size represent the `readahead window'.
* next_size: The number of pages to read on the next readahead miss.
* Has the magical value -1UL if readahead has been disabled.
* prev_page: The page which the readahead algorithm most-recently inspected. * prev_page: The page which the readahead algorithm most-recently inspected.
* prev_page is mainly an optimisation: if page_cache_readahead * It is mainly used to detect sequential file reading.
* sees that it is again being called for a page which it just * If page_cache_readahead sees that it is again being called for
* looked at, it can return immediately without making any state * a page which it just looked at, it can return immediately without
* changes. * making any state changes.
* ahead_start, * ahead_start,
* ahead_size: Together, these form the "ahead window". * ahead_size: Together, these form the "ahead window".
* ra_pages: The externally controlled max readahead for this fd. * ra_pages: The externally controlled max readahead for this fd.
* *
* When readahead is in the off state (size == -1UL), readahead is disabled. * When readahead is in the off state (size == 0), readahead is disabled.
* In this state, prev_page is used to detect the resumption of sequential I/O. * In this state, prev_page is used to detect the resumption of sequential I/O.
* *
* The readahead code manages two windows - the "current" and the "ahead" * The readahead code manages two windows - the "current" and the "ahead"
...@@ -224,7 +222,7 @@ static int read_pages(struct address_space *mapping, struct file *filp, ...@@ -224,7 +222,7 @@ static int read_pages(struct address_space *mapping, struct file *filp,
* ahead window. * ahead window.
* *
* A `readahead hit' occurs when a read request is made against a page which is * A `readahead hit' occurs when a read request is made against a page which is
* the next sequential page. Ahead windowe calculations are done only when it * the next sequential page. Ahead window calculations are done only when it
* is time to submit a new IO. The code ramps up the size agressively at first, * is time to submit a new IO. The code ramps up the size agressively at first,
* but slow down as it approaches max_readhead. * but slow down as it approaches max_readhead.
* *
...@@ -236,11 +234,8 @@ static int read_pages(struct address_space *mapping, struct file *filp, ...@@ -236,11 +234,8 @@ static int read_pages(struct address_space *mapping, struct file *filp,
* read is about to happen and the window is immediately set to the initial size * read is about to happen and the window is immediately set to the initial size
* based on I/O request size and the max_readahead. * based on I/O request size and the max_readahead.
* *
* A page request at (start + size) is not a miss at all - it's just a part of
* sequential file reading.
*
* This function is to be called for every read request, rather than when * This function is to be called for every read request, rather than when
* it is time to perform readahead. It is called only oce for the entire I/O * it is time to perform readahead. It is called only once for the entire I/O
* regardless of size unless readahead is unable to start enough I/O to satisfy * regardless of size unless readahead is unable to start enough I/O to satisfy
* the request (I/O request > max_readahead). * the request (I/O request > max_readahead).
*/ */
...@@ -447,28 +442,28 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, ...@@ -447,28 +442,28 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra,
int sequential; int sequential;
/* /*
* Here we detect the case where the application is performing * We avoid doing extra work and bogusly perturbing the readahead
* sub-page sized reads. We avoid doing extra work and bogusly * window expansion logic.
* perturbing the readahead window expansion logic.
*/ */
if (offset == ra->prev_page && --req_size) if (offset == ra->prev_page && --req_size)
++offset; ++offset;
/* Note that prev_page == -1 if it is a first read */
sequential = (offset == ra->prev_page + 1); sequential = (offset == ra->prev_page + 1);
ra->prev_page = offset; ra->prev_page = offset;
max = get_max_readahead(ra); max = get_max_readahead(ra);
newsize = min(req_size, max); newsize = min(req_size, max);
/* No readahead or file already in cache or sub-page sized read */ /* No readahead or sub-page sized read or file already in cache */
if (newsize == 0 || (ra->flags & RA_FLAG_INCACHE)) if (newsize == 0 || (ra->flags & RA_FLAG_INCACHE))
goto out; goto out;
ra->prev_page += newsize - 1; ra->prev_page += newsize - 1;
/* /*
* Special case - first read. We'll assume it's a whole-file read if * Special case - first read at start of file. We'll assume it's
* at start of file, and grow the window fast. Or detect first * a whole-file read and grow the window fast. Or detect first
* sequential access * sequential access
*/ */
if (sequential && ra->size == 0) { if (sequential && ra->size == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment