[patch] fs: fix __block_write_full_page error case buffer submission

From: Nick Piggin
Date: Tue Feb 06 2007 - 03:33:55 EST


OK, I had initially been going to send a patch to bring the common case
into line with the error case to reduce the chance of rare bugs, but
that's stupid because the common case is obviously the better tested one!

Oh, and the error case seems to have a bug as well.

--
Andrew noticed that unlocking the page before submitting all buffers for
writeout could cause problems if the IO completes before we've finished
messing around with the page buffers, and they subsequently get freed.

Even if there were no bug, it is a good idea to bring the error case
into line with the common case here.

Signed-off-by: Nick Piggin <npiggin@xxxxxxx>

Index: linux-2.6/fs/buffer.c
===================================================================
--- linux-2.6.orig/fs/buffer.c
+++ linux-2.6/fs/buffer.c
@@ -1732,7 +1732,6 @@ recover:
SetPageError(page);
BUG_ON(PageWriteback(page));
set_page_writeback(page);
- unlock_page(page);
do {
struct buffer_head *next = bh->b_this_page;
if (buffer_async_write(bh)) {
@@ -1742,6 +1741,7 @@ recover:
}
bh = next;
} while (bh != head);
+ unlock_page(page);
goto done;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/