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

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