diff mbox series

[1/1] blk-mq: do not reset plug->rq_count before the list is sorted

Message ID 1554346664-24038-1-git-send-email-dongli.zhang@oracle.com (mailing list archive)
State New, archived
Headers show
Series [1/1] blk-mq: do not reset plug->rq_count before the list is sorted | expand

Commit Message

Dongli Zhang April 4, 2019, 2:57 a.m. UTC
We would never be able to sort the list if we first reset plug->rq_count
which is used in conditional check later.

Fixes: ce5b009cff19 ("block: improve logic around when to sort a plug list")
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 block/blk-mq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ming Lei April 4, 2019, 6:53 a.m. UTC | #1
On Thu, Apr 4, 2019 at 10:54 AM Dongli Zhang <dongli.zhang@oracle.com> wrote:
>
> We would never be able to sort the list if we first reset plug->rq_count
> which is used in conditional check later.
>
> Fixes: ce5b009cff19 ("block: improve logic around when to sort a plug list")
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
>  block/blk-mq.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 3ff3d7b..c162718 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1711,11 +1711,12 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
>         unsigned int depth;
>
>         list_splice_init(&plug->mq_list, &list);
> -       plug->rq_count = 0;
>
>         if (plug->rq_count > 2 && plug->multiple_queues)
>                 list_sort(NULL, &list, plug_rq_cmp);
>
> +       plug->rq_count = 0;
> +
>         this_q = NULL;
>         this_hctx = NULL;
>         this_ctx = NULL;
> --
> 2.7.4
>

Reviewed-by: Ming Lei <ming.lei@redhat.com>

Thanks,
Ming Lei
Jens Axboe April 4, 2019, 2:37 p.m. UTC | #2
On 4/3/19 8:57 PM, Dongli Zhang wrote:
> We would never be able to sort the list if we first reset plug->rq_count
> which is used in conditional check later.

Well, that was pretty stupid. Thanks for the patch, applied.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 3ff3d7b..c162718 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1711,11 +1711,12 @@  void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
 	unsigned int depth;
 
 	list_splice_init(&plug->mq_list, &list);
-	plug->rq_count = 0;
 
 	if (plug->rq_count > 2 && plug->multiple_queues)
 		list_sort(NULL, &list, plug_rq_cmp);
 
+	plug->rq_count = 0;
+
 	this_q = NULL;
 	this_hctx = NULL;
 	this_ctx = NULL;