From patchwork Sat Jul 12 03:43:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 369271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E88FF1400BE for ; Sat, 12 Jul 2014 13:44:31 +1000 (EST) Received: from localhost ([::1]:47607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5oEg-0004os-1I for incoming@patchwork.ozlabs.org; Fri, 11 Jul 2014 23:44:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5oEK-0004Vt-7N for qemu-devel@nongnu.org; Fri, 11 Jul 2014 23:44:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X5oEF-0006k6-9X for qemu-devel@nongnu.org; Fri, 11 Jul 2014 23:44:08 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:57736) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5oEE-0006hq-IZ for qemu-devel@nongnu.org; Fri, 11 Jul 2014 23:44:03 -0400 Received: from 172.24.2.119 (EHLO szxeml405-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BWO80347; Sat, 12 Jul 2014 11:43:49 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml405-hub.china.huawei.com (10.82.67.60) with Microsoft SMTP Server id 14.3.158.1; Sat, 12 Jul 2014 11:43:40 +0800 From: To: Date: Sat, 12 Jul 2014 11:43:37 +0800 Message-ID: <1405136617-11184-1-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: kwolf@redhat.com, peter.maydell@linaro.org, weidong.huang@huawei.com, luonengjun@huawei.com, daifulai@huawei.com, Gonglei , stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v2 for-2.1] linux-aio: Fix laio resource leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- v2: small spelling fixes. --- 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); }