linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] Fix file-corrupting bug, kernels 2.5.41 to 2.5.44
@ 2002-10-28  4:11 Andrew Morton
  2002-10-28 11:04 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2002-10-28  4:11 UTC (permalink / raw)
  To: lkml; +Cc: Jens Axboe



This patch fixes a filesystem corrupting bug, present in 2.5.41 through
2.5.44.  It can cause ext2 indirect blocks to not be written out.  A
fsck will fix it up.

Under heavy memory pressure a PF_MEMALLOC task attemtps to write out a
blockdev page whose buffers are already under writeback and which were
dirtied while under writeback.

The writepage call returns -EAGAIN but because the caller is
PF_MEMALLOC, the page was not being marked dirty again.

The page sits on mapping->clean_pages for ever and it not written out.

The fix is to mark that page dirty again for all callers, regardless of
PF_MEMALLOC state.



 fs/mpage.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

--- 25/fs/mpage.c~set_page_dirty-pf_memalloc	Sun Oct 27 19:22:44 2002
+++ 25-akpm/fs/mpage.c	Sun Oct 27 19:24:18 2002
@@ -591,6 +591,10 @@ mpage_writepages(struct address_space *m
 					test_clear_page_dirty(page)) {
 			if (writepage) {
 				ret = (*writepage)(page);
+				if (ret == -EAGAIN) {
+					__set_page_dirty_nobuffers(page);
+					ret = 0;
+				}
 			} else {
 				bio = mpage_writepage(bio, page, get_block,
 						&last_block_in_bio, &ret);
@@ -601,10 +605,6 @@ mpage_writepages(struct address_space *m
 					pagevec_deactivate_inactive(&pvec);
 				page = NULL;
 			}
-			if (ret == -EAGAIN && page) {
-				__set_page_dirty_nobuffers(page);
-				ret = 0;
-			}
 			if (ret || (--(wbc->nr_to_write) <= 0))
 				done = 1;
 			if (wbc->nonblocking && bdi_write_congested(bdi)) {

.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Fix file-corrupting bug, kernels 2.5.41 to 2.5.44
  2002-10-28  4:11 [patch] Fix file-corrupting bug, kernels 2.5.41 to 2.5.44 Andrew Morton
@ 2002-10-28 11:04 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2002-10-28 11:04 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lkml

On Sun, Oct 27 2002, Andrew Morton wrote:
> 
> 
> This patch fixes a filesystem corrupting bug, present in 2.5.41 through
> 2.5.44.  It can cause ext2 indirect blocks to not be written out.  A
> fsck will fix it up.
> 
> Under heavy memory pressure a PF_MEMALLOC task attemtps to write out a
> blockdev page whose buffers are already under writeback and which were
> dirtied while under writeback.

Nasty, it's odd how noone else seems to have noticed this?

> The writepage call returns -EAGAIN but because the caller is
> PF_MEMALLOC, the page was not being marked dirty again.
> 
> The page sits on mapping->clean_pages for ever and it not written out.
> 
> The fix is to mark that page dirty again for all callers, regardless of
> PF_MEMALLOC state.

I can confirm that this fixes my 'loosing data under vm pressure' bug,
both for O_DIRECT case and sgio. It passed 1 iteration of both tests, it
would not even get past the 10% mark before. Thanks!

BTW, 2.5.44-mm6 showed some funnies and corrupted data in other
interesting ways. I'm hesitant to report this as a bug right now, as it
may just have been that the target fs had not been fsck'ed after being
run under one of the buggy kernels. But it did crash in the end, dumping
lots of hot/cold warnings. The above verification was run under 2.5.44 +
sgio patches + your standalone __set_page_dirty() fix.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-28 10:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-28  4:11 [patch] Fix file-corrupting bug, kernels 2.5.41 to 2.5.44 Andrew Morton
2002-10-28 11:04 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).