mm: write_cache_pages writepage error fix
authorNick Piggin <npiggin@suse.de>
Tue, 6 Jan 2009 22:39:06 +0000 (14:39 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 25 Jan 2009 00:36:26 +0000 (16:36 -0800)
commitc53e887db7e2520d2f0f8cd7794cf90b3f553823
tree86417d10f2301e37472711db26684d67589eb9f7
parentb37c30215d093eb5b3a1f23b7d46cbda8e120a4b
mm: write_cache_pages writepage error fix

commit 00266770b8b3a6a77f896ca501a0613739086832 upstream.

In write_cache_pages, if ret signals a real error, but we still have some
pages left in the pagevec, done would be set to 1, but the remaining pages
would continue to be processed and ret will be overwritten in the process.

It could easily be overwritten with success, and thus success will be
returned even if there is an error.  Thus the caller is told all writes
succeeded, wheras in reality some did not.

Fix this by bailing immediately if there is an error, and retaining the
first error code.

This is a data integrity bug.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
mm/page-writeback.c