]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] aio: avoid extra aio_{read,write} call when ki_left == 0
authorZach Brown <zach.brown@oracle.com>
Fri, 30 Sep 2005 18:58:56 +0000 (11:58 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 30 Sep 2005 19:41:17 +0000 (12:41 -0700)
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 <zach.brown@oracle.com>
Signed-off-by: Benjamin LaHaise <bcrl@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/aio.c

index 9edc0e4a12192e7addd621f2e436fc4b48a8c17b..d6b1551342b7206bff66323d60c6a8126bcaf813 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -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 */
@@ -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;