[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20090415115440.AC2E.A69D9226@jp.fujitsu.com>
Date: Wed, 15 Apr 2009 11:58:54 +0900 (JST)
From: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
To: Jeff Moyer <jmoyer@...hat.com>, Zach Brown <zach.brown@...cle.com>,
Jens Axboe <jens.axboe@...cle.com>,
linux-fsdevel@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>
Cc: kosaki.motohiro@...fujitsu.com
Subject: [PATCH v4] aio: Don't inherit aio ring memory at fork
ChangeLog
since V3
- remvoe BUG_ON
- change comment properly (thanks Jeff!)
V1, V2: not posted
--------------------------------
Subject: [PATCH] aio: Don't inherit aio ring memory at fork
Currently, mm_struct::ioctx_list member isn't copyed at fork. IOW aio
context don't inherit at fork.
but only ring memory inherited. that's strange.
This patch mark DONTFORK to ring-memory too.
Reviewed-by: Jeff Moyer <jmoyer@...hat.com>
Cc: Zach Brown <zach.brown@...cle.com>
Cc: Jens Axboe <jens.axboe@...cle.com>
Cc: linux-fsdevel@...r.kernel.org
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
---
fs/aio.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
Index: b/fs/aio.c
===================================================================
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -106,6 +106,7 @@ static int aio_setup_ring(struct kioctx
unsigned nr_events = ctx->max_reqs;
unsigned long size;
int nr_pages;
+ int ret;
/* Compensate for the ring buffer's head/tail overlap entry */
nr_events += 2; /* 1 is required, 2 for good luck */
@@ -140,6 +141,18 @@ static int aio_setup_ring(struct kioctx
return -EAGAIN;
}
+ /*
+ * The io_context is not inherited by the child after fork()
+ * (see mm_init). Therefore, it makes little sense for the
+ * completion ring to be inherited.
+ */
+ ret = sys_madvise(info->mmap_base, info->mmap_size, MADV_DONTFORK);
+ if (ret < 0) {
+ up_write(&ctx->mm->mmap_sem);
+ aio_free_ring(ctx);
+ return -EAGAIN;
+ }
+
dprintk("mmap address: 0x%08lx\n", info->mmap_base);
info->nr_pages = get_user_pages(current, ctx->mm,
info->mmap_base, nr_pages,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists