Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


struct block_device *bi_bdev;
...
unsigned short bi_vcnt; /* how many bio_vec’s */
unsigned short bi_idx; /* current index into bvl_vec */

unsigned short bi_phys_segments;
unsigned short bi_hw_segments;

unsigned int bi_size; /* residual I/O count */
...
struct bio_vec *bi_io_vec; /* the actual vec list */

bio_end_io_t *bi_end_io;

void *bi_private;
...
};

❑ bi_sectorspecifies the sector at which transfer starts.


❑ bi_nextcombines several BIOs in a singly linked list associated with a request.


❑ bi_bdevis a pointer to the block device data structure of the device to which the request belongs.


❑ bi_phys_segmentsandbi_hw_segmentsspecify the number of segments in a transfer before and
after remapping by the I/O MMU.


❑ bi_sizeindicates the total size of the request in bytes.


❑ bi_io_vecis a pointer to the I/O vectors, andbi_vcntspecifies the number of entries in the
array.bi_idxdenotes which array entry iscurrently being processed.
The structure of the individual array elements is as follows:



struct bio_vec {
struct page *bv_page;
unsigned int bv_len;
unsigned int bv_offset;
};
bv_pagepoints to thepageinstance of the page used for data transfer.bv_offsetindicates the
offset within the page; typically this value is 0because page boundaries are normally used as
boundaries for I/O operations.
lenspecifies the number of bytes used for the data if the whole page is not filled.

❑ bi_privateis not modified by the generic BIO code and can be used for driver-specific informa-
tion.


❑ bi_destructorpoints to a destructor function invoked before abioinstance is removed from
memory.


❑ bi_end_iomust be invoked by the device driver when hardware transfer is completed. This
gives the block layer the opportunity to do clean-up work or wake sleeping processes that are
waiting for the request to end.

Free download pdf