aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAndrea Arcangeli <andrea@suse.de>2004-07-28 09:13:18 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-07-28 09:13:18 -0700
commit06ce8344a3a71290edfb6e1ee6dca40c5c58c7eb (patch)
tree3a6313bfc77a1220faf9f034b721bf09def3f9b3 /fs
parentdf13449018c3ae8119cf1daae1fffda5b47231f3 (diff)
downloadhistory-06ce8344a3a71290edfb6e1ee6dca40c5c58c7eb.tar.gz
[PATCH] writepages drops bh on not uptodate page
I think I understood why some ext2 fs corruption still happens even after the last i_size fix. what happened I believe is that the writepages layer got a not a fully uptodate page (in turn with bh mapped on top of it), and then right before unlocking the page and entering the writeback mode, it freed all the bh. Without bh a not uptodate page will trigger a full readpage from disk, that overwrites the pagecache before the multi-bio gets submitted, generating fs corruption. I believe the below patch should fix it (untested) against kernel CVS. The testcases developed by Kurt showed the pagecache being overwritten with on-disk data at block offsets, and Chris as well was wondering about races between wait_on_page_writeback and readpage. the below fix just explains everything we've seen since not-fully-uptodate pages must have always bh on them and the below patch enforces just that invariant, and it should fix our pagecache-overwritten-by-disk-data problem. Signed-off-by: Andrea Arcangeli <andrea@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/mpage.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/mpage.c b/fs/mpage.c
index 79fdc78455b979..71c7ca3a455de3 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -553,7 +553,12 @@ alloc_new:
bh = bh->b_this_page;
} while (bh != head);
- if (buffer_heads_over_limit)
+ /*
+ * we cannot drop the bh if the page is not uptodate
+ * or a concurrent readpage would fail to serialize with the bh
+ * and it would read from disk before we reach the platter.
+ */
+ if (buffer_heads_over_limit && PageUptodate(page))
try_to_free_buffers(page);
}