1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>bio_alloc_bioset</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="API-bio-chain.html" title="bio_chain"><link rel="next" href="API-bio-put.html" title="bio_put"></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">bio_alloc_bioset</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-bio-chain.html">Prev</a>&#160;</td><th width="60%" align="center">Other Functions</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-bio-put.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-bio-alloc-bioset"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>bio_alloc_bioset &#8212; 
2     allocate a bio for I/O
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 bio * <b class="fsfunc">bio_alloc_bioset </b>(</code></td><td>gfp_t <var class="pdparam">gfp_mask</var>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">nr_iovecs</var>, </td></tr><tr><td>&#160;</td><td>struct bio_set * <var class="pdparam">bs</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1102339228"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>gfp_mask</code></em></span></dt><dd><p>
4     the GFP_ mask given to the slab allocator
5    </p></dd><dt><span class="term"><em class="parameter"><code>nr_iovecs</code></em></span></dt><dd><p>
6     number of iovecs to pre-allocate
7    </p></dd><dt><span class="term"><em class="parameter"><code>bs</code></em></span></dt><dd><p>
8     the bio_set to allocate from.
9    </p></dd></dl></div></div><div class="refsect1"><a name="idp1102342916"></a><h2>Description</h2><p>
10   If <em class="parameter"><code>bs</code></em> is NULL, uses <code class="function">kmalloc</code> to allocate the bio; else the allocation is
11   backed by the <em class="parameter"><code>bs</code></em>'s mempool.
12   </p><p>
13
14   When <em class="parameter"><code>bs</code></em> is not NULL, if <code class="constant">__GFP_WAIT</code> is set then bio_alloc will always be
15   able to allocate a bio. This is due to the mempool guarantees. To make this
16   work, callers must never allocate more than 1 bio at a time from this pool.
17   Callers that need to allocate more than 1 bio must always submit the
18   previously allocated bio for IO before attempting to allocate a new one.
19   Failure to do so can cause deadlocks under memory pressure.
20   </p><p>
21
22   Note that when running under <code class="function">generic_make_request</code> (i.e. any block
23   driver), bios are not submitted until after you return - see the code in
24   <code class="function">generic_make_request</code> that converts recursion into iteration, to prevent
25   stack overflows.
26   </p><p>
27
28   This would normally mean allocating multiple bios under
29   <code class="function">generic_make_request</code> would be susceptible to deadlocks, but we have
30   deadlock avoidance code that resubmits any blocked bios from a rescuer
31   thread.
32   </p><p>
33
34   However, we do not guarantee forward progress for allocations from other
35   mempools. Doing multiple allocations from the same mempool under
36   <code class="function">generic_make_request</code> should be avoided - instead, use bio_set's front_pad
37   for per bio allocations.
38</p></div><div class="refsect1"><a name="idp1102348276"></a><h2>RETURNS</h2><p>
39   Pointer to new bio on success, NULL on failure.
40</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-bio-chain.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="other_functions.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-bio-put.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">bio_chain</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">bio_put</span></td></tr></table></div></body></html>
41