Feature #4637
open027: Request queues init/cleanup
0%
Description
Correct use of request queues for block devices¶
DESCRIPTION¶
To avoid resource leakage request queues should be deactivated and released. If initialization of request queue (`struct request_queue`) was done by `blk_init_queue()` function, then for the deletion it is required to call `blk_cleanup_queue()`.
EXAMPLE¶
Correct usage example:
struct gendisk* gd;
int init_module()
{
...
gd=alloc_disk(32 /*the number of minor devices*/);
//further initialization of gendisk
gd->first_minor=0;
...
//initialization of request queue
Queue = blk_init_queue(sbd_request /*request handler for new added tasks*/, &lock_point /*spinlock_t* */);
if (Queue == NULL) goto out;
blk_queue_hardsect_size(Queue, HARD_SECT_SIZE);
//request queue activation
gd->queue=Queue;
}
void module_exit()
{
...
//ending work and releasing gendisk resources
del_gendisk(gd); //switch off object
//Note: it also deactivates request queue gd->queue
put_disk(gd); //free memory
//deactivation and releasing request queue resources
blk_cleanup_queue(Queue);
}
No data to display