The problem is that my block driver doesn't use aphysio. I figure that
the block layer should isolate my driver from character driver entry
points (read, aread, write and awrite). In fact when I run the below
program with the delay, I only see the strategy routine getting called
(along with the open, getinfo & close).

I filled out the aread and awrite entry points with asyncio, but none of
it ever got called.

When I panic my system and the box recovers, I can see that the panic
occurred in my strategy command while accessing the passed in *struct
buf*. I assume that the aio_cancel64 de-allocated the structure and
accessing it is no longer valid.

I incorrectly said earlier that my system "hung", it doesn't hang, it
panics. FWIW.

-Adam


Garrett D'Amore wrote:
> If you read the man page for aphysio, you'll find that you have to use
> anocancel() in your driver entry point, because cancellation is not
> supported. You'll see that "sd" for example does this.
>
> - Garrett
>
> Adam Chunn wrote:
>   
>> Driver list,
>>
>> I have an issue I can't figure out. Any help would be appreciated.
>>
>> I have written a block driver that works in most cases except one:
>> using aio_cancel64 to cancel pending DMA(s).
>>
>> If I run the program below compiled with "gcc test.c", my system
>> hangs. This test is queuing 16 asynchronous DMAs to the block layer.
>> It then immediately cancels all DMAs.
>>
>> If I run the program below compiled with "gcc -DADD_DELAY=1 test.c" my
>> system does not hang. In this case the added delay is allowing all the
>> pending DMAs to complete prior to calling aio_cancel64.
>>
>> I figure I don't have some aio_cancel hook filled out in my driver. As
>> far as I can tell -- nothing like that exists. Can anyone shed light
>> on what I need to do to support aio_cancel64?
>>
>> -Adam
>>
>>
>>
>>     #define BUF_SIZE 8*1024*1024
>>     #define NUM_IOS 16
>>
>>     int main(int argc, char **argv) {
>>     struct aiocb64 aiocb[NUM_IOS];
>>     char *ptr, *buf;
>>     int fd, st, ii;
>>
>>     ptr = malloc(NUM_IOS * BUF_SIZE);
>>     memset(ptr, 0, NUM_IOS * BUF_SIZE);
>>
>>     #ifdef ADD_DELAY
>>     printf("Adding delay\n");
>>     #endif
>>
>>     fd = open("/dev/dsk/c9d0s0", O_RDWR | O_LARGEFILE | O_SYNC);
>>
>>     memset(aiocb, 0, sizeof(aiocb));
>>     buf = ptr;
>>
>>     for (ii = 0; ii < NUM_IOS; ii++) {
>>     aiocb[ii].aio_fildes = fd;
>>     aiocb[ii].aio_buf = buf;
>>     aiocb[ii].aio_offset = ii * BUF_SIZE;
>>     aiocb[ii].aio_nbytes = BUF_SIZE;
>>
>>     aio_write64(&aiocb[ii]);
>>     buf += BUF_SIZE;
>>     }
>>
>>     #ifdef ADD_DELAY
>>     sleep(2);
>>     #endif
>>
>>     aio_cancel64(fd, NULL);
>>
>>     close(fd);
>>     free(ptr);
>>
>>     return 0;
>>     }
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> driver-discuss mailing list
>> driver-discuss@opensolaris.org
>> http://mail.opensolaris.org/mailman/listinfo/driver-discuss
>>   
>>     
>
>   
_______________________________________________
driver-discuss mailing list
driver-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/driver-discuss

Reply via email to