Blame SOURCES/kvm-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch

24c150
From 9c5a68878b3c6ec16c94dfcfe388a830df8deb2f Mon Sep 17 00:00:00 2001
24c150
From: Stefan Hajnoczi <stefanha@redhat.com>
24c150
Date: Thu, 9 Jun 2022 17:47:11 +0100
24c150
Subject: [PATCH 1/2] linux-aio: fix unbalanced plugged counter 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: [1/2] bc1fa9b401cffb712f09935aba861d1a0bf74421
24c150
24c150
Every laio_io_plug() call has a matching laio_io_unplug() call. There is
24c150
a plugged counter that tracks the number of levels of plugging and
24c150
allows for nesting.
24c150
24c150
The plugged counter must reflect the balance between laio_io_plug() and
24c150
laio_io_unplug() calls accurately. Otherwise I/O stalls occur since
24c150
io_submit(2) calls are skipped while plugged.
24c150
24c150
Reported-by: Nikolay Tenev <nt@storpool.com>
24c150
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24c150
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
24c150
Message-id: 20220609164712.1539045-2-stefanha@redhat.com
24c150
Cc: Stefano Garzarella <sgarzare@redhat.com>
24c150
Fixes: 68d7946648 ("linux-aio: add `dev_max_batch` parameter to laio_io_unplug()")
24c150
[Stefano Garzarella suggested adding a Fixes tag.
24c150
--Stefan]
24c150
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24c150
(cherry picked from commit f387cac5af030a58ac5a0dacf64cab5e5a4fe5c7)
24c150
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24c150
---
24c150
 block/linux-aio.c | 4 +++-
24c150
 1 file changed, 3 insertions(+), 1 deletion(-)
24c150
24c150
diff --git a/block/linux-aio.c b/block/linux-aio.c
24c150
index f53ae72e21..77f17ad596 100644
24c150
--- a/block/linux-aio.c
24c150
+++ b/block/linux-aio.c
24c150
@@ -360,8 +360,10 @@ void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
24c150
                     uint64_t dev_max_batch)
24c150
 {
24c150
     assert(s->io_q.plugged);
24c150
+    s->io_q.plugged--;
24c150
+
24c150
     if (s->io_q.in_queue >= laio_max_batch(s, dev_max_batch) ||
24c150
-        (--s->io_q.plugged == 0 &&
24c150
+        (!s->io_q.plugged &&
24c150
          !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending))) {
24c150
         ioq_submit(s);
24c150
     }
24c150
-- 
24c150
2.31.1
24c150