Skip to content

Commit b640201

Browse files
Damien Le Moalaxboe
authored andcommitted
block: null_blk: cleanup null_queue_rq()
Use a local struct request pointer variable to avoid having to dereference struct blk_mq_queue_data multiple times. While at it, also fix the function argument indentation and remove a useless "else" after a return. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Pankaj Raghav <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 63f8865 commit b640201

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

drivers/block/null_blk/main.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,12 +1657,13 @@ static enum blk_eh_timer_return null_timeout_rq(struct request *rq)
16571657
}
16581658

16591659
static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
1660-
const struct blk_mq_queue_data *bd)
1660+
const struct blk_mq_queue_data *bd)
16611661
{
1662-
struct nullb_cmd *cmd = blk_mq_rq_to_pdu(bd->rq);
1662+
struct request *rq = bd->rq;
1663+
struct nullb_cmd *cmd = blk_mq_rq_to_pdu(rq);
16631664
struct nullb_queue *nq = hctx->driver_data;
1664-
sector_t nr_sectors = blk_rq_sectors(bd->rq);
1665-
sector_t sector = blk_rq_pos(bd->rq);
1665+
sector_t nr_sectors = blk_rq_sectors(rq);
1666+
sector_t sector = blk_rq_pos(rq);
16661667
const bool is_poll = hctx->type == HCTX_TYPE_POLL;
16671668

16681669
might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING);
@@ -1671,38 +1672,36 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
16711672
hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
16721673
cmd->timer.function = null_cmd_timer_expired;
16731674
}
1674-
cmd->rq = bd->rq;
1675+
cmd->rq = rq;
16751676
cmd->error = BLK_STS_OK;
16761677
cmd->nq = nq;
1677-
cmd->fake_timeout = should_timeout_request(bd->rq) ||
1678-
blk_should_fake_timeout(bd->rq->q);
1678+
cmd->fake_timeout = should_timeout_request(rq) ||
1679+
blk_should_fake_timeout(rq->q);
16791680

1680-
blk_mq_start_request(bd->rq);
1681+
blk_mq_start_request(rq);
16811682

1682-
if (should_requeue_request(bd->rq)) {
1683+
if (should_requeue_request(rq)) {
16831684
/*
16841685
* Alternate between hitting the core BUSY path, and the
16851686
* driver driven requeue path
16861687
*/
16871688
nq->requeue_selection++;
16881689
if (nq->requeue_selection & 1)
16891690
return BLK_STS_RESOURCE;
1690-
else {
1691-
blk_mq_requeue_request(bd->rq, true);
1692-
return BLK_STS_OK;
1693-
}
1691+
blk_mq_requeue_request(rq, true);
1692+
return BLK_STS_OK;
16941693
}
16951694

16961695
if (is_poll) {
16971696
spin_lock(&nq->poll_lock);
1698-
list_add_tail(&bd->rq->queuelist, &nq->poll_list);
1697+
list_add_tail(&rq->queuelist, &nq->poll_list);
16991698
spin_unlock(&nq->poll_lock);
17001699
return BLK_STS_OK;
17011700
}
17021701
if (cmd->fake_timeout)
17031702
return BLK_STS_OK;
17041703

1705-
return null_handle_cmd(cmd, sector, nr_sectors, req_op(bd->rq));
1704+
return null_handle_cmd(cmd, sector, nr_sectors, req_op(rq));
17061705
}
17071706

17081707
static void cleanup_queue(struct nullb_queue *nq)

0 commit comments

Comments
 (0)