<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>mpage_readpages</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /><link rel="home" href="index.html" title="Linux Filesystems API" /><link rel="up" href="other_functions.html" title="Other Functions" /><link rel="prev" href="other_functions.html" title="Other Functions" /><link rel="next" href="API-mpage-writepages.html" title="mpage_writepages" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span>mpage_readpages</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="other_functions.html">Prev</a> </td><th width="60%" align="center">Other Functions</th><td width="20%" align="right"> <a accesskey="n" href="API-mpage-writepages.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="mpage_readpages"><a id="API-mpage-readpages"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>mpage_readpages — populate an address space with some pages & start reads against them </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <strong>fsfuncmpage_readpages </strong>(</code></td><td>struct address_space * <var class="pdparam">mapping</var>, </td></tr><tr><td> </td><td>struct list_head * <var class="pdparam">pages</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">nr_pages</var>, </td></tr><tr><td> </td><td>get_block_t <var class="pdparam">get_block</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1" title="Arguments"><a id="id2748978"></a><h2>Arguments</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>mapping</code></em></span></dt><dd><p> the address_space </p></dd><dt><span class="term"><em class="parameter"><code>pages</code></em></span></dt><dd><p> The address of a list_head which contains the target pages. These pages have their ->index populated and are otherwise uninitialised. The page at <em class="parameter"><code>pages</code></em>->prev has the lowest file offset, and reads should be issued in <em class="parameter"><code>pages</code></em>->prev to <em class="parameter"><code>pages</code></em>->next order. </p></dd><dt><span class="term"><em class="parameter"><code>nr_pages</code></em></span></dt><dd><p> The number of pages at *<em class="parameter"><code>pages</code></em> </p></dd><dt><span class="term"><em class="parameter"><code>get_block</code></em></span></dt><dd><p> The filesystem's block mapper function. </p></dd></dl></div></div><div class="refsect1" title="Description"><a id="id2749081"></a><h2>Description</h2><p> This function walks the pages and the blocks within each page, building and emitting large BIOs. </p><p> If anything unusual happens, such as: </p><p> - encountering a page which has buffers - encountering a page which has a non-hole after a hole - encountering a page with non-contiguous blocks </p><p> then this code just gives up and calls the buffer_head-based read function. It does handle a page which has holes at the end - that is a common case: the end-of-file on blocksize < PAGE_CACHE_SIZE setups. </p></div><div class="refsect1" title="BH_Boundary explanation"><a id="id2749109"></a><h2>BH_Boundary explanation</h2><p> </p><p> There is a problem. The mpage read code assembles several pages, gets all their disk mappings, and then submits them all. That's fine, but obtaining the disk mappings may require I/O. Reads of indirect blocks, for example. </p><p> So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be </p></div><div class="refsect1" title="submitted in the following order"><a id="id2749128"></a><h2>submitted in the following order</h2><p> 12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16 </p><p> because the indirect block has to be read to get the mappings of blocks 13,14,15,16. Obviously, this impacts performance. </p><p> So what we do it to allow the filesystem's <code class="function">get_block</code> function to set BH_Boundary when it maps block 11. BH_Boundary says: mapping of the block after this one will require I/O against a block which is probably close to this one. So you should push what I/O you have currently accumulated. </p><p> This all causes the disk requests to be issued in the correct order. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="other_functions.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="other_functions.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-mpage-writepages.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Other Functions </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span>mpage_writepages</span></td></tr></table></div></body></html>