On Apr 20, 2004, at 10:00 PM, darwin-kernel-request@lists.apple.com wrote: 6. Cancelling AIO (Lamont Cranston) Message: 6 Date: Tue, 20 Apr 2004 12:02:23 -0700 (PDT) From: Lamont Cranston <lamontcranston41@yahoo.com> Subject: Cancelling AIO To: darwin-kernel@lists.apple.com I have the following code in a userland AIO test app to clean up file I/O and close a file: // cancel any pending aio requests. retval = aio_cancel( file, NULL ); if ( retval == AIO_NOTCANCELED ) { // Requests could not be cancelled. Go through the // AIO list and wait for completion. for( i = 0; i < aiocb_list_size; i++ ) { if ( !aiocb_list[i] ) continue; while( aio_error( aiocb_list[i] ) == EINPROGRESS ) continue; aio_return( aiocb_list[i] ); } } close( file ); ---------------------------------------- This code is common to file and raw disk I/O. I am having problems with raw disk I/O. I know that aio_cancel() does not work with raw disks (so the for loop will always execute), but does that mean I can't make the call at all? do you have a little sample application that shows this problem with raw disks? it should work fine. While running a series of AIO tests in which rdisks are opened and closed, eventually aio_read() and aio_write() begin to fail because aio_max_requests_per_process and aio_max_requests have been exceeded. I make sure that these are set to twice what I need via sysctl() calls. If I take out the aio_cancel() call and just run the for loop, everything works. For file I/O, do I need to call aio_return() even if requests are cancelled via aio_cancel() (i.e. should I run the for loop regardless)? yes. you need to call aio_return on cancelled requests. BTW, in your above sample, if you hit the aio_error result == EINPROGRESS case you continue but never recheck again (unless you somehow execute the for loop again). aio_suspend until the IO completes may work for you here. A simple full functioning test application showing you problem will probably result in better answers to your questions. _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.
participants (1)
-
Jerry Cottingham