From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73Dj-000720-Ry for qemu-devel@nongnu.org; Tue, 15 Jul 2014 09:56:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X73De-0000xl-97 for qemu-devel@nongnu.org; Tue, 15 Jul 2014 09:56:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42400) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X73De-0000xh-2C for qemu-devel@nongnu.org; Tue, 15 Jul 2014 09:56:34 -0400 From: Stefan Hajnoczi Date: Tue, 15 Jul 2014 15:55:41 +0200 Message-Id: <1405432543-9121-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1405432543-9121-1-git-send-email-stefanha@redhat.com> References: <1405432543-9121-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL for-2.1 1/3] linux-aio: Fix laio resource leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell From: Gonglei when hotplug virtio-scsi disks using laio, the aio_nr will increase in laio_init() by io_setup(), we can see the number by # cat /proc/sys/fs/aio-nr 128 if the aio_nr attach the maxnum, which found from # cat /proc/sys/fs/aio-max-nr 65536 the hotplug process will fail because of aio context leak. Fix it by io_destroy in laio_cleanup(). Reported-by: daifulai Signed-off-by: Gonglei Signed-off-by: Stefan Hajnoczi --- block/linux-aio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/linux-aio.c b/block/linux-aio.c index 4867369..7ac7e8c 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -310,5 +310,10 @@ void laio_cleanup(void *s_) struct qemu_laio_state *s = s_; event_notifier_cleanup(&s->e); + + if (io_destroy(s->ctx) != 0) { + fprintf(stderr, "%s: destroy AIO context %p failed\n", + __func__, &s->ctx); + } g_free(s); } -- 1.9.3