diff mbox series

[V9,1/4] blk-mq: insert to hctx dispatch list when bypass_insert is true

Message ID 1543995842-20704-2-git-send-email-jianchao.w.wang@oracle.com (mailing list archive)
State New, archived
Headers show
Series blk-mq: refactor code of issue directly | expand

Commit Message

jianchao.wang Dec. 5, 2018, 7:43 a.m. UTC
We don't allow direct dispatch of anything but regular reads/writes
and insert all of non-read-write requests. However, this is not
correct for 'bypass_insert == true' case where inserting is ignored
and BLK_STS_RESOURCE is returned. The caller will fail forever.

Fix it with inserting the non-read-write request to hctx dispatch
list to avoid to involve merge and io scheduler when bypass_insert
is true.

Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
---
 block/blk-mq.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

Comments

Jens Axboe Dec. 5, 2018, 4:25 p.m. UTC | #1
On 12/5/18 12:43 AM, Jianchao Wang wrote:
> We don't allow direct dispatch of anything but regular reads/writes
> and insert all of non-read-write requests. However, this is not
> correct for 'bypass_insert == true' case where inserting is ignored
> and BLK_STS_RESOURCE is returned. The caller will fail forever.
> 
> Fix it with inserting the non-read-write request to hctx dispatch
> list to avoid to involve merge and io scheduler when bypass_insert
> is true.
> 
> Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
> ---
>  block/blk-mq.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 9005505..153af90 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1822,6 +1822,7 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
>  {
>  	struct request_queue *q = rq->q;
>  	bool run_queue = true;
> +	bool force = false;
>  
>  	/*
>  	 * RCU or SRCU read lock is needed before checking quiesced flag.
> @@ -1836,9 +1837,19 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
>  		goto insert;
>  	}
>  
> -	if (!blk_rq_can_direct_dispatch(rq) || (q->elevator && !bypass_insert))
> +	if (q->elevator && !bypass_insert)
>  		goto insert;
>  
> +	if (!blk_rq_can_direct_dispatch(rq)) {
> +		/*
> +		 * For 'bypass_insert == true' case, insert request into hctx
> +		 * dispatch list.
> +		 */
> +		if (bypass_insert)
> +			force = true;
> +		goto insert;
> +	}

Just do force = bypass_insert, no need for the if.
jianchao.wang Dec. 6, 2018, 1:12 a.m. UTC | #2
On 12/6/18 12:25 AM, Jens Axboe wrote:
> On 12/5/18 12:43 AM, Jianchao Wang wrote:
>> We don't allow direct dispatch of anything but regular reads/writes
>> and insert all of non-read-write requests. However, this is not
>> correct for 'bypass_insert == true' case where inserting is ignored
>> and BLK_STS_RESOURCE is returned. The caller will fail forever.
>>
>> Fix it with inserting the non-read-write request to hctx dispatch
>> list to avoid to involve merge and io scheduler when bypass_insert
>> is true.
>>
>> Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
>> ---
>>  block/blk-mq.c | 19 +++++++++++++++++--
>>  1 file changed, 17 insertions(+), 2 deletions(-)
>>
>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>> index 9005505..153af90 100644
>> --- a/block/blk-mq.c
>> +++ b/block/blk-mq.c
>> @@ -1822,6 +1822,7 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
>>  {
>>  	struct request_queue *q = rq->q;
>>  	bool run_queue = true;
>> +	bool force = false;
>>  
>>  	/*
>>  	 * RCU or SRCU read lock is needed before checking quiesced flag.
>> @@ -1836,9 +1837,19 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
>>  		goto insert;
>>  	}
>>  
>> -	if (!blk_rq_can_direct_dispatch(rq) || (q->elevator && !bypass_insert))
>> +	if (q->elevator && !bypass_insert)
>>  		goto insert;
>>  
>> +	if (!blk_rq_can_direct_dispatch(rq)) {
>> +		/*
>> +		 * For 'bypass_insert == true' case, insert request into hctx
>> +		 * dispatch list.
>> +		 */
>> +		if (bypass_insert)
>> +			force = true;
>> +		goto insert;
>> +	}
> 
> Just do force = bypass_insert, no need for the if.
> 

Yes, I will do it.

Thanks
Jianchao
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 9005505..153af90 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1822,6 +1822,7 @@  static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
 {
 	struct request_queue *q = rq->q;
 	bool run_queue = true;
+	bool force = false;
 
 	/*
 	 * RCU or SRCU read lock is needed before checking quiesced flag.
@@ -1836,9 +1837,19 @@  static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
 		goto insert;
 	}
 
-	if (!blk_rq_can_direct_dispatch(rq) || (q->elevator && !bypass_insert))
+	if (q->elevator && !bypass_insert)
 		goto insert;
 
+	if (!blk_rq_can_direct_dispatch(rq)) {
+		/*
+		 * For 'bypass_insert == true' case, insert request into hctx
+		 * dispatch list.
+		 */
+		if (bypass_insert)
+			force = true;
+		goto insert;
+	}
+
 	if (!blk_mq_get_dispatch_budget(hctx))
 		goto insert;
 
@@ -1849,8 +1860,12 @@  static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
 
 	return __blk_mq_issue_directly(hctx, rq, cookie, last);
 insert:
-	if (bypass_insert)
+	if (force) {
+		blk_mq_request_bypass_insert(rq, run_queue);
+		return BLK_STS_OK;
+	} else if (bypass_insert) {
 		return BLK_STS_RESOURCE;
+	}
 
 	blk_mq_sched_insert_request(rq, false, run_queue, false);
 	return BLK_STS_OK;