All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kemeng Shi <shikemeng@huaweicloud.com>
To: axboe@kernel.dk, dwagner@suse.de, hare@suse.de,
	ming.lei@redhat.com, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: hch@lst.de, john.garry@huawei.com, jack@suse.cz
Subject: [PATCH v2 06/13] blk-mq: remove unncessary error count and flush in blk_mq_plug_issue_direct
Date: Wed,  4 Jan 2023 22:22:52 +0800	[thread overview]
Message-ID: <20230104142259.2673013-7-shikemeng@huaweicloud.com> (raw)
In-Reply-To: <20230104142259.2673013-1-shikemeng@huaweicloud.com>

blk_mq_plug_issue_direct try to send a list of requests which belong to
different hctxs. Normally, we will send flush when hctx changes as there
maybe no more request for the same hctx. Besides we will send flush along
with last request in the list by set last parameter of
blk_mq_request_issue_directly.

Extra flush is needed for two cases:
1. We stop sending at middle of list, then normal flush sent after last
request of current hctx is miss.
2. Error happens at sending last request and normal flush may be lost.

In blk_mq_plug_issue_direct, we only break the list walk if we get
BLK_STS_RESOURCE or BLK_STS_DEV_RESOURCE error. We will send extra flush
for this case already.
We count error number and send extra flush if error number is non-zero
after sending all requests in list. This could cover case 2 described
above, but there are two things to improve:
1. If last request is sent successfully, error of request at middle of list
will trigger an unnecessary flush.
2. We only need error of last request instead of error number and error of
last request can be simply retrieved from ret.

Cover case 2 above by simply check ret of last request and remove
unnecessary error count and flush to improve blk_mq_plug_issue_direct.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 block/blk-mq.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index d84ce1f758ce..ba917b6b5cc1 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2687,11 +2687,10 @@ static void blk_mq_plug_issue_direct(struct blk_plug *plug, bool from_schedule)
 	struct blk_mq_hw_ctx *hctx = NULL;
 	struct request *rq;
 	int queued = 0;
-	int errors = 0;
+	blk_status_t ret;
 
 	while ((rq = rq_list_pop(&plug->mq_list))) {
 		bool last = rq_list_empty(plug->mq_list);
-		blk_status_t ret;
 
 		if (hctx != rq->mq_hctx) {
 			if (hctx)
@@ -2711,7 +2710,6 @@ static void blk_mq_plug_issue_direct(struct blk_plug *plug, bool from_schedule)
 			return;
 		default:
 			blk_mq_end_request(rq, ret);
-			errors++;
 			break;
 		}
 	}
@@ -2720,7 +2718,7 @@ static void blk_mq_plug_issue_direct(struct blk_plug *plug, bool from_schedule)
 	 * If we didn't flush the entire list, we could have told the driver
 	 * there was more coming, but that turned out to be a lie.
 	 */
-	if (errors)
+	if (ret != BLK_STS_OK)
 		blk_mq_commit_rqs(hctx, &queued, from_schedule);
 }
 
-- 
2.30.0


  parent reply	other threads:[~2023-01-04  6:24 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04 14:22 [PATCH v2 00/13] A few bugfix and cleanup patches for blk-mq Kemeng Shi
2023-01-04 14:22 ` [PATCH v2 01/13] blk-mq: avoid sleep in blk_mq_alloc_request_hctx Kemeng Shi
2023-01-08 17:55   ` Christoph Hellwig
2023-01-04 14:22 ` [PATCH v2 02/13] blk-mq: remove stale comment for blk_mq_sched_mark_restart_hctx Kemeng Shi
2023-01-08 17:55   ` Christoph Hellwig
2023-01-04 14:22 ` [PATCH v2 03/13] blk-mq: wait on correct sbitmap_queue in blk_mq_mark_tag_wait Kemeng Shi
2023-01-08 17:55   ` Christoph Hellwig
2023-01-04 14:22 ` [PATCH v2 04/13] blk-mq: Fix potential io hung for shared sbitmap per tagset Kemeng Shi
2023-01-04 14:22 ` [PATCH v2 05/13] blk-mq: remove unnecessary list_empty check in blk_mq_try_issue_list_directly Kemeng Shi
2023-01-08 17:56   ` Christoph Hellwig
2023-01-04 14:22 ` Kemeng Shi [this message]
2023-01-08 18:02   ` [PATCH v2 06/13] blk-mq: remove unncessary error count and flush in blk_mq_plug_issue_direct Christoph Hellwig
2023-01-04 14:22 ` [PATCH v2 07/13] blk-mq: remove error count and unncessary flush in blk_mq_try_issue_list_directly Kemeng Shi
2023-01-08 18:03   ` Christoph Hellwig
2023-01-04 14:22 ` [PATCH v2 08/13] blk-mq: simplify flush check in blk_mq_dispatch_rq_list Kemeng Shi
2023-01-08 18:06   ` Christoph Hellwig
2023-01-09  2:27     ` Kemeng Shi
2023-01-10  8:09       ` Christoph Hellwig
2023-01-10 12:35         ` Kemeng Shi
2023-01-04 14:22 ` [PATCH v2 09/13] blk-mq: remove unnecessary error count and " Kemeng Shi
2023-01-04 14:22 ` [PATCH v2 10/13] blk-mq: remove set of bd->last when get driver tag for next request fails Kemeng Shi
2023-01-04 14:22 ` [PATCH v2 11/13] blk-mq: remove unncessary from_schedule parameter in blk_mq_plug_issue_direct Kemeng Shi
2023-01-08 18:06   ` Christoph Hellwig
2023-01-04 14:22 ` [PATCH v2 12/13] blk-mq: use switch/case to improve readability in blk_mq_try_issue_list_directly Kemeng Shi
2023-01-04 14:22 ` [PATCH v2 13/13] blk-mq: correct stale comment of .get_budget Kemeng Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230104142259.2673013-7-shikemeng@huaweicloud.com \
    --to=shikemeng@huaweicloud.com \
    --cc=axboe@kernel.dk \
    --cc=dwagner@suse.de \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=john.garry@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.