Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

blk-mq: factor out a helper blk_mq_limit_depth()

There are no functional changes, just make code cleaner.

Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Yu Kuai and committed by
Jens Axboe
cf02d7d4 1db61b0a

+37 -25
+37 -25
block/blk-mq.c
··· 498 498 return rq_list_pop(data->cached_rqs); 499 499 } 500 500 501 + static void blk_mq_limit_depth(struct blk_mq_alloc_data *data) 502 + { 503 + struct elevator_mq_ops *ops; 504 + 505 + /* If no I/O scheduler has been configured, don't limit requests */ 506 + if (!data->q->elevator) { 507 + blk_mq_tag_busy(data->hctx); 508 + return; 509 + } 510 + 511 + /* 512 + * All requests use scheduler tags when an I/O scheduler is 513 + * enabled for the queue. 514 + */ 515 + data->rq_flags |= RQF_SCHED_TAGS; 516 + 517 + /* 518 + * Flush/passthrough requests are special and go directly to the 519 + * dispatch list, they are not subject to the async_depth limit. 520 + */ 521 + if ((data->cmd_flags & REQ_OP_MASK) == REQ_OP_FLUSH || 522 + blk_op_is_passthrough(data->cmd_flags)) 523 + return; 524 + 525 + WARN_ON_ONCE(data->flags & BLK_MQ_REQ_RESERVED); 526 + data->rq_flags |= RQF_USE_SCHED; 527 + 528 + /* 529 + * By default, sync requests have no limit, and async requests are 530 + * limited to async_depth. 531 + */ 532 + ops = &data->q->elevator->type->ops; 533 + if (ops->limit_depth) 534 + ops->limit_depth(data->cmd_flags, data); 535 + } 536 + 501 537 static struct request *__blk_mq_alloc_requests(struct blk_mq_alloc_data *data) 502 538 { 503 539 struct request_queue *q = data->q; ··· 552 516 data->ctx = blk_mq_get_ctx(q); 553 517 data->hctx = blk_mq_map_queue(data->cmd_flags, data->ctx); 554 518 555 - if (q->elevator) { 556 - /* 557 - * All requests use scheduler tags when an I/O scheduler is 558 - * enabled for the queue. 559 - */ 560 - data->rq_flags |= RQF_SCHED_TAGS; 561 - 562 - /* 563 - * Flush/passthrough requests are special and go directly to the 564 - * dispatch list. 565 - */ 566 - if ((data->cmd_flags & REQ_OP_MASK) != REQ_OP_FLUSH && 567 - !blk_op_is_passthrough(data->cmd_flags)) { 568 - struct elevator_mq_ops *ops = &q->elevator->type->ops; 569 - 570 - WARN_ON_ONCE(data->flags & BLK_MQ_REQ_RESERVED); 571 - 572 - data->rq_flags |= RQF_USE_SCHED; 573 - if (ops->limit_depth) 574 - ops->limit_depth(data->cmd_flags, data); 575 - } 576 - } else { 577 - blk_mq_tag_busy(data->hctx); 578 - } 579 - 519 + blk_mq_limit_depth(data); 580 520 if (data->flags & BLK_MQ_REQ_RESERVED) 581 521 data->rq_flags |= RQF_RESV; 582 522