[PATCH 2.6.3-rc2-mm1] __block_write_full patch

From: Daniel McNeil
Date: Fri Feb 13 2004 - 16:33:34 EST


Andrew,

Here is my original __block_write_full_page patch which adds
a wait_on_buffer() to catch the case where i/o might be in flight
from ll_rw_block().

I know that it waits for i/o even the non-blocking writebacks, but
it does make sure filemap_write_and_wait() and filemap_fdatawrite /
filemap_fdatawait() do wait for all i/o that has been submitted to
complete. (This similar to 2.4 which always does a lock_buffer()).
The direct_read_under test does not see uninitialized data with
this patch. Without this patch 2.6.3-rc2-mm1 still sees uninitialized
data.

I am worried that the current behavior where PageWriteback can be
cleared with i/o still in flight for a buffer on that page could cause
other problems.

I am still trying to figure out how to fix this some other way,
but, in the mean time, this makes sure the code is correct.

Thoughts?

re-diff against 2.6.3-rc2-mm1.

Daniel

On Thu, 2004-02-12 at 01:57, Andrew Morton wrote:

>
> O_DIRECT-ll_rw_block-vs-block_write_full_page-fix.patch
> Fix race between ll_rw_block() and block_write_full_page()
>

--- linux-2.6.3-rc2-mm1.orig/fs/buffer.c 2004-02-12 11:43:39.000000000 -0800
+++ linux-2.6.3-rc2-mm1/fs/buffer.c 2004-02-12 11:42:56.000000000 -0800
@@ -1810,6 +1810,7 @@ static int __block_write_full_page(struc

do {
get_bh(bh);
+ wait_on_buffer(bh); /* i/o might be in flight */
if (!buffer_mapped(bh))
continue;
if (wbc->sync_mode != WB_SYNC_NONE) {