feat: add option to disable copy-file-range for multipart uploads

The standard io.Copy() will attempt to use copy_file_range when available.
However, this can cause problems with certain filesystems. Add an option
that will prevent io.Copy() from being able to use copy_file_range to force
a standard data copy between file descriptors when needed for completing
multipart uploads.
This commit is contained in:
Jakob van Santen
2026-03-20 08:23:01 -07:00
committed by GitHub
parent ae411fa3c1
commit 56cb36d45a
2 changed files with 60 additions and 31 deletions
+24 -16
View File
@@ -25,14 +25,15 @@ import (
)
var (
chownuid, chowngid bool
bucketlinks bool
versioningDir string
dirPerms uint
sidecar string
nometa bool
forceNoTmpFile bool
actionsConcurrency int
chownuid, chowngid bool
bucketlinks bool
versioningDir string
dirPerms uint
sidecar string
nometa bool
forceNoTmpFile bool
forceNoCopyFileRange bool
actionsConcurrency int
)
func posixCommand() *cli.Command {
@@ -108,6 +109,12 @@ will be translated into the file /mnt/fs/gwroot/mybucket/a/b/c/myobject`,
EnvVars: []string{"VGW_DISABLE_OTMP"},
Destination: &forceNoTmpFile,
},
&cli.BoolFlag{
Name: "disable-copy-file-range",
Usage: "explicitly copy multipart upload parts instead of using copy_file_range (which may hang with some NFS servers)",
EnvVars: []string{"VGW_DISABLE_COPY_FILE_RANGE"},
Destination: &forceNoCopyFileRange,
},
},
}
}
@@ -132,14 +139,15 @@ func runPosix(ctx *cli.Context) error {
}
opts := posix.PosixOpts{
ChownUID: chownuid,
ChownGID: chowngid,
BucketLinks: bucketlinks,
VersioningDir: versioningDir,
NewDirPerm: fs.FileMode(dirPerms),
ForceNoTmpFile: forceNoTmpFile,
ValidateBucketNames: disableStrictBucketNames,
Concurrency: actionsConcurrency,
ChownUID: chownuid,
ChownGID: chowngid,
BucketLinks: bucketlinks,
VersioningDir: versioningDir,
NewDirPerm: fs.FileMode(dirPerms),
ForceNoTmpFile: forceNoTmpFile,
ForceNoCopyFileRange: forceNoCopyFileRange,
ValidateBucketNames: disableStrictBucketNames,
Concurrency: actionsConcurrency,
}
var ms meta.MetadataStorer