提交 8c48f7e8 编写于 作者: R Robin Dong 提交者: Theodore Ts'o

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: NRobin Dong <sanbai@taobao.com>
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
上级 14d7f3ef
...@@ -3281,6 +3281,9 @@ static int ext4_find_delalloc_range(struct inode *inode, ...@@ -3281,6 +3281,9 @@ static int ext4_find_delalloc_range(struct inode *inode,
ext4_lblk_t i, pg_lblk; ext4_lblk_t i, pg_lblk;
pgoff_t index; pgoff_t index;
if (!test_opt(inode->i_sb, DELALLOC))
return 0;
/* reverse search wont work if fs block size is less than page size */ /* reverse search wont work if fs block size is less than page size */
if (inode->i_blkbits < PAGE_CACHE_SHIFT) if (inode->i_blkbits < PAGE_CACHE_SHIFT)
search_hint_reverse = 0; search_hint_reverse = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册