Message ID | 20160704022455.GA28883@thunk.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sun, Jul 03, 2016 at 10:24:55PM -0400, Theodore Ts'o wrote: > From bf21c027d84ded545d2c08fa01fd184d29641458 Mon Sep 17 00:00:00 2001 > From: Theodore Ts'o <tytso@mit.edu> > Date: Sun, 3 Jul 2016 22:20:49 -0400 > Subject: [PATCH] ext4: in ext4_setattr(), only call ext4_truncate() if there is no data to drop > > If there are no blocks associated with the inode (and no inline data), > there's no point calling ext4_truncate(). This avoids setting the > replace-via-truncate hueristic if there is an attempt to truncate a > file which is already zero-length --- which is something that happens > in the core dumping code, in case there is an already existing core > file. In the comon case, there is not a previous core file, so by not > enabling the replace-via-truncate hueristic, we can speed up core > dumps. > > Reported-by: Omar Sandoval <osandov@fb.com> > Signed-off-by: Theodore Ts'o <tytso@mit.edu> This patch is buggy; when I tried running regression tests, it failed early. So you probably want to skip this. - Ted -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 44ee5d9..cd757f8 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5171,7 +5171,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) * in data=journal mode to make pages freeable. */ truncate_pagecache(inode, inode->i_size); - if (shrink) + if (shrink && (inode->i_blocks || ext4_has_inline_data(inode))) ext4_truncate(inode); up_write(&EXT4_I(inode)->i_mmap_sem); }