bug fix in dio handling write error
PATCH 1/1 bug fix in dio handling write error
There is a bug in direct-io on propagating write error up to the higher I/O layer. When performing an async ODIRECT write to a block device, if a device error occurred (like media error or disk is pulled), the error code is only propagated from device driver to the DIO layer. The error code stops at finished_one_bio(). The aysnc write, however, is supposedly have a corresponding AIO event with appropriate return code (in this case -EIO). Application which waits on the async write event, will hang forever since such AIO event is lost forever (if such app did not use the timeout option in io_getevents call. Regardless, an AIO event is lost).
The problem is that calls to aio_complete() is conditioned upon READ, but it should've handle WRITE error as well.
fs/direct-io.c renamed from fs/direct-io.c.orig +1 -2
@@ -253,8 +253,7 @@ static void finished_one_bio(struct diodio_complete (dio, offset, transferred);/* Complete AIO later if falling back to buffered i/o */ -if (dio->result == dio->size || - ((dio->rw ==READ ) && dio->result)) { +if (dio->result == dio->size || dio->result) {aio_complete (dio->iocb, transferred,0 );kfree (dio);return ;
Quoted 23 lines · Kenneth W
There is a bug in direct-io on propagating write error up to the higher I/O layer. When performing an async ODIRECT write to a block device, if a device error occurred (like media error or disk is pulled), the error code is only propagated from device driver to the DIO layer. The error code stops at
finished_one_bio(). The aysnc write, however, is supposedly have a corresponding AIO event with appropriate return code (in this case-EIO). Application which waits on the async write event, will hang forever since such AIO event is lost forever (if such app did not use the timeout option inio_geteventscall. Regardless, an AIO event is lost).The problem is that calls to
aio_complete()is conditioned upon READ, but it should've handle WRITE error as well.Signed-off-by Ken Chen <[email protected]>
fs/direct-io.c static void finished_one_bio(struct dio · line 259
Quoted 9 lines
fs/direct-io.c renamed from fs/direct-io.c.orig +1
-2@@ -253,8 +253,7 @@ static void finished_one_bio(struct diodio_complete (dio, offset, transferred);/* Complete AIO later if falling back to buffered i/o */ -if (dio->result == dio->size || - ((dio->rw ==READ ) && dio->result)) { +if (dio->result == dio->size || dio->result) {aio_complete (dio->iocb, transferred,0 );kfree (dio);return ;
I vaguely remember adding the explicit "dio->rw == READ" check for a reason (which escapes me right now). Suparna, do you remember ? Let me think and get back to you.
Thanks,
Badari