<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: Chris Mason &lt;mason@suse.com&gt;

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
===================================================================
--- linux.aio.orig/fs/aio.c	2004-02-15 14:53:51.000000000 -0500
+++ linux.aio/fs/aio.c	2004-02-15 15:50:50.000000000 -0500
@@ -918,6 +918,13 @@
 	if (iocb-&gt;ki_run_list.prev &amp;&amp; !list_empty(&amp;iocb-&gt;ki_run_list))
 		list_del_init(&amp;iocb-&gt;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-&gt;ring_pages[0], KM_IRQ1);
 
 	tail = info-&gt;tail;
@@ -950,7 +957,7 @@
 		iocb-&gt;ki_retried,
 		iocb-&gt;ki_nbytes - iocb-&gt;ki_left, iocb-&gt;ki_nbytes,
 		iocb-&gt;ki_kicked, iocb-&gt;ki_queued, aio_run, aio_wakeups);
-
+put_rq:
 	/* everything turned out well, dispose of the aiocb. */
 	ret = __aio_put_req(ctx, iocb);
 
@@ -1604,6 +1611,7 @@
 	if (kiocb &amp;&amp; kiocb-&gt;ki_cancel) {
 		cancel = kiocb-&gt;ki_cancel;
 		kiocb-&gt;ki_users ++;
+		kiocbSetCancelled(kiocb);
 	} else
 		cancel = NULL;
 	spin_unlock_irq(&amp;ctx-&gt;ctx_lock);
</pre></body></html>