cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From e5f537a8b3821b68040eada7a964b2dd1b17d3d3 Mon Sep 17 00:00:00 2001
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Tue, 21 Nov 2017 03:21:45 +0100
9ae3a8
Subject: [PATCH 2/9] linux-aio: Fix laio resource leak
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <20171121032145.5681-3-famz@redhat.com>
9ae3a8
Patchwork-id: 77767
9ae3a8
O-Subject: [RHEL-7.5 qemu-kvm PATCH v2 2/2] linux-aio: Fix laio resource leak
9ae3a8
Bugzilla: 1491434
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: John Snow <jsnow@redhat.com>
9ae3a8
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
9ae3a8
9ae3a8
From: Gonglei <arei.gonglei@huawei.com>
9ae3a8
9ae3a8
when hotplug virtio-scsi disks using laio, the aio_nr will
9ae3a8
increase in laio_init() by io_setup(), we can see the number by
9ae3a8
  # cat /proc/sys/fs/aio-nr
9ae3a8
  128
9ae3a8
if the aio_nr attach the maxnum, which found from
9ae3a8
  # cat /proc/sys/fs/aio-max-nr
9ae3a8
  65536
9ae3a8
the hotplug process will fail because of aio context leak.
9ae3a8
9ae3a8
Fix it by io_destroy in laio_cleanup().
9ae3a8
9ae3a8
Reported-by: daifulai <daifulai@huawei.com>
9ae3a8
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit a1abf40d6be2fc4b40d90ae3b46442f4a671776b)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	block/linux-aio.c
9ae3a8
9ae3a8
Contextual conflict because of the previous patch's necessary deviation
9ae3a8
from upstream.
9ae3a8
---
9ae3a8
 block/linux-aio.c | 5 +++++
9ae3a8
 1 file changed, 5 insertions(+)
9ae3a8
9ae3a8
diff --git a/block/linux-aio.c b/block/linux-aio.c
9ae3a8
index 43f14f3..e1d2593 100644
9ae3a8
--- a/block/linux-aio.c
9ae3a8
+++ b/block/linux-aio.c
9ae3a8
@@ -232,5 +232,10 @@ void laio_cleanup(void *s_)
9ae3a8
 
9ae3a8
     qemu_aio_set_fd_handler(s->efd, NULL, NULL, NULL, NULL);
9ae3a8
     close(s->efd);
9ae3a8
+
9ae3a8
+    if (io_destroy(s->ctx) != 0) {
9ae3a8
+        fprintf(stderr, "%s: destroy AIO context %p failed\n",
9ae3a8
+                        __func__, &s->ctx);
9ae3a8
+    }
9ae3a8
     g_free(s);
9ae3a8
 }
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8