mirror of
https://github.com/versity/versitygw.git
synced 2026-01-08 12:41:10 +00:00
The complete multipart upload can be optimized in some cases to not need to copy the full data from parts to the final object file. If the filesystem supports it, there can be optimizations to just clone exent references and not have to actually copy the data. For io.Copy() to make use of file_copy_range, we have to pass it the *os.File file handles from the filesystem for the source and destination. We were previously adding a layer of indirection that was causing io.Copy() to fallback to full data copy. This fixes the copy by exposing the underlying fd. This also skips the falloc for the final object in complete mutlipart upload, because some filesystems will be able to use file_copy_range to optimize the copy and may not even need new data allocations in the final object file. Note that this only affects posix mode as scoutfs has special handling for this case that is similar to but not compatible with copy_file_range using a special ioctl.