Mmfilemapc

unsigned long ra_pages;

ra_pages = max_sane_readahead(file->f_ra.ra_pages); if (ra_pages) {

start = vmf->pgoff - ra_pages / 2; do_page_cache_readahead(mapping, file, start, ra_pages);

28It sounds odd that the kernel checks for a sequential read hint even if a random read hint was found only a couple of steps before, and the check could in this case be, in fact, avoided. However, the structure of filemap_fault, which contains a quite liberal use of goto, can lead to this situation.

page = find_lock_page(mapping, vmf->pgoff); if (!page)

goto no_cached_page;

max_sane_readahead computes a sensible upper bound on the number of pages that are supposed to be read in in advance. If this number is greater than zero, do_page_cache_readahead is invoked to allocate pages in the page cache and read in the data. Since afterward there is sufficient hope the desired page is in the page cache, find_lock_page once again tries to locate it there. Should this again fail, the kernel jumps to no_cached_page as described before.

If the page is by now contained in the page cache, it is necessary to ensure that the page is up-to-date. If it is not, it is re-read using the readpage method of the mapping, and retries the page access again starting from the call to find_lock_page further above. Otherwise, it suffices to call mark_page_accessed to mark the page as active.

Continue reading here: Fsnameic

Was this article helpful?

0 0