Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
bio-integrity.c File Reference
#include <linux/blkdev.h>
#include <linux/mempool.h>
#include <linux/export.h>
#include <linux/bio.h>
#include <linux/workqueue.h>
#include <linux/slab.h>

Go to the source code of this file.

Data Structures

struct  integrity_slab
 

Macros

#define IS(x)   { .nr_vecs = x, .name = "bip-"__stringify(x) }
 

Functions

struct bio_integrity_payload * bio_integrity_alloc (struct bio *bio, gfp_t gfp_mask, unsigned int nr_vecs)
 
 EXPORT_SYMBOL (bio_integrity_alloc)
 
void bio_integrity_free (struct bio *bio)
 
 EXPORT_SYMBOL (bio_integrity_free)
 
int bio_integrity_add_page (struct bio *bio, struct page *page, unsigned int len, unsigned int offset)
 
 EXPORT_SYMBOL (bio_integrity_add_page)
 
int bio_integrity_enabled (struct bio *bio)
 
 EXPORT_SYMBOL (bio_integrity_enabled)
 
unsigned int bio_integrity_tag_size (struct bio *bio)
 
 EXPORT_SYMBOL (bio_integrity_tag_size)
 
int bio_integrity_tag (struct bio *bio, void *tag_buf, unsigned int len, int set)
 
int bio_integrity_set_tag (struct bio *bio, void *tag_buf, unsigned int len)
 
 EXPORT_SYMBOL (bio_integrity_set_tag)
 
int bio_integrity_get_tag (struct bio *bio, void *tag_buf, unsigned int len)
 
 EXPORT_SYMBOL (bio_integrity_get_tag)
 
int bio_integrity_prep (struct bio *bio)
 
 EXPORT_SYMBOL (bio_integrity_prep)
 
void bio_integrity_endio (struct bio *bio, int error)
 
 EXPORT_SYMBOL (bio_integrity_endio)
 
void bio_integrity_mark_head (struct bio_integrity_payload *bip, unsigned int skip)
 
void bio_integrity_mark_tail (struct bio_integrity_payload *bip, unsigned int len)
 
void bio_integrity_advance (struct bio *bio, unsigned int bytes_done)
 
 EXPORT_SYMBOL (bio_integrity_advance)
 
void bio_integrity_trim (struct bio *bio, unsigned int offset, unsigned int sectors)
 
 EXPORT_SYMBOL (bio_integrity_trim)
 
void bio_integrity_split (struct bio *bio, struct bio_pair *bp, int sectors)
 
 EXPORT_SYMBOL (bio_integrity_split)
 
int bio_integrity_clone (struct bio *bio, struct bio *bio_src, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (bio_integrity_clone)
 
int bioset_integrity_create (struct bio_set *bs, int pool_size)
 
 EXPORT_SYMBOL (bioset_integrity_create)
 
void bioset_integrity_free (struct bio_set *bs)
 
 EXPORT_SYMBOL (bioset_integrity_free)
 
void __init bio_integrity_init (void)
 

Variables

struct integrity_slab bip_slab[BIOVEC_NR_POOLS] __read_mostly
 

Macro Definition Documentation

#define IS (   x)    { .nr_vecs = x, .name = "bip-"__stringify(x) }

Definition at line 36 of file bio-integrity.c.

Function Documentation

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

Definition at line 161 of file bio-integrity.c.

void bio_integrity_advance ( struct bio *  bio,
unsigned int  bytes_done 
)

bio_integrity_advance - Advance integrity vector : bio whose integrity vector to update : number of data bytes that have been completed

Description: This function calculates how many integrity bytes the number of completed data bytes correspond to and advances the integrity vector accordingly.

Definition at line 628 of file bio-integrity.c.

struct bio_integrity_payload* bio_integrity_alloc ( struct bio *  bio,
gfp_t  gfp_mask,
unsigned int  nr_vecs 
)
read

bio_integrity_alloc - Allocate integrity payload and attach it to bio : bio to attach integrity metadata to : Memory allocation mask : Number of integrity metadata scatter-gather elements

Description: This function prepares a bio for attaching integrity metadata. nr_vecs specifies the maximum number of pages containing integrity metadata that can be attached.

Definition at line 82 of file bio-integrity.c.

int bio_integrity_clone ( struct bio *  bio,
struct bio *  bio_src,
gfp_t  gfp_mask 
)

bio_integrity_clone - Callback for cloning bios with integrity metadata : New bio : Original bio : Memory allocation mask

Description: Called to allocate a bip when cloning a bio

Definition at line 723 of file bio-integrity.c.

int bio_integrity_enabled ( struct bio *  bio)

bio_integrity_enabled - Check whether integrity can be passed : bio to check

Description: Determines whether bio_integrity_prep() can be called on this bio or not. bio data direction and target device must be set prior to calling. The functions honors the write_generate and read_verify flags in sysfs.

Definition at line 211 of file bio-integrity.c.

void bio_integrity_endio ( struct bio *  bio,
int  error 
)

bio_integrity_endio - Integrity I/O completion function : Protected bio : Pointer to errno

Description: Completion for integrity I/O

Normally I/O completion is done in interrupt context. However, verifying I/O integrity is a time-consuming task which must be run in process context. This function postpones completion accordingly.

Definition at line 547 of file bio-integrity.c.

void bio_integrity_free ( struct bio *  bio)

bio_integrity_free - Free bio integrity payload : bio containing bip to be freed

Description: Used to free the integrity portion of a bio. Usually called from bio_free().

Definition at line 128 of file bio-integrity.c.

int bio_integrity_get_tag ( struct bio *  bio,
void tag_buf,
unsigned int  len 
)

bio_integrity_get_tag - Retrieve a tag buffer from a bio : bio to retrieve buffer from : Pointer to a buffer for the tag data : Length of the target buffer

Description: Use this function to retrieve the tag buffer from a completed I/O. The size of the integrity buffer must be <= to the size reported by bio_integrity_tag_size().

Definition at line 316 of file bio-integrity.c.

void __init bio_integrity_init ( void  )

Definition at line 771 of file bio-integrity.c.

void bio_integrity_mark_head ( struct bio_integrity_payload *  bip,
unsigned int  skip 
)

bio_integrity_mark_head - Advance bip_vec skip bytes : Integrity vector to advance Number of bytes to advance it

Definition at line 574 of file bio-integrity.c.

void bio_integrity_mark_tail ( struct bio_integrity_payload *  bip,
unsigned int  len 
)

bio_integrity_mark_tail - Truncate bip_vec to be len bytes long : Integrity vector to truncate : New length of integrity vector

Definition at line 600 of file bio-integrity.c.

int bio_integrity_prep ( struct bio *  bio)

bio_integrity_prep - Prepare bio for integrity I/O : bio to prepare

Description: Allocates a buffer for integrity metadata, maps the pages and attaches them to a bio. The bio must have data direction, target device and start sector set priot to calling. In the WRITE case, integrity metadata will be generated using the block device's integrity function. In the READ case, the buffer will be prepared for DMA and a suitable end_io handler set up.

Definition at line 384 of file bio-integrity.c.

int bio_integrity_set_tag ( struct bio *  bio,
void tag_buf,
unsigned int  len 
)

bio_integrity_set_tag - Attach a tag buffer to a bio : bio to attach buffer to : Pointer to a buffer containing tag data : Length of the included buffer

Description: Use this function to tag a bio by leveraging the extra space provided by devices formatted with integrity protection. The size of the integrity buffer must be <= to the size reported by bio_integrity_tag_size().

Definition at line 298 of file bio-integrity.c.

void bio_integrity_split ( struct bio *  bio,
struct bio_pair *  bp,
int  sectors 
)

bio_integrity_split - Split integrity metadata : Protected bio : Resulting bio_pair : Offset

Description: Splits an integrity page into a bio_pair.

Definition at line 679 of file bio-integrity.c.

int bio_integrity_tag ( struct bio *  bio,
void tag_buf,
unsigned int  len,
int  set 
)

Definition at line 259 of file bio-integrity.c.

unsigned int bio_integrity_tag_size ( struct bio *  bio)

bio_integrity_tag_size - Retrieve integrity tag space : bio to inspect

Description: Returns the maximum number of tag bytes that can be attached to this bio. Filesystems can use this to determine how much metadata to attach to an I/O.

Definition at line 249 of file bio-integrity.c.

void bio_integrity_trim ( struct bio *  bio,
unsigned int  offset,
unsigned int  sectors 
)

bio_integrity_trim - Trim integrity vector : bio whose integrity vector to update : offset to first data sector : number of data sectors

Description: Used to trim the integrity vector in a cloned bio. The ivec will be advanced corresponding to 'offset' data sectors and the length will be truncated corresponding to 'len' data sectors.

Definition at line 653 of file bio-integrity.c.

int bioset_integrity_create ( struct bio_set *  bs,
int  pool_size 
)

Definition at line 747 of file bio-integrity.c.

void bioset_integrity_free ( struct bio_set *  bs)

Definition at line 764 of file bio-integrity.c.

EXPORT_SYMBOL ( bio_integrity_alloc  )
EXPORT_SYMBOL ( bio_integrity_free  )
EXPORT_SYMBOL ( bio_integrity_add_page  )
EXPORT_SYMBOL ( bio_integrity_enabled  )
EXPORT_SYMBOL ( bio_integrity_tag_size  )
EXPORT_SYMBOL ( bio_integrity_set_tag  )
EXPORT_SYMBOL ( bio_integrity_get_tag  )
EXPORT_SYMBOL ( bio_integrity_prep  )
EXPORT_SYMBOL ( bio_integrity_endio  )
EXPORT_SYMBOL ( bio_integrity_advance  )
EXPORT_SYMBOL ( bio_integrity_trim  )
EXPORT_SYMBOL ( bio_integrity_split  )
EXPORT_SYMBOL ( bio_integrity_clone  )
EXPORT_SYMBOL ( bioset_integrity_create  )
EXPORT_SYMBOL ( bioset_integrity_free  )

Variable Documentation

struct integrity_slab bip_slab [BIOVEC_NR_POOLS] __read_mostly
Initial value:
= {
IS(1), IS(4), IS(16), IS(64), IS(128), IS(BIO_MAX_PAGES),
}

Definition at line 37 of file bio-integrity.c.