- 论坛徽章:
- 0
|
如果queue为空,则blk_run_queue,中会设置queue为UNPLUG,这样就没有3ms后的数据写入设备的timer了。
所以在如果想往queue中添加request需要先打开timer,这样3ms过后数据才会被timer调用的__generic_unplug_device内核线程写入设备。
NOTE:如果不开启设备queue的plug(即不调用blk_plug_device),直接调用add_request,那么requset,将永远保留在queue中不会刷新到设备中。
- //从队列中移除被插入的请求,表示要队列中的请求都写入设备
- //Return Value:0表示前一个状态是未插入,1表示前一个状态是插入
- /*
- * remove the queue from the plugged list, if present. called with
- * queue lock held and interrupts disabled.
- */
- int blk_remove_plug(request_queue_t *q)
- {
- WARN_ON(!irqs_disabled());
-
- if (!test_and_clear_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags)) //清楚队列plug状态,如果之前是unplug状态直接返回0,因为此时至准没有unplug的timer被设置
- return 0;
- del_timer(&q->unplug_timer); //如果前一个状态是插入状态,那么一定为设置在3ms后unplug队列的计时器,所以这里删除定时器,防止队列unplug(防止队列把数据写入磁盘)
- return 1;
- }
复制代码
一般blk_remove_plug会和__generic_unplug_device一起只用,用来往设备上刷新request。
|
|