]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: don't do nocow check unless we have to
authorJosef Bacik <jbacik@fb.com>
Fri, 25 Mar 2016 17:26:00 +0000 (13:26 -0400)
committerChris Mason <clm@fb.com>
Thu, 23 Jun 2016 00:57:14 +0000 (17:57 -0700)
commit6d36299c289de18b6b2ce2e18aa8ef9ddec6f5de
tree2e3ecc39233d9f461c6645ddf093305dcdeeabff
parent7886ccf6941e60f8359ccb6b21472cf8fa8c577d
Btrfs: don't do nocow check unless we have to

Before we write into prealloc/nocow space we have to make sure that there are no
references to the extents we are writing into, which means checking the extent
tree and csum tree in the case of nocow.  So we don't want to do the nocow dance
unless we can't reserve data space, since it's a serious drag on performance.
With the following sequence

fallocate -l10737418240 /mnt/btrfs-test/file
cp --reflink /mnt/btrfs-test/file /mnt/btrfs-test/link
fio --name=randwrite --rw=randwrite --bs=4k --filename=/mnt/btrfs-test/file \
--end_fsync=1

we get the worst case scenario where we have to fall back on to doing the check
anyway.

Without this patch
lat (usec): min=5, max=111598, avg=27.65, stdev=124.51
write: io=10240MB, bw=126876KB/s, iops=31718, runt= 82646msec

With this patch
lat (usec): min=3, max=91210, avg=14.09, stdev=110.62
write: io=10240MB, bw=212753KB/s, iops=53188, runt= 49286msec

We get twice the throughput, half of the runtime, and half of the average
latency.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
[ PAGE_CACHE_ removal related fixups ]
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/file.c