diff options
author | Robin Dong <sanbai@taobao.com> | 2011-12-18 23:05:43 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-12-18 23:05:43 -0500 |
commit | 8c48f7e88e293b9dd422bd8884842aea85d30b22 (patch) | |
tree | 5a29043ea9c3453d648d2d0b32cfa616f90bc6a9 /fs/ext4 | |
parent | 14d7f3efe923bc60839c65f9818793c64b4d708b (diff) |
ext4: optimize ext4_find_delalloc_range() in nodelalloc mode
We found performance regression when using bigalloc with "nodelalloc"
(1MB cluster size):
1. mke2fs -C 1048576 -O ^has_journal,bigalloc /dev/sda
2. mount -o nodelalloc /dev/sda /test/
3. time dd if=/dev/zero of=/test/io bs=1048576 count=1024
The "dd" will cost about 2 seconds to finish, but if we mke2fs without
"bigalloc", "dd" will only cost less than 1 second.
The reason is: when using ext4 with "nodelalloc", it will call
ext4_find_delalloc_cluster() nearly everytime it call
ext4_ext_map_blocks(), and ext4_find_delalloc_range() will also scan
all pages in cluster because no buffer is "delayed". A cluster has
256 pages (1MB cluster), so it will scan 256 * 256k pags when creating
a 1G file. That severely hurts the performance.
Therefore, we return immediately from ext4_find_delalloc_range() in
nodelalloc mode, since by definition there can't be any delalloc
pages.
Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/extents.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 4423b11476a..5684f251092 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -3281,6 +3281,9 @@ static int ext4_find_delalloc_range(struct inode *inode, | |||
3281 | ext4_lblk_t i, pg_lblk; | 3281 | ext4_lblk_t i, pg_lblk; |
3282 | pgoff_t index; | 3282 | pgoff_t index; |
3283 | 3283 | ||
3284 | if (!test_opt(inode->i_sb, DELALLOC)) | ||
3285 | return 0; | ||
3286 | |||
3284 | /* reverse search wont work if fs block size is less than page size */ | 3287 | /* reverse search wont work if fs block size is less than page size */ |
3285 | if (inode->i_blkbits < PAGE_CACHE_SHIFT) | 3288 | if (inode->i_blkbits < PAGE_CACHE_SHIFT) |
3286 | search_hint_reverse = 0; | 3289 | search_hint_reverse = 0; |