@@ -1799,20 +1799,18 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
if (q->elevator && !bypass_insert)
goto insert;
- if (!blk_mq_get_driver_tag(rq, NULL, false))
- goto insert;
-
- if (!blk_mq_get_dispatch_budget(hctx)) {
+ if (!blk_mq_get_driver_tag(rq, NULL, false) ||
+ !blk_mq_get_dispatch_budget(hctx)) {
+ /* blk_mq_put_driver_tag() is idempotent */
blk_mq_put_driver_tag(rq);
+ if (bypass_insert)
+ return BLK_STS_RESOURCE;
goto insert;
}
return __blk_mq_issue_directly(hctx, rq, cookie);
insert:
__blk_mq_fallback_to_insert(rq, run_queue, bypass_insert);
- if (bypass_insert)
- return BLK_STS_RESOURCE;
-
return BLK_STS_OK;
}