Skip to content

Commit

Permalink
ext4: Don't treat a truncation of a zero-length file as replace-via-t…
Browse files Browse the repository at this point in the history
…runcate

If a non-existent file is opened via O_WRONLY|O_CREAT|O_TRUNC, there's
no need to treat this as a true file truncation, so we shouldn't
activate the replace-via-truncate hueristic.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Theodore Ts'o committed Jun 9, 2009
1 parent 9aee228 commit 0eab928
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4127,7 +4127,8 @@ void ext4_truncate(struct inode *inode)
if (!ext4_can_truncate(inode))
return;

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

if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) {
Expand Down

0 comments on commit 0eab928

Please sign in to comment.