1 ext4: in ext4_setattr(), only call ext4_truncate() if there is no data to drop
3 If there are no blocks associated with the inode (and no inline data),
4 there's no point calling ext4_truncate(). This avoids setting the
5 replace-via-truncate hueristic if there is an attempt to truncate a
6 file which is already zero-length --- which is something that happens
7 in the core dumping code, in case there is an already existing core
8 file. In the comon case, there is not a previous core file, so by not
9 enabling the replace-via-truncate hueristic, we can speed up core
12 Reported-by: Omar Sandoval <osandov@fb.com>
13 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
15 fs/ext4/inode.c | 2 +-
16 1 file changed, 1 insertion(+), 1 deletion(-)
18 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
19 index 44ee5d9..cd757f8 100644
22 @@ -5171,7 +5171,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
23 * in data=journal mode to make pages freeable.
25 truncate_pagecache(inode, inode->i_size);
27 + if (shrink && (inode->i_blocks || ext4_has_inline_data(inode)))
29 up_write(&EXT4_I(inode)->i_mmap_sem);