]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ext3: Fix data / filesystem corruption when write fails to copy data
authorJan Kara <jack@suse.cz>
Tue, 1 Dec 2009 15:53:06 +0000 (16:53 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 18 Dec 2009 21:44:18 +0000 (13:44 -0800)
commite5a1a67df493b4c14a6e1e795b861d0dd8226529
tree6355b9672f591205255d14c161b35d7e632331e6
parent1c1f916747265cd65ba1896c20a93034c6c1ec17
ext3: Fix data / filesystem corruption when write fails to copy data

commit 68eb3db08344286733adac48304d9fb7a0e53b27 upstream.

When ext3_write_begin fails after allocating some blocks or
generic_perform_write fails to copy data to write, we truncate blocks already
instantiated beyond i_size. Although these blocks were never inside i_size, we
have to truncate pagecache of these blocks so that corresponding buffers get
unmapped. Otherwise subsequent __block_prepare_write (called because we are
retrying the write) will find the buffers mapped, not call ->get_block, and
thus the page will be backed by already freed blocks leading to filesystem and
data corruption.

Reported-by: James Y Knight <foom@fuhm.net>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/ext3/inode.c