Quick Reference
The most important functions and macros used in writing block drivers
are summarized here. To save space, however, we do not list the
fields of struct request, struct buffer_head, or struct genhd, and we omit
the predefined ioctl commands.
-
#include <linux/fs.h>,int register_blkdev(unsigned int major, const char *name, struct block_device_operations *bdops);,int unregister_blkdev(unsigned int major, const char *name); These functions are in charge of device registration in the module’s initialization function and device removal in the cleanup function.
-
#include <linux/blkdev.h>,blk_init_queue(request_queue_t *queue, request_fn_proc *request);,blk_cleanup_queue(request_queue_t *queue); The first function initializes a queue and establishes the request function; the second is used at cleanup time.
-
BLK_DEFAULT_QUEUE(major) This macro returns a default I/O request queue for a given major number.
-
struct blk_dev_struct blk_dev[MAX_BLKDEV]; This array is used by the kernel to find the proper queue for a given request.
-
int read_ahead[];,int max_readahead[][]; read_aheadcontains block-level read-ahead values for every major number. A value of 8 is reasonable for devices like hard disks; the value should be greater for slower media.max_readaheadcontains filesystem-level read-ahead values for every major and minor number, and is not usually changed from the system default.-
int max_sectors[][]; This array, indexed by both major and ...