--- .pc/io_setup-ctx.patch/fs/aio.c 2004-10-14 12:58:40 -07:00 +++ fs/aio.c 2004-10-14 12:58:40 -07:00 @@ -101,13 +101,14 @@ static void aio_free_ring(struct kioctx info->nr = 0; } -static int aio_setup_ring(struct kioctx *ctx) +static int aio_setup_ring(unsigned long mmap_base, struct kioctx *ctx) { struct aio_ring *ring; struct aio_ring_info *info = &ctx->ring_info; unsigned nr_events = ctx->max_reqs; unsigned long size; int nr_pages; + int mmap_flags; /* Compensate for the ring buffer's head/tail overlap entry */ nr_events += 2; /* 1 is required, 2 for good luck */ @@ -135,8 +136,12 @@ static int aio_setup_ring(struct kioctx info->mmap_size = nr_pages * PAGE_SIZE; dprintk("attempting mmap of %lu bytes\n", info->mmap_size); down_write(&ctx->mm->mmap_sem); - info->mmap_base = do_mmap(NULL, 0, info->mmap_size, - PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, + + mmap_flags = MAP_ANON|MAP_PRIVATE; + if (mmap_base != 0) + mmap_flags |= MAP_FIXED; + info->mmap_base = do_mmap(NULL, mmap_base, info->mmap_size, + PROT_READ|PROT_WRITE, mmap_flags, 0); if (IS_ERR((void *)info->mmap_base)) { up_write(&ctx->mm->mmap_sem); @@ -200,7 +205,7 @@ static int aio_setup_ring(struct kioctx /* ioctx_alloc * Allocates and initializes an ioctx. Returns an ERR_PTR if it failed. */ -static struct kioctx *ioctx_alloc(unsigned nr_events) +static struct kioctx *ioctx_alloc(unsigned long mmap_base, unsigned nr_events) { struct mm_struct *mm; struct kioctx *ctx; @@ -233,7 +238,7 @@ static struct kioctx *ioctx_alloc(unsign INIT_LIST_HEAD(&ctx->run_list); INIT_WORK(&ctx->wq, aio_kick_handler, ctx); - if (aio_setup_ring(ctx) < 0) + if (aio_setup_ring(mmap_base, ctx) < 0) goto out_freectx; /* limit the number of system wide aios */ @@ -1278,12 +1283,12 @@ asmlinkage long sys_io_setup(unsigned nr goto out; ret = -EINVAL; - if (unlikely(ctx || (int)nr_events <= 0)) { + if (unlikely((int)nr_events <= 0)) { pr_debug("EINVAL: io_setup: ctx or nr_events > max\n"); goto out; } - ioctx = ioctx_alloc(nr_events); + ioctx = ioctx_alloc(ctx, nr_events); ret = PTR_ERR(ioctx); if (!IS_ERR(ioctx)) { ret = put_user(ioctx->user_id, ctxp);