1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>blk_make_request</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Linux Kernel API"><link rel="up" href="blkdev.html" title="Chapter&#160;14.&#160;Block Devices"><link rel="prev" href="API-blk-init-queue.html" title="blk_init_queue"><link rel="next" href="API-blk-rq-set-block-pc.html" title="blk_rq_set_block_pc"></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">blk_make_request</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-blk-init-queue.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;14.&#160;Block Devices</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-blk-rq-set-block-pc.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-blk-make-request"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>blk_make_request &#8212; 
2     given a bio, allocate a corresponding struct request.
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">struct request * <b class="fsfunc">blk_make_request </b>(</code></td><td>struct request_queue * <var class="pdparam">q</var>, </td></tr><tr><td>&#160;</td><td>struct bio * <var class="pdparam">bio</var>, </td></tr><tr><td>&#160;</td><td>gfp_t <var class="pdparam">gfp_mask</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1127875380"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>q</code></em></span></dt><dd><p>
4     target request queue
5    </p></dd><dt><span class="term"><em class="parameter"><code>bio</code></em></span></dt><dd><p>
6     The bio describing the memory mappings that will be submitted for IO.
7     It may be a chained-bio properly constructed by block/bio layer.
8    </p></dd><dt><span class="term"><em class="parameter"><code>gfp_mask</code></em></span></dt><dd><p>
9     gfp flags to be used for memory allocation
10    </p></dd></dl></div></div><div class="refsect1"><a name="idp1127879156"></a><h2>Description</h2><p>
11   blk_make_request is the parallel of generic_make_request for BLOCK_PC
12   type commands. Where the struct request needs to be farther initialized by
13   the caller. It is passed a <span class="structname">struct bio</span>, which describes the memory info of
14   the I/O transfer.
15   </p><p>
16
17   The caller of blk_make_request must make sure that bi_io_vec
18   are set to describe the memory buffers. That <code class="function">bio_data_dir</code> will return
19   the needed direction of the request. (And all bio's in the passed bio-chain
20   are properly set accordingly)
21   </p><p>
22
23   If called under none-sleepable conditions, mapped bio buffers must not
24   need bouncing, by calling the appropriate masked or flagged allocator,
25   suitable for the target device. Otherwise the call to blk_queue_bounce will
26   BUG.
27</p></div><div class="refsect1"><a name="idp1127881332"></a><h2>WARNING</h2><p>
28   When allocating/cloning a bio-chain, careful consideration should be
29   given to how you allocate bios. In particular, you cannot use __GFP_WAIT for
30   anything but the first bio in the chain. Otherwise you risk waiting for IO
31   completion of a bio that hasn't been submitted yet, thus resulting in a
32   deadlock. Alternatively bios should be allocated using <code class="function">bio_kmalloc</code> instead
33   of <code class="function">bio_alloc</code>, as that avoids the mempool deadlock.
34   If possible a big IO should be split into smaller parts when allocation
35   fails. Partial allocation should not be an error, or you risk a live-lock.
36</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-blk-init-queue.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="blkdev.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-blk-rq-set-block-pc.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">blk_init_queue</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">blk_rq_set_block_pc</span></td></tr></table></div></body></html>
37