Lines Matching refs:nq
19 struct nullb_queue *nq; member
150 static void put_tag(struct nullb_queue *nq, unsigned int tag) in put_tag() argument
152 clear_bit_unlock(tag, nq->tag_map); in put_tag()
154 if (waitqueue_active(&nq->wait)) in put_tag()
155 wake_up(&nq->wait); in put_tag()
158 static unsigned int get_tag(struct nullb_queue *nq) in get_tag() argument
163 tag = find_first_zero_bit(nq->tag_map, nq->queue_depth); in get_tag()
164 if (tag >= nq->queue_depth) in get_tag()
166 } while (test_and_set_bit_lock(tag, nq->tag_map)); in get_tag()
173 put_tag(cmd->nq, cmd->tag); in free_cmd()
176 static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq) in __alloc_cmd() argument
181 tag = get_tag(nq); in __alloc_cmd()
183 cmd = &nq->cmds[tag]; in __alloc_cmd()
185 cmd->nq = nq; in __alloc_cmd()
192 static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, int can_wait) in alloc_cmd() argument
197 cmd = __alloc_cmd(nq); in alloc_cmd()
202 prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE); in alloc_cmd()
203 cmd = __alloc_cmd(nq); in alloc_cmd()
210 finish_wait(&nq->wait, &wait); in alloc_cmd()
316 struct nullb_queue *nq = nullb_to_queue(nullb); in null_queue_bio() local
319 cmd = alloc_cmd(nq, 1); in null_queue_bio()
328 struct nullb_queue *nq = nullb_to_queue(nullb); in null_rq_prep_fn() local
331 cmd = alloc_cmd(nq, 0); in null_rq_prep_fn()
360 cmd->nq = hctx->driver_data; in null_queue_rq()
368 static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq) in null_init_queue() argument
371 BUG_ON(!nq); in null_init_queue()
373 init_waitqueue_head(&nq->wait); in null_init_queue()
374 nq->queue_depth = nullb->queue_depth; in null_init_queue()
381 struct nullb_queue *nq = &nullb->queues[index]; in null_init_hctx() local
383 hctx->driver_data = nq; in null_init_hctx()
384 null_init_queue(nullb, nq); in null_init_hctx()
424 static int setup_commands(struct nullb_queue *nq) in setup_commands() argument
429 nq->cmds = kzalloc(nq->queue_depth * sizeof(*cmd), GFP_KERNEL); in setup_commands()
430 if (!nq->cmds) in setup_commands()
433 tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG; in setup_commands()
434 nq->tag_map = kzalloc(tag_size * sizeof(unsigned long), GFP_KERNEL); in setup_commands()
435 if (!nq->tag_map) { in setup_commands()
436 kfree(nq->cmds); in setup_commands()
440 for (i = 0; i < nq->queue_depth; i++) { in setup_commands()
441 cmd = &nq->cmds[i]; in setup_commands()
450 static void cleanup_queue(struct nullb_queue *nq) in cleanup_queue() argument
452 kfree(nq->tag_map); in cleanup_queue()
453 kfree(nq->cmds); in cleanup_queue()
481 struct nullb_queue *nq; in init_driver_queues() local
485 nq = &nullb->queues[i]; in init_driver_queues()
487 null_init_queue(nullb, nq); in init_driver_queues()
489 ret = setup_commands(nq); in init_driver_queues()