diff mbox series

[V3,6/6] null_blk: create a helper for req completion

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

Commit Message

Chaitanya Kulkarni Aug. 21, 2019, 6:13 a.m. UTC
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>
---
 drivers/block/null_blk_main.c | 49 +++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 22 deletions(-)

Comments

Christoph Hellwig Aug. 22, 2019, 12:59 a.m. UTC | #1
On Tue, Aug 20, 2019 at 11:13:14PM -0700, Chaitanya Kulkarni wrote:
> 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>
> ---
>  drivers/block/null_blk_main.c | 49 +++++++++++++++++++----------------
>  1 file changed, 27 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
> index 501af79bffb2..fe12ec59b3a6 100644
> --- a/drivers/block/null_blk_main.c
> +++ b/drivers/block/null_blk_main.c
> @@ -1202,6 +1202,32 @@ static inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd,
>  	return sts;
>  }
>  
> +static inline void nullb_handle_cmd_completion(struct nullb_cmd *cmd)

Maybe cal this nullb_complete_cmd instead?

Otherwise looks fine:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Chaitanya Kulkarni Aug. 22, 2019, 2:17 a.m. UTC | #2
On 8/21/19 5:59 PM, Christoph Hellwig wrote:
> On Tue, Aug 20, 2019 at 11:13:14PM -0700, Chaitanya Kulkarni wrote:
>> 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>
>> ---
>>   drivers/block/null_blk_main.c | 49 +++++++++++++++++++----------------
>>   1 file changed, 27 insertions(+), 22 deletions(-)
>>
>> diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
>> index 501af79bffb2..fe12ec59b3a6 100644
>> --- a/drivers/block/null_blk_main.c
>> +++ b/drivers/block/null_blk_main.c
>> @@ -1202,6 +1202,32 @@ static inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd,
>>   	return sts;
>>   }
>>   
>> +static inline void nullb_handle_cmd_completion(struct nullb_cmd *cmd)
> Maybe cal this nullb_complete_cmd instead?

Okay.

Jens do you want me to send new series with above fix or it can be done

at the time of applying the patch to minimize the emails ? either way 
I'm fine.

>
> Otherwise looks fine:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
Chaitanya Kulkarni Aug. 22, 2019, 2:23 a.m. UTC | #3
Please ignore, I'll send a new version.

On 8/21/19 7:17 PM, Chaitanya Kulkarni wrote:
> On 8/21/19 5:59 PM, Christoph Hellwig wrote:
>> On Tue, Aug 20, 2019 at 11:13:14PM -0700, Chaitanya Kulkarni wrote:
>>> 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>
>>> ---
>>>    drivers/block/null_blk_main.c | 49 +++++++++++++++++++----------------
>>>    1 file changed, 27 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
>>> index 501af79bffb2..fe12ec59b3a6 100644
>>> --- a/drivers/block/null_blk_main.c
>>> +++ b/drivers/block/null_blk_main.c
>>> @@ -1202,6 +1202,32 @@ static inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd,
>>>    	return sts;
>>>    }
>>>    
>>> +static inline void nullb_handle_cmd_completion(struct nullb_cmd *cmd)
>> Maybe cal this nullb_complete_cmd instead?
> Okay.
>
> Jens do you want me to send new series with above fix or it can be done
>
> at the time of applying the patch to minimize the emails ? either way
> I'm fine.
>
>> Otherwise looks fine:
>>
>> 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 501af79bffb2..fe12ec59b3a6 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1202,6 +1202,32 @@  static inline blk_status_t null_handle_zoned(struct nullb_cmd *cmd,
 	return sts;
 }
 
+static inline void nullb_handle_cmd_completion(struct nullb_cmd *cmd)
+{
+	/* Complete IO by inline, softirq or timer */
+	switch (cmd->nq->dev->irqmode) {
+	case NULL_IRQ_SOFTIRQ:
+		switch (cmd->nq->dev->queue_mode) {
+		case NULL_Q_MQ:
+			blk_mq_complete_request(cmd->rq);
+			break;
+		case NULL_Q_BIO:
+			/*
+			 * XXX: no proper submitting cpu information available.
+			 */
+			end_cmd(cmd);
+			break;
+		}
+		break;
+	case NULL_IRQ_NONE:
+		end_cmd(cmd);
+		break;
+	case NULL_IRQ_TIMER:
+		null_cmd_end_timer(cmd);
+		break;
+	}
+}
+
 static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector,
 				    sector_t nr_sectors, enum req_opf op)
 {
@@ -1233,28 +1259,7 @@  static blk_status_t null_handle_cmd(struct nullb_cmd *cmd, sector_t sector,
 		cmd->error = null_handle_zoned(cmd, op, sector, nr_sectors);
 
 out:
-	/* Complete IO by inline, softirq or timer */
-	switch (dev->irqmode) {
-	case NULL_IRQ_SOFTIRQ:
-		switch (dev->queue_mode)  {
-		case NULL_Q_MQ:
-			blk_mq_complete_request(cmd->rq);
-			break;
-		case NULL_Q_BIO:
-			/*
-			 * XXX: no proper submitting cpu information available.
-			 */
-			end_cmd(cmd);
-			break;
-		}
-		break;
-	case NULL_IRQ_NONE:
-		end_cmd(cmd);
-		break;
-	case NULL_IRQ_TIMER:
-		null_cmd_end_timer(cmd);
-		break;
-	}
+	nullb_handle_cmd_completion(cmd);
 	return BLK_STS_OK;
 }