Lines Matching refs:nq
20 struct nullb_queue *nq; member
147 static void put_tag(struct nullb_queue *nq, unsigned int tag) in put_tag() argument
149 clear_bit_unlock(tag, nq->tag_map); in put_tag()
151 if (waitqueue_active(&nq->wait)) in put_tag()
152 wake_up(&nq->wait); in put_tag()
155 static unsigned int get_tag(struct nullb_queue *nq) in get_tag() argument
160 tag = find_first_zero_bit(nq->tag_map, nq->queue_depth); in get_tag()
161 if (tag >= nq->queue_depth) in get_tag()
163 } while (test_and_set_bit_lock(tag, nq->tag_map)); in get_tag()
170 put_tag(cmd->nq, cmd->tag); in free_cmd()
175 static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq) in __alloc_cmd() argument
180 tag = get_tag(nq); in __alloc_cmd()
182 cmd = &nq->cmds[tag]; in __alloc_cmd()
184 cmd->nq = nq; in __alloc_cmd()
196 static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, int can_wait) in alloc_cmd() argument
201 cmd = __alloc_cmd(nq); in alloc_cmd()
206 prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE); in alloc_cmd()
207 cmd = __alloc_cmd(nq); in alloc_cmd()
214 finish_wait(&nq->wait, &wait); in alloc_cmd()
314 struct nullb_queue *nq = nullb_to_queue(nullb); in null_queue_bio() local
317 cmd = alloc_cmd(nq, 1); in null_queue_bio()
327 struct nullb_queue *nq = nullb_to_queue(nullb); in null_rq_prep_fn() local
330 cmd = alloc_cmd(nq, 0); in null_rq_prep_fn()
364 cmd->nq = hctx->driver_data; in null_queue_rq()
372 static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq) in null_init_queue() argument
375 BUG_ON(!nq); in null_init_queue()
377 init_waitqueue_head(&nq->wait); in null_init_queue()
378 nq->queue_depth = nullb->queue_depth; in null_init_queue()
385 struct nullb_queue *nq = &nullb->queues[index]; in null_init_hctx() local
387 hctx->driver_data = nq; in null_init_hctx()
388 null_init_queue(nullb, nq); in null_init_hctx()
401 static void cleanup_queue(struct nullb_queue *nq) in cleanup_queue() argument
403 kfree(nq->tag_map); in cleanup_queue()
404 kfree(nq->cmds); in cleanup_queue()
587 static int setup_commands(struct nullb_queue *nq) in setup_commands() argument
592 nq->cmds = kzalloc(nq->queue_depth * sizeof(*cmd), GFP_KERNEL); in setup_commands()
593 if (!nq->cmds) in setup_commands()
596 tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG; in setup_commands()
597 nq->tag_map = kzalloc(tag_size * sizeof(unsigned long), GFP_KERNEL); in setup_commands()
598 if (!nq->tag_map) { in setup_commands()
599 kfree(nq->cmds); in setup_commands()
603 for (i = 0; i < nq->queue_depth; i++) { in setup_commands()
604 cmd = &nq->cmds[i]; in setup_commands()
628 struct nullb_queue *nq; in init_driver_queues() local
632 nq = &nullb->queues[i]; in init_driver_queues()
634 null_init_queue(nullb, nq); in init_driver_queues()
636 ret = setup_commands(nq); in init_driver_queues()