Skip to content

Commit

Permalink
[PATCH] aio: avoid extra aio_{read,write} call when ki_left == 0
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Zach Brown <[email protected]>
Signed-off-by: Benjamin LaHaise <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Zach Brown authored and Linus Torvalds committed Sep 30, 2005
1 parent 897f15f commit 353fb07
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ static ssize_t aio_pread(struct kiocb *iocb)
* regular files we retry till we complete the entire read or
* find that we can't read any more data (e.g short reads).
*/
} while (ret > 0 &&
} while (ret > 0 && iocb->ki_left > 0 &&
!S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode));

/* This means we must have transferred all that we could */
Expand All @@ -1371,7 +1371,7 @@ static ssize_t aio_pwrite(struct kiocb *iocb)
iocb->ki_buf += ret;
iocb->ki_left -= ret;
}
} while (ret > 0);
} while (ret > 0 && iocb->ki_left > 0);

if ((ret == 0) || (iocb->ki_left == 0))
ret = iocb->ki_nbytes - iocb->ki_left;
Expand Down

0 comments on commit 353fb07

Please sign in to comment.