Blame SOURCES/kvm-linux-aio-explain-why-max-batch-is-checked-in-laio_i.patch

24c150
From 0cd0c916715c43f71cf249bafa2829b42aa67267 Mon Sep 17 00:00:00 2001
24c150
From: Stefan Hajnoczi <stefanha@redhat.com>
24c150
Date: Thu, 9 Jun 2022 17:47:12 +0100
24c150
Subject: [PATCH 2/2] linux-aio: explain why max batch is checked in
24c150
 laio_io_unplug()
24c150
24c150
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
24c150
RH-MergeRequest: 210: linux-aio: fix unbalanced plugged counter in laio_io_unplug()
24c150
RH-Bugzilla: 2109569
24c150
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
24c150
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
24c150
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
24c150
RH-Acked-by: Alberto Faria <None>
24c150
RH-Commit: [2/2] caed03e006e8004d3c0670b24e4454a94274d7d9
24c150
24c150
It may not be obvious why laio_io_unplug() checks max batch. I discussed
24c150
this with Stefano and have added a comment summarizing the reason.
24c150
24c150
Cc: Stefano Garzarella <sgarzare@redhat.com>
24c150
Cc: Kevin Wolf <kwolf@redhat.com>
24c150
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24c150
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
24c150
Message-id: 20220609164712.1539045-3-stefanha@redhat.com
24c150
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24c150
(cherry picked from commit 99b969fbe105117f5af6060d3afef40ca39cc9c1)
24c150
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24c150
---
24c150
 block/linux-aio.c | 6 ++++++
24c150
 1 file changed, 6 insertions(+)
24c150
24c150
diff --git a/block/linux-aio.c b/block/linux-aio.c
24c150
index 77f17ad596..85650c4222 100644
24c150
--- a/block/linux-aio.c
24c150
+++ b/block/linux-aio.c
24c150
@@ -362,6 +362,12 @@ void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
24c150
     assert(s->io_q.plugged);
24c150
     s->io_q.plugged--;
24c150
 
24c150
+    /*
24c150
+     * Why max batch checking is performed here:
24c150
+     * Another BDS may have queued requests with a higher dev_max_batch and
24c150
+     * therefore in_queue could now exceed our dev_max_batch. Re-check the max
24c150
+     * batch so we can honor our device's dev_max_batch.
24c150
+     */
24c150
     if (s->io_q.in_queue >= laio_max_batch(s, dev_max_batch) ||
24c150
         (!s->io_q.plugged &&
24c150
          !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending))) {
24c150
-- 
24c150
2.31.1
24c150