--- linux-2.6.0-test6-mm2/fs/aio.c 2003-10-03 10:45:39.000000000 -0700 +++ linux-2.6.0-test6-mm2.aio/fs/aio.c 2003-10-03 11:26:26.894495149 -0700 @@ -771,12 +771,20 @@ static void __aio_run_iocbs(struct kioct struct kiocb *iocb; ssize_t ret; int count = 0; + int need_putctx; while (!list_empty(&ctx->run_list)) { iocb = list_entry(ctx->run_list.next, struct kiocb, ki_run_list); list_del(&iocb->ki_run_list); + /* + * Hold an extra reference while retrying i/o. + */ + iocb->ki_users++; /* grab extra reference */ ret = aio_run_iocb(iocb); + need_putctx = __aio_put_req(ctx, iocb); /* drop extra ref */ + if (need_putctx) + put_ioctx(ctx); count++; } aio_run++;