Skip to contentSkip to conversation

fs: fix __block_write_full_page error case buffer submission

PATCH New Nick Piggin 1 participant 1 message Feb 6, 2007 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: fix __block_write_full_page error case buffer submission

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.

fs/buffer.c +1 -1
Index: 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;
 }