1<html><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.78.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 bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">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"><a name="API-mpage-readpages"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>mpage_readpages — 2 populate an address space with some pages & start reads against them 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">mpage_readpages </b>(</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"><a name="idp1102116684"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>mapping</code></em></span></dt><dd><p> 4 the address_space 5 </p></dd><dt><span class="term"><em class="parameter"><code>pages</code></em></span></dt><dd><p> 6 The address of a list_head which contains the target pages. These 7 pages have their ->index populated and are otherwise uninitialised. 8 The page at <em class="parameter"><code>pages</code></em>->prev has the lowest file offset, and reads should be 9 issued in <em class="parameter"><code>pages</code></em>->prev to <em class="parameter"><code>pages</code></em>->next order. 10 </p></dd><dt><span class="term"><em class="parameter"><code>nr_pages</code></em></span></dt><dd><p> 11 The number of pages at *<em class="parameter"><code>pages</code></em> 12 </p></dd><dt><span class="term"><em class="parameter"><code>get_block</code></em></span></dt><dd><p> 13 The filesystem's block mapper function. 14 </p></dd></dl></div></div><div class="refsect1"><a name="idp1102122852"></a><h2>Description</h2><p> 15 This function walks the pages and the blocks within each page, building and 16 emitting large BIOs. 17 </p><p> 18 19 If anything unusual happens, such as: 20 </p><p> 21 22 - encountering a page which has buffers 23 - encountering a page which has a non-hole after a hole 24 - encountering a page with non-contiguous blocks 25 </p><p> 26 27 then this code just gives up and calls the buffer_head-based read function. 28 It does handle a page which has holes at the end - that is a common case: 29 the end-of-file on blocksize < PAGE_CACHE_SIZE setups. 30</p></div><div class="refsect1"><a name="idp1102124540"></a><h2>BH_Boundary explanation</h2><p> 31 </p><p> 32 33 There is a problem. The mpage read code assembles several pages, gets all 34 their disk mappings, and then submits them all. That's fine, but obtaining 35 the disk mappings may require I/O. Reads of indirect blocks, for example. 36 </p><p> 37 38 So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be 39</p></div><div class="refsect1"><a name="idp1102125708"></a><h2>submitted in the following order</h2><p> 40 12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16 41 </p><p> 42 43 because the indirect block has to be read to get the mappings of blocks 44 13,14,15,16. Obviously, this impacts performance. 45 </p><p> 46 47 So what we do it to allow the filesystem's <code class="function">get_block</code> function to set 48 BH_Boundary when it maps block 11. BH_Boundary says: mapping of the block 49 after this one will require I/O against a block which is probably close to 50 this one. So you should push what I/O you have currently accumulated. 51 </p><p> 52 53 This all causes the disk requests to be issued in the correct order. 54</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 class="phrase">mpage_writepages</span></td></tr></table></div></body></html> 55