Commit c27d53fb authored by Bart Van Assche's avatar Bart Van Assche Committed by Jens Axboe

blk-mq: Reduce the number of if-statements in blk_mq_mark_tag_wait()

This patch does not change any functionality but makes the
blk_mq_mark_tag_wait() code slightly easier to read.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 33f782c4
...@@ -1104,15 +1104,25 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx, ...@@ -1104,15 +1104,25 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx,
struct request *rq) struct request *rq)
{ {
struct blk_mq_hw_ctx *this_hctx = *hctx; struct blk_mq_hw_ctx *this_hctx = *hctx;
bool shared_tags = (this_hctx->flags & BLK_MQ_F_TAG_SHARED) != 0;
struct sbq_wait_state *ws; struct sbq_wait_state *ws;
wait_queue_entry_t *wait; wait_queue_entry_t *wait;
bool ret; bool ret;
if (!shared_tags) { if (!(this_hctx->flags & BLK_MQ_F_TAG_SHARED)) {
if (!test_bit(BLK_MQ_S_SCHED_RESTART, &this_hctx->state)) if (!test_bit(BLK_MQ_S_SCHED_RESTART, &this_hctx->state))
set_bit(BLK_MQ_S_SCHED_RESTART, &this_hctx->state); set_bit(BLK_MQ_S_SCHED_RESTART, &this_hctx->state);
} else {
/*
* It's possible that a tag was freed in the window between the
* allocation failure and adding the hardware queue to the wait
* queue.
*
* Don't clear RESTART here, someone else could have set it.
* At most this will cost an extra queue run.
*/
return blk_mq_get_driver_tag(rq, hctx, false);
}
wait = &this_hctx->dispatch_wait; wait = &this_hctx->dispatch_wait;
if (!list_empty_careful(&wait->entry)) if (!list_empty_careful(&wait->entry))
return false; return false;
...@@ -1125,7 +1135,6 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx, ...@@ -1125,7 +1135,6 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx,
ws = bt_wait_ptr(&this_hctx->tags->bitmap_tags, this_hctx); ws = bt_wait_ptr(&this_hctx->tags->bitmap_tags, this_hctx);
add_wait_queue(&ws->wait, wait); add_wait_queue(&ws->wait, wait);
}
/* /*
* It's possible that a tag was freed in the window between the * It's possible that a tag was freed in the window between the
...@@ -1133,14 +1142,6 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx, ...@@ -1133,14 +1142,6 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx,
* queue. * queue.
*/ */
ret = blk_mq_get_driver_tag(rq, hctx, false); ret = blk_mq_get_driver_tag(rq, hctx, false);
if (!shared_tags) {
/*
* Don't clear RESTART here, someone else could have set it.
* At most this will cost an extra queue run.
*/
return ret;
} else {
if (!ret) { if (!ret) {
spin_unlock(&this_hctx->lock); spin_unlock(&this_hctx->lock);
return false; return false;
...@@ -1154,8 +1155,8 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx, ...@@ -1154,8 +1155,8 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx,
list_del_init(&wait->entry); list_del_init(&wait->entry);
spin_unlock_irq(&ws->wait.lock); spin_unlock_irq(&ws->wait.lock);
spin_unlock(&this_hctx->lock); spin_unlock(&this_hctx->lock);
return true; return true;
}
} }
bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list, bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment