/* We have the option of inserting the head or the tail of the queue. Typically we use the tail for new ioctls and so forth. We use the head of the queue for things like a QUEUE_FULL message from a device, or a host that is unable to accept a particular command.  */
void blk_insert_request(struct request_queue *q, struct request *rq, int at_head, void *data)
/* We have the option of inserting the head or the tail of the queue. Typically we use the tail for new ioctls and so forth. We use the head of the queue for things like a QUEUE_FULL message from a device, or a host that is unable to accept a particular command.  */
void blk_insert_request(struct request_queue *q, struct request *rq, int at_head, void *data)
{
	int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
	unsigned long flags;
	rq->cmd_type = REQ_TYPE_SPECIAL;
	rq->special = data;
	spin_lock_irqsave(q->queue_lock, flags);
	if (blk_rq_tagged(rq))
		blk_queue_end_tag(q, rq);
	drive_stat_acct(rq, 1);
	__elv_add_request(q, rq, where, 0);
	__blk_run_queue(q);
	spin_unlock_irqrestore(q->queue_lock, flags);
}