Skip to content

Commit 10966fa

Browse files
Christoph Hellwigaxboe
authored andcommitted
mtip32xx: merge mtip_submit_request into mtip_queue_rq
Factor out a new is_stopped helper that matches the existing is_se_active helper, and merge the trivial amount of remaining code into the only caller. This also allows better error handling by returning a BLK_STS_* directly instead of explicitly calling blk_mq_end_request, and moving blk_mq_start_request closer to the actual issue to hardware. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b5fa0e9 commit 10966fa

File tree

1 file changed

+28
-50
lines changed

1 file changed

+28
-50
lines changed

drivers/block/mtip32xx/mtip32xx.c

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,54 +3534,24 @@ static inline bool is_se_active(struct driver_data *dd)
35343534
return false;
35353535
}
35363536

3537-
/*
3538-
* Block layer make request function.
3539-
*
3540-
* This function is called by the kernel to process a BIO for
3541-
* the P320 device.
3542-
*
3543-
* @queue Pointer to the request queue. Unused other than to obtain
3544-
* the driver data structure.
3545-
* @rq Pointer to the request.
3546-
*
3547-
*/
3548-
static int mtip_submit_request(struct blk_mq_hw_ctx *hctx, struct request *rq)
3537+
static inline bool is_stopped(struct driver_data *dd, struct request *rq)
35493538
{
3550-
struct driver_data *dd = hctx->queue->queuedata;
3551-
struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
3552-
3553-
if (is_se_active(dd))
3554-
return -ENODATA;
3555-
3556-
if (unlikely(dd->dd_flag & MTIP_DDF_STOP_IO)) {
3557-
if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT,
3558-
&dd->dd_flag))) {
3559-
return -ENXIO;
3560-
}
3561-
if (unlikely(test_bit(MTIP_DDF_OVER_TEMP_BIT, &dd->dd_flag))) {
3562-
return -ENODATA;
3563-
}
3564-
if (unlikely(test_bit(MTIP_DDF_WRITE_PROTECT_BIT,
3565-
&dd->dd_flag) &&
3566-
rq_data_dir(rq))) {
3567-
return -ENODATA;
3568-
}
3569-
if (unlikely(test_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag) ||
3570-
test_bit(MTIP_DDF_REBUILD_FAILED_BIT, &dd->dd_flag)))
3571-
return -ENODATA;
3572-
}
3573-
3574-
if (req_op(rq) == REQ_OP_DISCARD) {
3575-
int err;
3539+
if (likely(!(dd->dd_flag & MTIP_DDF_STOP_IO)))
3540+
return false;
35763541

3577-
err = mtip_send_trim(dd, blk_rq_pos(rq), blk_rq_sectors(rq));
3578-
blk_mq_end_request(rq, err ? BLK_STS_IOERR : BLK_STS_OK);
3579-
return 0;
3580-
}
3542+
if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag))
3543+
return true;
3544+
if (test_bit(MTIP_DDF_OVER_TEMP_BIT, &dd->dd_flag))
3545+
return true;
3546+
if (test_bit(MTIP_DDF_WRITE_PROTECT_BIT, &dd->dd_flag) &&
3547+
rq_data_dir(rq))
3548+
return true;
3549+
if (test_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag))
3550+
return true;
3551+
if (test_bit(MTIP_DDF_REBUILD_FAILED_BIT, &dd->dd_flag))
3552+
return true;
35813553

3582-
/* Issue the read/write. */
3583-
mtip_hw_submit_io(dd, rq, cmd, hctx);
3584-
return 0;
3554+
return false;
35853555
}
35863556

35873557
static bool mtip_check_unal_depth(struct blk_mq_hw_ctx *hctx,
@@ -3647,8 +3617,9 @@ static blk_status_t mtip_issue_reserved_cmd(struct blk_mq_hw_ctx *hctx,
36473617
static blk_status_t mtip_queue_rq(struct blk_mq_hw_ctx *hctx,
36483618
const struct blk_mq_queue_data *bd)
36493619
{
3620+
struct driver_data *dd = hctx->queue->queuedata;
36503621
struct request *rq = bd->rq;
3651-
int ret;
3622+
struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
36523623

36533624
mtip_init_cmd_header(rq);
36543625

@@ -3658,12 +3629,19 @@ static blk_status_t mtip_queue_rq(struct blk_mq_hw_ctx *hctx,
36583629
if (unlikely(mtip_check_unal_depth(hctx, rq)))
36593630
return BLK_STS_RESOURCE;
36603631

3632+
if (is_se_active(dd) || is_stopped(dd, rq))
3633+
return BLK_STS_IOERR;
3634+
36613635
blk_mq_start_request(rq);
36623636

3663-
ret = mtip_submit_request(hctx, rq);
3664-
if (likely(!ret))
3665-
return BLK_STS_OK;
3666-
return BLK_STS_IOERR;
3637+
if (req_op(rq) == REQ_OP_DISCARD) {
3638+
if (mtip_send_trim(dd, blk_rq_pos(rq), blk_rq_sectors(rq)) < 0)
3639+
return BLK_STS_IOERR;
3640+
} else {
3641+
mtip_hw_submit_io(dd, rq, cmd, hctx);
3642+
}
3643+
3644+
return BLK_STS_OK;
36673645
}
36683646

36693647
static void mtip_free_cmd(struct blk_mq_tag_set *set, struct request *rq,

0 commit comments

Comments
 (0)