Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
bio.c File Reference
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/bio.h>
#include <linux/blkdev.h>
#include <linux/iocontext.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/mempool.h>
#include <linux/workqueue.h>
#include <linux/cgroup.h>
#include <scsi/sg.h>
#include <trace/events/block.h>

Go to the source code of this file.

Data Structures

struct  bio_slab
 
struct  bio_map_data
 

Macros

#define BIO_INLINE_VECS   4
 
#define BV(x)   { .nr_vecs = x, .name = "biovec-"__stringify(x) }
 

Functions

 EXPORT_SYMBOL (fs_bio_set)
 
unsigned int bvec_nr_vecs (unsigned short idx)
 
void bvec_free_bs (struct bio_set *bs, struct bio_vec *bv, unsigned int idx)
 
struct bio_vec * bvec_alloc_bs (gfp_t gfp_mask, int nr, unsigned long *idx, struct bio_set *bs)
 
void bio_init (struct bio *bio)
 
 EXPORT_SYMBOL (bio_init)
 
void bio_reset (struct bio *bio)
 
 EXPORT_SYMBOL (bio_reset)
 
struct bio * bio_alloc_bioset (gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
 
 EXPORT_SYMBOL (bio_alloc_bioset)
 
void zero_fill_bio (struct bio *bio)
 
 EXPORT_SYMBOL (zero_fill_bio)
 
void bio_put (struct bio *bio)
 
 EXPORT_SYMBOL (bio_put)
 
int bio_phys_segments (struct request_queue *q, struct bio *bio)
 
 EXPORT_SYMBOL (bio_phys_segments)
 
void __bio_clone (struct bio *bio, struct bio *bio_src)
 
 EXPORT_SYMBOL (__bio_clone)
 
struct bio * bio_clone_bioset (struct bio *bio, gfp_t gfp_mask, struct bio_set *bs)
 
 EXPORT_SYMBOL (bio_clone_bioset)
 
int bio_get_nr_vecs (struct block_device *bdev)
 
 EXPORT_SYMBOL (bio_get_nr_vecs)
 
int bio_add_pc_page (struct request_queue *q, struct bio *bio, struct page *page, unsigned int len, unsigned int offset)
 
 EXPORT_SYMBOL (bio_add_pc_page)
 
int bio_add_page (struct bio *bio, struct page *page, unsigned int len, unsigned int offset)
 
 EXPORT_SYMBOL (bio_add_page)
 
int bio_uncopy_user (struct bio *bio)
 
 EXPORT_SYMBOL (bio_uncopy_user)
 
struct bio * bio_copy_user_iov (struct request_queue *q, struct rq_map_data *map_data, struct sg_iovec *iov, int iov_count, int write_to_vm, gfp_t gfp_mask)
 
struct bio * bio_copy_user (struct request_queue *q, struct rq_map_data *map_data, unsigned long uaddr, unsigned int len, int write_to_vm, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (bio_copy_user)
 
struct bio * bio_map_user (struct request_queue *q, struct block_device *bdev, unsigned long uaddr, unsigned int len, int write_to_vm, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (bio_map_user)
 
struct bio * bio_map_user_iov (struct request_queue *q, struct block_device *bdev, struct sg_iovec *iov, int iov_count, int write_to_vm, gfp_t gfp_mask)
 
void bio_unmap_user (struct bio *bio)
 
 EXPORT_SYMBOL (bio_unmap_user)
 
struct bio * bio_map_kern (struct request_queue *q, void *data, unsigned int len, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (bio_map_kern)
 
struct bio * bio_copy_kern (struct request_queue *q, void *data, unsigned int len, gfp_t gfp_mask, int reading)
 
 EXPORT_SYMBOL (bio_copy_kern)
 
void bio_set_pages_dirty (struct bio *bio)
 
void bio_check_pages_dirty (struct bio *bio)
 
void bio_endio (struct bio *bio, int error)
 
 EXPORT_SYMBOL (bio_endio)
 
void bio_pair_release (struct bio_pair *bp)
 
 EXPORT_SYMBOL (bio_pair_release)
 
struct bio_pair * bio_split (struct bio *bi, int first_sectors)
 
 EXPORT_SYMBOL (bio_split)
 
sector_t bio_sector_offset (struct bio *bio, unsigned short index, unsigned int offset)
 
 EXPORT_SYMBOL (bio_sector_offset)
 
void bioset_free (struct bio_set *bs)
 
 EXPORT_SYMBOL (bioset_free)
 
struct bio_set * bioset_create (unsigned int pool_size, unsigned int front_pad)
 
 EXPORT_SYMBOL (bioset_create)
 
 subsys_initcall (init_bio)
 

Variables

struct bio_set * fs_bio_set
 

Macro Definition Documentation

#define BIO_INLINE_VECS   4

Definition at line 38 of file bio.c.

#define BV (   x)    { .nr_vecs = x, .name = "biovec-"__stringify(x) }

Definition at line 47 of file bio.c.

Function Documentation

void __bio_clone ( struct bio *  bio,
struct bio *  bio_src 
)

__bio_clone - clone a bio : destination bio : bio to clone

Clone a &bio. Caller will own the returned bio, but not the actual data it points to. Reference count of returned bio will be one.

Definition at line 423 of file bio.c.

int bio_add_page ( struct bio *  bio,
struct page page,
unsigned int  len,
unsigned int  offset 
)

Definition at line 647 of file bio.c.

int bio_add_pc_page ( struct request_queue q,
struct bio *  bio,
struct page page,
unsigned int  len,
unsigned int  offset 
)

Definition at line 627 of file bio.c.

struct bio* bio_alloc_bioset ( gfp_t  gfp_mask,
int  nr_iovecs,
struct bio_set *  bs 
)
read

bio_alloc_bioset - allocate a bio for I/O : the GFP_ mask given to the slab allocator : number of iovecs to pre-allocate : the bio_set to allocate from.

Description: If is NULL, uses kmalloc() to allocate the bio; else the allocation is backed by the 's mempool.

When is not NULL, if __GFP_WAIT 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.

RETURNS: Pointer to new bio on success, NULL on failure.

Definition at line 320 of file bio.c.

void bio_check_pages_dirty ( struct bio *  bio)

Definition at line 1368 of file bio.c.

struct bio* bio_clone_bioset ( struct bio *  bio,
gfp_t  gfp_mask,
struct bio_set *  bs 
)
read

bio_clone_bioset - clone a bio : bio to clone : allocation priority : bio_set to allocate from

Like __bio_clone, only also allocates the returned bio

Definition at line 450 of file bio.c.

struct bio* bio_copy_kern ( struct request_queue q,
void data,
unsigned int  len,
gfp_t  gfp_mask,
int  reading 
)
read

bio_copy_kern - copy kernel address into bio : the struct request_queue for the bio : pointer to buffer to copy : length in bytes : allocation flags for bio and page allocation : data direction is READ

copy the kernel address into a bio suitable for io to a block device. Returns an error pointer in case of error.

Definition at line 1245 of file bio.c.

struct bio* bio_copy_user ( struct request_queue q,
struct rq_map_data *  map_data,
unsigned long  uaddr,
unsigned int  len,
int  write_to_vm,
gfp_t  gfp_mask 
)
read

bio_copy_user - copy user data to bio : destination block queue : pointer to the rq_map_data holding pages (if necessary) : start of user address : length in bytes : bool indicating writing to pages or not : memory allocation flags

Prepares and returns a bio for indirect user io, bouncing data to/from kernel pages as necessary. Must be paired with call bio_uncopy_user() on io completion.

Definition at line 921 of file bio.c.

struct bio* bio_copy_user_iov ( struct request_queue q,
struct rq_map_data *  map_data,
struct sg_iovec iov,
int  iov_count,
int  write_to_vm,
gfp_t  gfp_mask 
)
read

bio_copy_user_iov - copy user data to bio : destination block queue : pointer to the rq_map_data holding pages (if necessary) : the iovec. : number of elements in the iovec : bool indicating writing to pages or not : memory allocation flags

Prepares and returns a bio for indirect user io, bouncing data to/from kernel pages as necessary. Must be paired with call bio_uncopy_user() on io completion.

Definition at line 795 of file bio.c.

void bio_endio ( struct bio *  bio,
int  error 
)

bio_endio - end I/O on a bio : bio : error, if any

Description: bio_endio() will end I/O on the whole bio. bio_endio() is the preferred way to end I/O on a bio, it takes care of clearing BIO_UPTODATE on error. is 0 on success, and and one of the established -Exxxx (-EIO, for instance) error values in case something went wrong. No one should call bi_end_io() directly on a bio unless they own it and thus know that it has an end_io function.

Definition at line 1424 of file bio.c.

int bio_get_nr_vecs ( struct block_device bdev)

bio_get_nr_vecs - return approx number of vecs : I/O target

Return the approximate number of pages we can send to this target. There's no guarantee that you will be able to fit this number of pages into a bio, it does not account for dynamic restrictions that vary on offset.

Definition at line 485 of file bio.c.

void bio_init ( struct bio *  bio)

Definition at line 271 of file bio.c.

struct bio* bio_map_kern ( struct request_queue q,
void data,
unsigned int  len,
gfp_t  gfp_mask 
)
read

bio_map_kern - map kernel address into bio : the struct request_queue for the bio : pointer to buffer to map : length in bytes : allocation flags for bio allocation

Map the kernel address into a bio suitable for io to a block device. Returns an error pointer in case of error.

Definition at line 1191 of file bio.c.

struct bio* bio_map_user ( struct request_queue q,
struct block_device bdev,
unsigned long  uaddr,
unsigned int  len,
int  write_to_vm,
gfp_t  gfp_mask 
)
read

bio_map_user - map user address into bio : the struct request_queue for the bio : destination block device : start of user address : length in bytes : bool indicating writing to pages or not : memory allocation flags

Map the user space address into a bio suitable for io to a block device. Returns an error pointer in case of error.

Definition at line 1058 of file bio.c.

struct bio* bio_map_user_iov ( struct request_queue q,
struct block_device bdev,
struct sg_iovec iov,
int  iov_count,
int  write_to_vm,
gfp_t  gfp_mask 
)
read

bio_map_user_iov - map user sg_iovec table into bio : the struct request_queue for the bio : destination block device : the iovec. : number of elements in the iovec : bool indicating writing to pages or not : memory allocation flags

Map the user space address into a bio suitable for io to a block device. Returns an error pointer in case of error.

Definition at line 1083 of file bio.c.

void bio_pair_release ( struct bio_pair *  bp)

Definition at line 1436 of file bio.c.

int bio_phys_segments ( struct request_queue q,
struct bio *  bio 
)
inline

Definition at line 405 of file bio.c.

void bio_put ( struct bio *  bio)

bio_put - release a reference to a bio : bio to release reference to

Description: Put a reference to a &struct bio, either one you have gotten with bio_alloc, bio_get or bio_clone. The last put of a bio will free it.

Definition at line 393 of file bio.c.

void bio_reset ( struct bio *  bio)

bio_reset - reinitialize a bio : bio to reset

Description: After calling bio_reset(), will be in the same state as a freshly allocated bio returned bio bio_alloc_bioset() - the only fields that are preserved are the ones that are initialized by bio_alloc_bioset(). See comment in struct bio.

Definition at line 289 of file bio.c.

sector_t bio_sector_offset ( struct bio *  bio,
unsigned short  index,
unsigned int  offset 
)

bio_sector_offset - Find hardware sector offset in bio : bio to inspect : bio_vec index : offset in bv_page

Return the number of hardware sectors between beginning of bio and an end point indicated by a bio_vec index and an offset within that vector's page.

Definition at line 1530 of file bio.c.

void bio_set_pages_dirty ( struct bio *  bio)

Definition at line 1302 of file bio.c.

struct bio_pair* bio_split ( struct bio *  bi,
int  first_sectors 
)
read

Definition at line 1470 of file bio.c.

int bio_uncopy_user ( struct bio *  bio)

bio_uncopy_user - finish previously mapped bio : bio being terminated

Free pages allocated from bio_copy_user() and write back data to user space in case of a read.

Definition at line 767 of file bio.c.

void bio_unmap_user ( struct bio *  bio)

bio_unmap_user - unmap a bio : the bio being unmapped

Unmap a bio previously mapped by bio_map_user(). Must be called with a process context.

bio_unmap_user() may sleep.

Definition at line 1132 of file bio.c.

struct bio_set* bioset_create ( unsigned int  pool_size,
unsigned int  front_pad 
)
read

bioset_create - Create a bio_set : Number of bio and bio_vecs to cache in the mempool : Number of bytes to allocate in front of the returned bio

Description: Set up a bio_set to be used with . Allows the caller to ask for a number of bytes to be allocated in front of the bio. Front pad allocation is useful for embedding the bio inside another structure, to avoid allocating extra data to go with the bio. Note that the bio must be embedded at the END of that structure always, or things will break badly.

Definition at line 1604 of file bio.c.

void bioset_free ( struct bio_set *  bs)

Definition at line 1578 of file bio.c.

struct bio_vec* bvec_alloc_bs ( gfp_t  gfp_mask,
int  nr,
unsigned long idx,
struct bio_set *  bs 
)
read

Definition at line 176 of file bio.c.

void bvec_free_bs ( struct bio_set *  bs,
struct bio_vec *  bv,
unsigned int  idx 
)

Definition at line 163 of file bio.c.

unsigned int bvec_nr_vecs ( unsigned short  idx)

Definition at line 158 of file bio.c.

EXPORT_SYMBOL ( fs_bio_set  )
EXPORT_SYMBOL ( bio_init  )
EXPORT_SYMBOL ( bio_reset  )
EXPORT_SYMBOL ( bio_alloc_bioset  )
EXPORT_SYMBOL ( zero_fill_bio  )
EXPORT_SYMBOL ( bio_put  )
EXPORT_SYMBOL ( bio_phys_segments  )
EXPORT_SYMBOL ( __bio_clone  )
EXPORT_SYMBOL ( bio_clone_bioset  )
EXPORT_SYMBOL ( bio_get_nr_vecs  )
EXPORT_SYMBOL ( bio_add_pc_page  )
EXPORT_SYMBOL ( bio_add_page  )
EXPORT_SYMBOL ( bio_uncopy_user  )
EXPORT_SYMBOL ( bio_copy_user  )
EXPORT_SYMBOL ( bio_map_user  )
EXPORT_SYMBOL ( bio_unmap_user  )
EXPORT_SYMBOL ( bio_map_kern  )
EXPORT_SYMBOL ( bio_copy_kern  )
EXPORT_SYMBOL ( bio_endio  )
EXPORT_SYMBOL ( bio_pair_release  )
EXPORT_SYMBOL ( bio_split  )
EXPORT_SYMBOL ( bio_sector_offset  )
EXPORT_SYMBOL ( bioset_free  )
EXPORT_SYMBOL ( bioset_create  )
subsys_initcall ( init_bio  )
void zero_fill_bio ( struct bio *  bio)

Definition at line 370 of file bio.c.

Variable Documentation

struct bio_set* fs_bio_set

Definition at line 57 of file bio.c.