History

[PATCH] aio: avoid extra aio_{read,write} call when ki_left == 0

Recently aio_p{read,write} changed to perform retries internally rather than returning -EIOCBRETRY. This inadvertantly resulted in always calling aio_{read,write} with ki_left at 0 which would in turn immediately return 0. Harmless, but we can avoid this call by checking in the caller.

Zach Brown committed 21 years ago

Commit 353fb071 parent 897f15f1 file · +2 −2Browse files

Unified · Split

fs/aio.c+2−2
@@ -1347,7 +1347,7 @@ static ssize_t aio_pread(struct kiocb *iocb) · 1346 unmodified lines
13471347 * regular files we retry till we complete the entire read or
13481348 * find that we can't read any more data (e.g short reads).
13491349 */
1350− } while (ret > 0 &&
1350+ } while (ret > 0 && iocb->ki_left > 0 &&
13511351 !S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode));
13521352
13531353 /* This means we must have transferred all that we could */
@@ -1371,7 +1371,7 @@ static ssize_t aio_pwrite(struct kiocb *iocb) · 17 unmodified lines
13711371 iocb->ki_buf += ret;
13721372 iocb->ki_left -= ret;
13731373 }
1374− } while (ret > 0);
1374+ } while (ret > 0 && iocb->ki_left > 0);
13751375
13761376 if ((ret == 0) || (iocb->ki_left == 0))
13771377 ret = iocb->ki_nbytes - iocb->ki_left;