From: Chris Mason Fix for sys_io_cancel to work properly with retries when a cancel method is specified for an iocb. Needed with pipe AIO support. There's a bug in my aio cancel patch, aio_complete still makes an event for cancelled iocbs. If nobody asks for this event, we effectively leak space in the event ring buffer. I've attached a new aio_cancel patch that just skips the event creation for canceled iocbs. aio.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletion(-) Index: linux.aio/fs/aio.c diff -upN reference/fs/aio.c current/fs/aio.c --- reference/fs/aio.c 2004-04-29 10:39:24.000000000 -0700 +++ current/fs/aio.c 2004-04-29 10:39:24.000000000 -0700 @@ -938,6 +938,13 @@ int fastcall aio_complete(struct kiocb * if (iocb->ki_run_list.prev && !list_empty(&iocb->ki_run_list)) list_del_init(&iocb->ki_run_list); + /* + * cancelled requests don't get events, userland was given one + * when the event got cancelled. + */ + if (kiocbIsCancelled(iocb)) + goto put_rq; + ring = kmap_atomic(info->ring_pages[0], KM_IRQ1); tail = info->tail; @@ -970,7 +977,7 @@ int fastcall aio_complete(struct kiocb * iocb->ki_retried, iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes, iocb->ki_kicked, iocb->ki_queued, aio_run, aio_wakeups); - +put_rq: /* everything turned out well, dispose of the aiocb. */ ret = __aio_put_req(ctx, iocb); @@ -1636,6 +1643,7 @@ asmlinkage long sys_io_cancel(aio_contex if (kiocb && kiocb->ki_cancel) { cancel = kiocb->ki_cancel; kiocb->ki_users ++; + kiocbSetCancelled(kiocb); } else cancel = NULL; spin_unlock_irq(&ctx->ctx_lock);