[PATCH 2.6.3-rc2-mm1] filemap_fdatawait patch

From: Daniel McNeil
Date: Fri Feb 13 2004 - 16:52:26 EST


Andrew,

This is re-diffed against 2.6.3-rc2-mm1.

This adds the lock_page() and check for PageDirty() in
filemap_fdatawait().

I did additional direct_read_under testing with a forked() process
doing "sync()" and without this patch I hit uninitialized data
even with the __block_write_full_page() patch.

Thoughts?

Daniel

PS

I still think there is potential problem if we ever allow multiple
filemap_fdatawait() to occur in parallel since filemap_fdatawait()
waits for a page with the page unlinked from the locked list.
The 2nd filemap_fdatawait() would never see that page to wait.
I might take care of that in a future patch.


--- linux-2.6.3-rc2-mm1.orig/mm/filemap.c 2004-02-12 15:04:41.000000000 -0800
+++ linux-2.6.3-rc2-mm1/mm/filemap.c 2004-02-13 12:57:08.777799758 -0800
@@ -209,10 +209,15 @@ restart:
page_cache_get(page);
spin_unlock(&mapping->page_lock);

- wait_on_page_writeback(page);
- if (PageError(page))
- ret = -EIO;
-
+ lock_page(page);
+ if (PageDirty(page) && mapping->a_ops->writepage) {
+ write_one_page(page, 1);
+ } else {
+ wait_on_page_writeback(page);
+ unlock_page(page);
+ }
+ if (PageError(page))
+ ret = -EIO;
page_cache_release(page);
spin_lock(&mapping->page_lock);
}