Skip to content

Commit a3d7d67

Browse files
ChaitanayaKulkarniaxboe
authored andcommitted
null_blk: create a helper for req completion
This patch creates a helper function for handling the request completion in the null_handle_cmd(). Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent fceb5d1 commit a3d7d67

1 file changed

Lines changed: 27 additions & 22 deletions

File tree

‎drivers/block/null_blk_main.c‎

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,32 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd,
11821182
return errno_to_blk_status(err);
11831183
}
11841184

1185+
static inline void nullb_complete_cmd(struct nullb_cmd *cmd)
1186+
{
1187+
/* Complete IO by inline, softirq or timer */
1188+
switch (cmd->nq->dev->irqmode) {
1189+
case NULL_IRQ_SOFTIRQ:
1190+
switch (cmd->nq->dev->queue_mode) {
1191+
case NULL_Q_MQ:
1192+
blk_mq_complete_request(cmd->rq);
1193+
break;
1194+
case NULL_Q_BIO:
1195+
/*
1196+
* XXX: no proper submitting cpu information available.
1197+
*/
1198+
end_cmd(cmd);
1199+
break;
1200+
}
1201+
break;
1202+
case NULL_IRQ_NONE:
1203+
end_cmd(cmd);
1204+
break;
1205+
case NULL_IRQ_TIMER:
1206+
null_cmd_end_timer(cmd);
1207+
break;
1208+
}
1209+
}
1210+
11851211
static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector,
11861212
sector_t nr_sectors, enum req_opf op)
11871213
{
@@ -1213,28 +1239,7 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector,
12131239
cmd->error = null_handle_zoned(cmd, op, sector, nr_sectors);
12141240

12151241
out:
1216-
/* Complete IO by inline, softirq or timer */
1217-
switch (dev->irqmode) {
1218-
case NULL_IRQ_SOFTIRQ:
1219-
switch (dev->queue_mode) {
1220-
case NULL_Q_MQ:
1221-
blk_mq_complete_request(cmd->rq);
1222-
break;
1223-
case NULL_Q_BIO:
1224-
/*
1225-
* XXX: no proper submitting cpu information available.
1226-
*/
1227-
end_cmd(cmd);
1228-
break;
1229-
}
1230-
break;
1231-
case NULL_IRQ_NONE:
1232-
end_cmd(cmd);
1233-
break;
1234-
case NULL_IRQ_TIMER:
1235-
null_cmd_end_timer(cmd);
1236-
break;
1237-
}
1242+
nullb_complete_cmd(cmd);
12381243
return BLK_STS_OK;
12391244
}
12401245

0 commit comments

Comments
 (0)