From: Suparna Bhattacharya Patch containing just the missing hunks fs/aio.c | 36 ++++++++++-------------------------- 1 files changed, 10 insertions(+), 26 deletions(-) diff -puN fs/aio.c~aio-O_SYNC-fix-missing-bit fs/aio.c --- 25/fs/aio.c~aio-O_SYNC-fix-missing-bit 2003-08-28 02:33:27.000000000 -0700 +++ 25-akpm/fs/aio.c 2003-08-28 02:33:32.000000000 -0700 @@ -1289,11 +1289,6 @@ static ssize_t aio_pwrite(struct kiocb * struct inode *inode = mapping->host; ssize_t ret = 0; - if (!iocb->ki_buf) { - ret = iocb->ki_left; - goto retry_osync; - } - ret = file->f_op->aio_write(iocb, iocb->ki_buf, iocb->ki_left, iocb->ki_pos); @@ -1302,7 +1297,7 @@ static ssize_t aio_pwrite(struct kiocb * * for a balance_dirty_pages to complete */ if (ret > 0) { - iocb->ki_buf += ret; + iocb->ki_buf += iocb->ki_buf ? ret : 0; iocb->ki_left -= ret; ret = -EIOCBRETRY; @@ -1312,30 +1307,19 @@ static ssize_t aio_pwrite(struct kiocb * /* No need to retry anymore unless we need to osync data */ if (ret == 0) { ret = iocb->ki_nbytes - iocb->ki_left; - /* Set things up for potential O_SYNC */ - iocb->ki_buf = NULL; - iocb->ki_pos -= ret; /* back up fpos */ - iocb->ki_left = ret; /* sync only what we have written out */ - iocb->ki_nbytes = ret; - } + if (!iocb->ki_buf) + return ret; - -retry_osync: - if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { - ssize_t err; - - err = sync_page_range(inode, mapping, iocb->ki_pos, ret); - if (err <= 0) { - ret = err; - } else { - BUG_ON(err > iocb->ki_left); - iocb->ki_pos += err; - iocb->ki_left -= err; + /* Set things up for potential O_SYNC */ + if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { + iocb->ki_buf = NULL; + iocb->ki_pos -= ret; /* back up fpos */ + iocb->ki_left = ret; /* sync what we have written out */ + iocb->ki_nbytes = ret; ret = -EIOCBRETRY; } } - if (ret == 0) - ret = iocb->ki_nbytes - iocb->ki_left; + return ret; } _