ext3: Fix truncation of symlinks after failed write
authorJan Kara <jack@suse.cz>
Mon, 13 Jul 2009 18:26:52 +0000 (20:26 +0200)
committerJan Kara <jack@suse.cz>
Wed, 15 Jul 2009 19:28:07 +0000 (21:28 +0200)
commit9eaaa2d5759837402ec5eee13b2a97921808c3eb
treec1ba576d1175a91e7fb443a7d87a76c2380ce9cf
parent7447a668a3860b66b3c9db86fdea91e355ba59ac
ext3: Fix truncation of symlinks after failed write

Contents of long symlinks is written via standard write methods. So when the
write fails, we add inode to orphan list. But symlinks don't have .truncate
method defined so nobody properly removes them from the orphan list (both on
disk and in memory).

Fix this by calling ext3_truncate() directly instead of calling vmtruncate()
(which is saner anyway since we don't need anything vmtruncate() does except
from calling .truncate in these paths).  We also add inode to orphan list only
if ext3_can_truncate() is true (currently, it can be false for symlinks when
there are no blocks allocated) - otherwise orphan list processing will complain
and ext3_truncate() will not remove inode from on-disk orphan list.

Signed-off-by: Jan Kara <jack@suse.cz>
fs/ext3/inode.c