blk-mq: don't handle failure in .get_budget

It is enough to just check if we can get the budget via .get_budget().
And we don't need to deal with device state change in .get_budget().

For SCSI, one issue to be fixed is that we have to call
scsi_mq_uninit_cmd() to free allocated ressources if SCSI device fails
to handle the request. And it isn't enough to simply call
blk_mq_end_request() to do that if this request is marked as
RQF_DONTPREP.

Fixes: 0df21c86bdbf(scsi: implement .get_budget and .put_budget for blk-mq)
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Ming Lei
2017-11-05 02:21:12 +08:00
committed by Jens Axboe
parent 826a70a08b
commit 88022d7201
5 changed files with 12 additions and 37 deletions

View File

@@ -1955,27 +1955,22 @@ static void scsi_mq_put_budget(struct blk_mq_hw_ctx *hctx)
put_device(&sdev->sdev_gendev);
}
static blk_status_t scsi_mq_get_budget(struct blk_mq_hw_ctx *hctx)
static bool scsi_mq_get_budget(struct blk_mq_hw_ctx *hctx)
{
struct request_queue *q = hctx->queue;
struct scsi_device *sdev = q->queuedata;
blk_status_t ret;
ret = prep_to_mq(scsi_prep_state_check(sdev, NULL));
if (ret == BLK_STS_RESOURCE || ret != BLK_STS_OK)
return ret;
if (!get_device(&sdev->sdev_gendev))
goto out;
if (!scsi_dev_queue_ready(q, sdev))
goto out_put_device;
return BLK_STS_OK;
return true;
out_put_device:
put_device(&sdev->sdev_gendev);
out:
return BLK_STS_RESOURCE;
return false;
}
static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,