btrfs: lift some btrfs_cross_ref_exist checks in nocow path
authorEthan Lien <ethanlien@synology.com>
Thu, 17 May 2018 06:58:29 +0000 (14:58 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 30 May 2018 14:46:53 +0000 (16:46 +0200)
commit78d4295b1eeed4d857f11333caac8b4894ac4412
tree3f9af4c65fc9bad4ebc7209349eb510c16aa8916
parentd19577912d57c143bb592a061e3dbd7b6f78f71a
btrfs: lift some btrfs_cross_ref_exist checks in nocow path

In nocow path, we check if the extent is snapshotted in
btrfs_cross_ref_exist(). We can do the similar check earlier and avoid
unnecessary search into extent tree.

A fio test on a Intel D-1531, 16GB RAM, SSD RAID-5 machine as follows:

[global]
group_reporting
time_based
thread=1
ioengine=libaio
bs=4k
iodepth=32
size=64G
runtime=180
numjobs=8
rw=randwrite

[file1]
filename=/mnt/nocow/testfile

IOPS result:   unpatched     patched

1 fio round:     46670        46958
snapshot
2 fio round:     51826        54498
3 fio round:     59767        61289

After snapshot, the first fio get about 5% performance gain. As we
continually write to the same file, all writes will resume to nocow mode
and eventually we have no performance gain.

Signed-off-by: Ethan Lien <ethanlien@synology.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update comments ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c