diff mbox

[v2,for-2.1] linux-aio: Fix laio resource leak

Message ID 1405136617-11184-1-git-send-email-arei.gonglei@huawei.com
State New
Headers show

Commit Message

Gonglei (Arei) July 12, 2014, 3:43 a.m. UTC
From: Gonglei <arei.gonglei@huawei.com>

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 <daifulai@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 v2: small spelling fixes.
---
 block/linux-aio.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Stefan Hajnoczi July 14, 2014, 8:12 a.m. UTC | #1
On Sat, Jul 12, 2014 at 11:43:37AM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> 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 <daifulai@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  v2: small spelling fixes.
> ---
>  block/linux-aio.c | 5 +++++
>  1 file changed, 5 insertions(+)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
diff mbox

Patch

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);
 }