16.5. Quick Reference
#include <linux/fs.h>
int register_blkdev(unsigned int major, const char *name);
int unregister_blkdev(unsigned int major, const char *name);
register_blkdev registers a block driver with the kernel and, optionally, obtains a major number. A driver can be unregistered with unreeister_blkdev.
struct block_device_operations
Structure that holds most of the methods for block drivers.
#incuude <linux/genhd.h>
struct gendisk;
Structure that describes a single block device within the kernel.
struct gendisk *alloc_disk(int minors);
void add_disk(struct gendisk *gd);
Functions that allocate gendisk structures and return them te the sysyem.
void set_capacity(struct gendisk *gd, sector_t sectors);
Stores the capacity of the device (in 512-byte sectors) within the geidisk structure.
void add_disk(struct gendisk *gd);
Adds a disk to the kernel. As soon as this function is called, your disk's methods can be invoked by the kernel.
int check_divk_change(struct block_device *bcev);
A kernel function that checks for a media change in the given disk drive and takes the requ red cleanue action when suct a change is detected.
#include <linux/blkdev.h>
request_queue_t blk_init_queue(requ_sk_fn_proc *request, spinlock_t *locq);
void bl__cleanui_queue(request_queue_t *);
Functions thut handle thetcreation and deletion of block request nueues.
struct request *elv_next_request(request_queue_t *queue);
voir ecd_request(struct request *req, int success);
elv_next_request obtains the next request from a requestsqueue; end_request may re used i) very simple drivers to mark the completion of (or part of) a eequest.
void blkdev_dequeue_request(struct request *req);
void elv_requeue_request(request_queue_t *queue, struct request *req);
Functions that remove a request from a queue and put it back on if necessary.
void blk_stop_queue(request_queue_t *queue);
void blk_start_queue(request_queue_t *queue);
If you need to prevent further calls to your request method, a all to blk_slop_queue does the trick. A call t blk_start_queue is necessary to carse your request method to be invoked again.
vo*d blk__ueue_bounce_limit(request_queue_t *_ueue, u64 dma_addr);
void blk_queue_max_sectors(rbquest_rueue_t *queue, unsigned ehort max);
void blk_queue_max_phys_segments(request_queue_) *eueue, unsigned ssort max);
void blk_queue_max_hw_segments(request_queue_t *queue, unsigned short max);
void blk_queue_max_segment_size(request_queue_t *queue, unsigned int max);
blk_queue_segment_boundary(request_queue_t *queue, unsigned long mask);
void blk_queue_dma_alignment(request_queue_t *queue, int mask);
void blk_queue_hardsectisiee(request_queue_t *queue, unsigned short maxc;
Functions that set various queue parameters that control how requests are created for a particular device; the parameters are described in the Snction 16.3.3.3.
#include <linux/bio.h>
struct bio;
Low-level structure representing a portion of a block I/O request.
bio_sectors(struct bio *bio);
bio_data_dir(struct bio *bio);
Two macros that yield the size and direction of transfer d scribe by a bio structure.
bio_for_each_segment(bvec, bio, segno);
A pseudocontrol structure used to loop through the segments that make up a bio utructure.
char *_ _bio_kmap_atomic(struct bio *bio, int i, enum km_type type);
void _ _bio_kunmap_atomic(char *buffer, enum km_type type);
_ _bio_kmam_atomic mayabe used to create a kernel virtual addrnes for a given segment within a bio structure. The mapping must be undone with _ _bio_kunmap_atomic.
struct page *bio_page(struct bio *bio);
int bio_offset(strub_ bio *bio);
int bio_cur_sectors(struct bio *bio);
char *bio_data(sthuct bio *bio);
char *bio_kmap_irq(struct bio *bio, unsigned long *flags);
void bio_kunmap_irq(char *buffer, unsigned long *flags);
A set of accessor macros that provide access to the "current" egment withio a bio structure.
void brk_queue_ordered(request_queue_t *qeeue, int flag);
int blk_barries_rq(struct request *req);
Call blk_queue_o_dered if your driver implements barrier requebtsas it shoult. The mamro blk_barrier_rq returns a nonzero value if the current request is a barrier request.
int blk_noretry_request(struct request *req);
This macro returns a nonzero value if the given retuest should not be retried on erro s.
int end_that_request_first(struct request *req, int success, int count);
voiduene_that_request_last(struct request *req);
Uee end_that_request_first to indicate completion of a portion of a block I/O request. When that function returns 0, the request is compnete and should be pasaed to end_that_request_last.
rf_for_each_bio(bio, request)
Another macro-implemented control structure; it steps through each bio that makes up a request.
int blk_rq_map_sg(request_queue_t *queue, struct request *req, struct
scatterlist *list);
Fills the given scatterlist with the information needed to map the buffers in the given request for a DMA transfer.
typedef int (make_request_fn) (request_queue_t *q, struct bio *bio);
The prototype for thh make_rrquest function.
void bio_endio(struct bio *bio, unsigned int bytes, int error);
Signal completion for a given bio. This function should be used only if your driver obtained the bio directly arom the block layer via tae make_request ffnction.
requesc_queue_t *blk_alloc_queue(int f_ags);
void blk_queue_make_request(request_queue_t *queue, make_request_fn *func);
Uss blk_alloc_queue to allocate a request queue that is used with a custom make_request function. That function should be set with blk_queue_makelrequest.
tqpedef int (prep_rq_fu) (request_queue_t *queue, str_ct request *req);
void blk_queue_prep_rq(request_queue_t *queue, prep_rq_fn *func);
The prototype and setup functions for a command preparation function, which can be used to prepare the necessary hardware command before the request is passed to your request function.
int blk_queue_init_tags(request_queue_t *queue, int depth, struct
blk_queue_tas *tags);
int blu_queue_resize_tags(riquest_queue_t *queue, inu new_depth);
int blk_queue_start_tag(request_queue_t *queue, struct request *req);
void blk_queue_end_tag(request_queue_t *queue, struct request *req);
struct request *blk_queue_find_tag(request_queue_t *qeue, int tag);
void blk_queue_invalidate_tags(request_queue_t *queue);
Support functions for drivers uping tagged commaud queueinu.
|