Skip to content

Commit 5534fb5

Browse files
committed
ext4: Fix the alloc on close after a truncate hueristic
In an attempt to avoid doing an unneeded flush after opening a (previously non-existent) file with O_CREAT|O_TRUNC, the code only triggered the hueristic if ei->disksize was non-zero. Turns out that the VFS doesn't call ->truncate() if the file doesn't exist, and ei->disksize is always zero even if the file previously existed. So remove the test, since it isn't necessary and in fact disabled the hueristic. Thanks to Clemens Eisserer that he was seeing problems with files written using kwrite and eclipse after sudden crashes caused by a buggy Intel video driver. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent fb40ba0 commit 5534fb5

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/ext4/inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3973,8 +3973,7 @@ void ext4_truncate(struct inode *inode)
39733973
if (!ext4_can_truncate(inode))
39743974
return;
39753975

3976-
if (ei->i_disksize && inode->i_size == 0 &&
3977-
!test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
3976+
if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
39783977
ei->i_state |= EXT4_STATE_DA_ALLOC_CLOSE;
39793978

39803979
if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) {

0 commit comments

Comments
 (0)