struct blk_dev_struct { request_fn_proc *request_fn; ... /*queue function*/ queue_proc *queue; /*request queue*/ struct request *current_request; struct request plug; ... };
When the kernel needs to spawn an I/O operation, it calls the blk_dev[dev_major].request_fn, where device_major is the major number of the device. ll_rw_block() is used to request a number of buffers from the block device or to write a number of buffers into the block device. ll_rw_block() queues the request structure into the corresponding device queue. The device queue can be mentioned by the queue function of the device. Since there are only a fixed number of request structures, if ll_rw_block() does not find any free request structures, it blocks till it gets a free request structure.
Plug: A plug request in blk_dev_struct is used to ``plug'' the device. A device is plugged to force the transfer to start only after we have put all the requests on the list. The request function, corresponding to the major number of the block device, is not called until the plug is removed. This allows clustering of adjacent blocks to speed up disk transfers.