On Wed, Jun 2, 2021 at 5:20 PM Michael Paquier <michael@paquier.xyz> wrote:
> Note: FreeBSD 13~ has support for copy_file_range(), nice.. Adding
> Thomas in CC in case I am missing something.
Yeah, so at least in theory Linux and FreeBSD can now both do tricks
like pushing copies down to network filesystems, COW file systems, and
(I believe not actually done by anyone yet, could be wrong) SCSI and
NVMe devices (they have commands like XCOPY that can copy block ranges
directly). I read a few things about all that, and I had a trivial
patch to try to use it in the places in the backend where we copy
files (like cloning a database with CREATE DATABASE and moving files
with ALTER TABLE SET TABLESPACE), but I hadn't got as far as actually
trying it on any interesting filesystems or figuring out any really
good uses for it. FWIW, here it is:
https://github.com/postgres/postgres/compare/master...macdice:copy_file_range
The main thing I noticed was that Linux < 5.3 can fail with EXDEV if
you cross a filesystem boundary, is that something we need to worry
abou there?