From: Chris Mason BUG 40701 correct math errors for aio O_SYNC writes that lead to the aio code thinking the write is complete while we are still waiting for some pages filemap.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) --- aio/mm/filemap.c 2004-06-26 15:50:43.132941192 -0700 +++ O_SYNC-write/mm/filemap.c 2004-06-26 16:01:26.559125544 -0700 @@ -208,7 +208,7 @@ static ssize_t wait_on_page_writeback_ra struct pagevec pvec; int nr_pages; int ret = 0, done = 0; - pgoff_t index, curr = start; + pgoff_t index; if (end < start) return 0; @@ -232,12 +232,9 @@ static ssize_t wait_on_page_writeback_ra unlock_page(page); continue; } - curr = page->index; unlock_page(page); ret = wait_on_page_writeback_wq(page, wait); if (ret == -EIOCBRETRY) { - if (curr > start) - ret = curr - start; done = 1; break; }