Page MenuHomeFreeBSD

make vn_generic_copy_file_range() run efficiently when the input file has a large hole to EOF
ClosedPublic

Authored by rmacklem on May 2 2021, 2:11 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 7 2024, 5:32 PM
Unknown Object (File)
Feb 17 2024, 12:41 AM
Unknown Object (File)
Jan 14 2024, 4:57 AM
Unknown Object (File)
Dec 25 2023, 1:47 AM
Unknown Object (File)
Dec 20 2023, 7:13 AM
Unknown Object (File)
Nov 23 2023, 5:21 AM
Unknown Object (File)
Nov 6 2023, 9:16 AM
Unknown Object (File)
Oct 6 2023, 6:59 AM
Subscribers
None

Details

Summary

PR#255523 reported that a file copy for a file with a large hole
to EOF on ZFS ran slowly over NFSv4.2.
The problem was that vn_generic_copy_file_range() would
loop around reading the hole's data and then see it is all
0s. It was coded this way since UFS always allocates a data
block near the end of the file, such that a hole to EOF never exists.

This patch modifies vn_generic_copy_file_range() to check for a
ENXIO returned from VOP_IOCTL(..FIOSEEKDATA..) and handle that
case as a hole to EOF. asomers@ confirms that it works for his
ZFS test case.

Test Plan

I tested it over UFS to ensure there was no regression for
a large file created via truncate(1) and asomers@ did the
same for ZFS.

Since the code was already tested for a similar case, where
the hole went as far as the "len" being copied, I believe
this should be sufficient testing.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

rmacklem created this revision.
This revision is now accepted and ready to land.May 2 2021, 2:20 AM