]> git.karo-electronics.de Git - karo-tx-linux.git/commit
Btrfs: allocate the free space by the existed max extent size when ENOSPC
authorMiao Xie <miaox@cn.fujitsu.com>
Mon, 9 Sep 2013 05:19:42 +0000 (13:19 +0800)
committerChris Mason <chris.mason@fusionio.com>
Sat, 21 Sep 2013 15:05:23 +0000 (11:05 -0400)
commita482039889b85c45fc9616e65d560db7a35d4f54
tree58482aa49aa50c30cdd2e7b496f30dd1c11ac860
parent13fd8da98f79317d26277360d510caa1edf9bab3
Btrfs: allocate the free space by the existed max extent size when ENOSPC

By the current code, if the requested size is very large, and all the extents
in the free space cache are small, we will waste lots of the cpu time to cut
the requested size in half and search the cache again and again until it gets
down to the size the allocator can return. In fact, we can know the max extent
size in the cache after the first search, so we needn't cut the size in half
repeatedly, and just use the max extent size directly. This way can save
lots of cpu time and make the performance grow up when there are only fragments
in the free space cache.

According to my test, if there are only 4KB free space extents in the fs,
and the total size of those extents are 256MB, we can reduce the execute
time of the following test from 5.4s to 1.4s.
  dd if=/dev/zero of=<testfile> bs=1MB count=1 oflag=sync

Changelog v2 -> v3:
- fix the problem that we skip the block group with the space which is
  less than we need.

Changelog v1 -> v2:
- address the problem that we return a wrong start position when searching
  the free space in a bitmap.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/extent-tree.c
fs/btrfs/free-space-cache.c
fs/btrfs/free-space-cache.h