diff --git a/pkg/filemanager/driver/local/local.go b/pkg/filemanager/driver/local/local.go index 172effb8..33f6ea93 100644 --- a/pkg/filemanager/driver/local/local.go +++ b/pkg/filemanager/driver/local/local.go @@ -226,6 +226,12 @@ func (handler *Driver) Token(ctx context.Context, uploadSession *fs.UploadSessio if err := Fallocate(f, 0, uploadSession.Props.Size); err != nil { handler.l.Warning("Failed to preallocate file: %s", err) } + } else { + // When disk pre-allocation is disabled, concurrent chunk uploads must be 1 + // to avoid disk fragmentation and write contention on local storage. + settings := *handler.Policy.Settings + settings.ChunkConcurrency = 1 + handler.Policy.Settings = &settings } return &fs.UploadCredential{ diff --git a/pkg/filemanager/driver/remote/remote.go b/pkg/filemanager/driver/remote/remote.go index 42b2b1af..cc0b89fa 100644 --- a/pkg/filemanager/driver/remote/remote.go +++ b/pkg/filemanager/driver/remote/remote.go @@ -150,6 +150,14 @@ func (handler *Driver) Token(ctx context.Context, uploadSession *fs.UploadSessio return nil, fmt.Errorf("failed to sign upload url: %w", err) } + // When disk pre-allocation is disabled, concurrent chunk uploads must be 1 + // to avoid disk fragmentation and write contention on slave storage. + if !handler.Policy.Settings.PreAllocate { + settings := *handler.Policy.Settings + settings.ChunkConcurrency = 1 + handler.Policy.Settings = &settings + } + return &fs.UploadCredential{ SessionID: uploadSession.Props.UploadSessionID, ChunkSize: handler.Policy.Settings.ChunkSize,