aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAndrey Sidorov <qrxd43@motorola.com>2012-09-19 14:14:53 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-09-19 14:14:53 -0400
commit18888cf0883c286f238d44ee565530fe82752f06 (patch)
treeebdc31cf2f7589b07bea8398cfb2d812f1a179c3 /fs
parent59e31c156a24d483bbd2ea07d4dc96043a55b6bc (diff)
ext4: speed up truncate/unlink by not using bforget() unless needed
Do not iterate over data blocks scanning for bh's to forget as they're never exist. This improves time taken by unlink / truncate syscall. Tested by continuously truncating file that is being written by dd. Another test is rm -rf of linux tree while tar unpacks it. With ordered data mode condition unlikely(!tbh) was always met in ext4_free_blocks. With journal data mode tbh was found only few times, so optimisation is also possible. Unlinking fallocated 60G file after doing sync && echo 3 > /proc/sys/vm/drop_caches && time rm --help X86 before (linux 3.6-rc4): # time rm -f test1 real 0m2.710s user 0m0.000s sys 0m1.530s X86 after: # time rm -f test1 real 0m0.644s user 0m0.003s sys 0m0.060s MIPS before (linux 2.6.37): # time rm -f test1 real 0m 4.93s user 0m 0.00s sys 0m 4.61s MIPS after: # time rm -f test1 real 0m 0.16s user 0m 0.00s sys 0m 0.06s Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Andrey Sidorov <qrxd43@motorola.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/extents.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index cc6d2b984e8f..a510917c175a 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2318,10 +2318,13 @@ static int ext4_remove_blocks(handle_t *handle, struct inode *inode,
2318 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 2318 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
2319 unsigned short ee_len = ext4_ext_get_actual_len(ex); 2319 unsigned short ee_len = ext4_ext_get_actual_len(ex);
2320 ext4_fsblk_t pblk; 2320 ext4_fsblk_t pblk;
2321 int flags = EXT4_FREE_BLOCKS_FORGET; 2321 int flags = 0;
2322 2322
2323 if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) 2323 if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
2324 flags |= EXT4_FREE_BLOCKS_METADATA; 2324 flags |= EXT4_FREE_BLOCKS_METADATA | EXT4_FREE_BLOCKS_FORGET;
2325 else if (ext4_should_journal_data(inode))
2326 flags |= EXT4_FREE_BLOCKS_FORGET;
2327
2325 /* 2328 /*
2326 * For bigalloc file systems, we never free a partial cluster 2329 * For bigalloc file systems, we never free a partial cluster
2327 * at the beginning of the extent. Instead, we make a note 2330 * at the beginning of the extent. Instead, we make a note