@@ -1242,30 +1242,12 @@ static inline void nullb_handle_zoned(struct nullb_cmd *cmd)
}
}
-static blk_status_t null_handle_cmd(struct nullb_cmd *cmd)
+static inline void nullb_handle_cmd_completion(struct nullb_cmd *cmd)
{
- struct nullb_device *dev = cmd->nq->dev;
- blk_status_t sts;
- int err = 0;
-
- sts = null_handle_throttled(cmd);
- if (sts != BLK_STS_OK)
- return sts;
-
- sts = null_handle_badblocks(cmd);
- if (sts != BLK_STS_OK)
- goto out;
-
- err = nullb_handle_memory_backed(cmd);
- cmd->error = errno_to_blk_status(err);
-
- if (!cmd->error && dev->zoned)
- nullb_handle_zoned(cmd);
-out:
/* Complete IO by inline, softirq or timer */
- switch (dev->irqmode) {
+ switch (cmd->nq->dev->irqmode) {
case NULL_IRQ_SOFTIRQ:
- switch (dev->queue_mode) {
+ switch (cmd->nq->dev->queue_mode) {
case NULL_Q_MQ:
blk_mq_complete_request(cmd->rq);
break;
@@ -1284,6 +1266,29 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd)
null_cmd_end_timer(cmd);
break;
}
+}
+
+static blk_status_t null_handle_cmd(struct nullb_cmd *cmd)
+{
+ struct nullb_device *dev = cmd->nq->dev;
+ blk_status_t sts;
+ int err = 0;
+
+ sts = null_handle_throttled(cmd);
+ if (sts != BLK_STS_OK)
+ return sts;
+
+ sts = null_handle_badblocks(cmd);
+ if (sts != BLK_STS_OK)
+ goto out;
+
+ err = nullb_handle_memory_backed(cmd);
+ cmd->error = errno_to_blk_status(err);
+
+ if (!cmd->error && dev->zoned)
+ nullb_handle_zoned(cmd);
+out:
+ nullb_handle_cmd_completion(cmd);
return BLK_STS_OK;
}
This patch creates a helper function for handling the request completion in the null_handle_cmd(). Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> --- drivers/block/null_blk_main.c | 47 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 21 deletions(-)