'\" t .\" Title: bio_alloc_bioset .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: April 2019 .\" Manual: The Linux VFS .\" Source: Kernel Hackers Manual 4.9.168 .\" Language: English .\" .TH "BIO_ALLOC_BIOSET" "9" "April 2019" "Kernel Hackers Manual 4\&.9\&." "The Linux VFS" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" bio_alloc_bioset \- allocate a bio for I/O .SH "SYNOPSIS" .HP \w'struct\ bio\ *\ bio_alloc_bioset('u .BI "struct bio * bio_alloc_bioset(gfp_t\ " "gfp_mask" ", int\ " "nr_iovecs" ", struct\ bio_set\ *\ " "bs" ");" .SH "ARGUMENTS" .PP \fIgfp_mask\fR .RS 4 the GFP_ mask given to the slab allocator .RE .PP \fInr_iovecs\fR .RS 4 number of iovecs to pre\-allocate .RE .PP \fIbs\fR .RS 4 the bio_set to allocate from\&. .RE .SH "DESCRIPTION" .PP If \fIbs\fR is NULL, uses \fBkmalloc\fR to allocate the bio; else the allocation is backed by the \fIbs\fR\*(Aqs mempool\&. .PP When \fIbs\fR is not NULL, if \fB__GFP_DIRECT_RECLAIM\fR is set then bio_alloc will always be able to allocate a bio\&. This is due to the mempool guarantees\&. To make this work, callers must never allocate more than 1 bio at a time from this pool\&. Callers that need to allocate more than 1 bio must always submit the previously allocated bio for IO before attempting to allocate a new one\&. Failure to do so can cause deadlocks under memory pressure\&. .PP Note that when running under \fBgeneric_make_request\fR (i\&.e\&. any block driver), bios are not submitted until after you return \- see the code in \fBgeneric_make_request\fR that converts recursion into iteration, to prevent stack overflows\&. .PP This would normally mean allocating multiple bios under \fBgeneric_make_request\fR would be susceptible to deadlocks, but we have deadlock avoidance code that resubmits any blocked bios from a rescuer thread\&. .PP However, we do not guarantee forward progress for allocations from other mempools\&. Doing multiple allocations from the same mempool under \fBgeneric_make_request\fR should be avoided \- instead, use bio_set\*(Aqs front_pad for per bio allocations\&. .SH "RETURN" .PP Pointer to new bio on success, NULL on failure\&. .SH "COPYRIGHT" .br