Reading Via The Page Cache
Entry function: do_generic_file_read, in mm/filemap.c:
- Get the address mapping of the file's inode.
- Translate the read position to a page index (each page contains
2^PAGE_CACHE_SHIFT bytes).
- Calculate read-ahead parameters (i.e. reading from a file at position
X normally causes reading several more pages, assuming the application
is likely to request those pages next).
- Make sure we're not reading past EOF.
- For each page in the range the user asked to read from:
- Look for the page in the page cache. If it is there, and
- If it's there, and is up-to-date:
- If we're not in 'non-blocking' mode (i.e. we're allowed to block),
invoke read-ahead.
- Copy data from the page to the user's buffer.
- Otherwise, use the address mapping 'readpage' operation to read the
page, and start over (unless we're in non-blocking mode).
Originally written by
guy keren