Chapter 6: Device Drivers
RequestQueues
Read and write requests to block devices are placed on a queue known as arequest queue.Thegendisk
structure includes a pointer to the device-specific queue, which is represented by the following data type.
<blkdev.h>
struct request_queue
{
/*
* Together with queue_head for cacheline sharing
*/
struct list_head queue_head;
struct list_head *last_merge;
elevator_t elevator;
struct request_list rq; /* Queue request freelists */
request_fn_proc *request_fn;
make_request_fn *make_request_fn;
prep_rq_fn *prep_rq_fn;
unplug_fn *unplug_fn;
merge_bvec_fn *merge_bvec_fn;
prepare_flush_fn *prepare_flush_fn;
softirq_done_fn *softirq_done_fn;
...
/*
* Auto-unplugging state
*/
struct timer_list unplug_timer;
int unplug_thresh; /* After this many requests */
unsigned long unplug_delay; /* After this many jiffies */
struct work_struct unplug_work;
struct backing_dev_info backing_dev_info;
...
/* queue needs bounce pages for pages above this limit */
unsigned long bounce_pfn;
int bounce_gfp;
unsigned long queue_flags;
/* queue settings */
unsigned long nr_requests; /* Max # of requests */
unsigned int nr_congestion_on;
unsigned int nr_congestion_off;
unsigned int nr_batching;
unsigned short max_sectors;
unsigned short max_hw_sectors;
unsigned short max_phys_segments;
unsigned short max_hw_segments;
unsigned short hardsect_size;
unsigned int max_segment_size;
};