From e92ad0ba0862137670e85c3c0bef30df93644a43 Mon Sep 17 00:00:00 2001 From: niksis02 Date: Thu, 15 Oct 2026 19:20:36 +0400 Subject: [PATCH] fix: map quota and no-space errors when creating the multipart upload directory Fixes #2511 `CreateMultipartUpload` in the posix backend creates the upload directory under `.sgwtmp/multipart` with `os.MkdirAll` and returned any failure wrapped as `create upload temp dir`, so a full filesystem quota or a full disk came back as a 500 `InternalError` (which SDKs also retry) instead of the error the other write paths return. `PutObject`, `UploadPart`, `UploadPartCopy` and `CompleteMultipartUpload` already map these errors. `syscall.EDQUOT` from the directory creation now returns `QuotaExceeded` (403) and `syscall.ENOSPC` returns `InsufficientStorage` (507), the same mapping the rest of the posix write paths use. --- backend/posix/posix.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/posix/posix.go b/backend/posix/posix.go index b160347c..750f64fe 100644 --- a/backend/posix/posix.go +++ b/backend/posix/posix.go @@ -2080,6 +2080,12 @@ func (p *Posix) CreateMultipartUpload(ctx context.Context, mpu s3response.Create // associated with this specific multipart upload err = os.MkdirAll(filepath.Join(tmppath, uploadID), p.newDirPerm) if err != nil { + if errors.Is(err, syscall.EDQUOT) { + return s3response.InitiateMultipartUploadResult{}, s3err.GetAPIError(s3err.ErrQuotaExceeded) + } + if errors.Is(err, syscall.ENOSPC) { + return s3response.InitiateMultipartUploadResult{}, s3err.GetAPIError(s3err.ErrNoSpaceLeftOnDevice) + } return s3response.InitiateMultipartUploadResult{}, fmt.Errorf("create upload temp dir: %w", err) }