diff mbox series

[5/5] null_blk: create a helper for req completion

Message ID 20190629050442.8459-6-chaitanya.kulkarni@wdc.com (mailing list archive)
State New, archived
Headers show
Series null_blk: simplify null_handle_cmd() | expand

Commit Message

Chaitanya Kulkarni June 29, 2019, 5:04 a.m. UTC
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(-)

Comments

Christoph Hellwig July 1, 2019, 6:31 a.m. UTC | #1
On Fri, Jun 28, 2019 at 10:04:42PM -0700, Chaitanya Kulkarni wrote:
> 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>

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 824392681a28..c5343d514c66 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -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;
 }