2016-05-21 05:48:47 +02:00
|
|
|
/*
|
2020-06-13 05:04:01 +02:00
|
|
|
* MinIO Cloud Storage, (C) 2016-2020 MinIO, Inc.
|
2016-05-21 05:48:47 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-08-19 01:23:42 +02:00
|
|
|
package cmd
|
2016-05-21 05:48:47 +02:00
|
|
|
|
|
|
|
import (
|
2018-03-14 20:01:47 +01:00
|
|
|
"context"
|
2016-05-21 05:48:47 +02:00
|
|
|
"fmt"
|
2019-01-17 13:58:18 +01:00
|
|
|
"io"
|
2021-02-26 18:52:27 +01:00
|
|
|
"os"
|
2016-05-21 05:48:47 +02:00
|
|
|
"path"
|
2018-03-15 21:55:23 +01:00
|
|
|
"sort"
|
2018-09-28 05:36:17 +02:00
|
|
|
"strconv"
|
2016-05-24 22:35:43 +02:00
|
|
|
"strings"
|
2021-02-11 19:22:03 +01:00
|
|
|
"sync"
|
2020-08-22 06:39:54 +02:00
|
|
|
"time"
|
2016-05-24 22:35:43 +02:00
|
|
|
|
2020-07-14 18:38:05 +02:00
|
|
|
"github.com/minio/minio-go/v7/pkg/set"
|
2019-10-07 07:50:24 +02:00
|
|
|
xhttp "github.com/minio/minio/cmd/http"
|
2018-04-06 00:04:40 +02:00
|
|
|
"github.com/minio/minio/cmd/logger"
|
2016-05-24 22:35:43 +02:00
|
|
|
"github.com/minio/minio/pkg/mimedb"
|
2019-10-14 18:44:51 +02:00
|
|
|
"github.com/minio/minio/pkg/sync/errgroup"
|
2016-05-21 05:48:47 +02:00
|
|
|
)
|
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
func (er erasureObjects) getUploadIDDir(bucket, object, uploadID string) string {
|
|
|
|
return pathJoin(er.getMultipartSHADir(bucket, object), uploadID)
|
2017-01-26 21:51:12 +01:00
|
|
|
}
|
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
func (er erasureObjects) getMultipartSHADir(bucket, object string) string {
|
2018-03-15 21:55:23 +01:00
|
|
|
return getSHA256Hash([]byte(pathJoin(bucket, object)))
|
2017-01-26 21:51:12 +01:00
|
|
|
}
|
|
|
|
|
2019-04-23 23:54:28 +02:00
|
|
|
// checkUploadIDExists - verify if a given uploadID exists and is valid.
|
2021-03-26 19:17:23 +01:00
|
|
|
func (er erasureObjects) checkUploadIDExists(ctx context.Context, bucket, object, uploadID string) (err error) {
|
|
|
|
defer func() {
|
|
|
|
if err == errFileNotFound {
|
|
|
|
err = errUploadIDNotFound
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2020-10-26 18:30:46 +01:00
|
|
|
disks := er.getDisks()
|
|
|
|
|
|
|
|
// Read metadata associated with the object from all disks.
|
2021-01-08 04:27:31 +01:00
|
|
|
metaArr, errs := readAllFileInfo(ctx, disks, minioMetaMultipartBucket, er.getUploadIDDir(bucket, object, uploadID), "", false)
|
2020-10-26 18:30:46 +01:00
|
|
|
|
2021-01-16 21:08:02 +01:00
|
|
|
readQuorum, _, err := objectQuorumFromMeta(ctx, metaArr, errs, er.defaultParityCount)
|
2020-10-26 18:30:46 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if reducedErr := reduceReadQuorumErrs(ctx, errs, objectOpIgnoredErrs, readQuorum); reducedErr != nil {
|
2021-03-26 19:17:23 +01:00
|
|
|
return reducedErr
|
2020-10-26 18:30:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// List all online disks.
|
|
|
|
_, modTime := listOnlineDisks(disks, metaArr, errs)
|
|
|
|
|
|
|
|
// Pick latest valid metadata.
|
|
|
|
_, err = pickValidFileInfo(ctx, metaArr, modTime, readQuorum)
|
2019-04-23 23:54:28 +02:00
|
|
|
return err
|
2017-01-26 21:51:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Removes part given by partName belonging to a mulitpart upload from minioMetaBucket
|
2020-06-13 05:04:01 +02:00
|
|
|
func (er erasureObjects) removeObjectPart(bucket, object, uploadID, dataDir string, partNumber int) {
|
|
|
|
uploadIDPath := er.getUploadIDDir(bucket, object, uploadID)
|
|
|
|
curpartPath := pathJoin(uploadIDPath, dataDir, fmt.Sprintf("part.%d", partNumber))
|
|
|
|
storageDisks := er.getDisks()
|
2019-10-14 18:44:51 +02:00
|
|
|
|
|
|
|
g := errgroup.WithNErrs(len(storageDisks))
|
|
|
|
for index, disk := range storageDisks {
|
2017-01-26 21:51:12 +01:00
|
|
|
if disk == nil {
|
|
|
|
continue
|
|
|
|
}
|
2019-10-14 18:44:51 +02:00
|
|
|
index := index
|
|
|
|
g.Go(func() error {
|
2017-01-26 21:51:12 +01:00
|
|
|
// Ignoring failure to remove parts that weren't present in CompleteMultipartUpload
|
2020-06-13 05:04:01 +02:00
|
|
|
// requests. xl.meta is the authoritative source of truth on which parts constitute
|
2017-01-26 21:51:12 +01:00
|
|
|
// the object. The presence of parts that don't belong in the object doesn't affect correctness.
|
2020-10-28 17:18:35 +01:00
|
|
|
_ = storageDisks[index].Delete(context.TODO(), minioMetaMultipartBucket, curpartPath, false)
|
2019-10-14 18:44:51 +02:00
|
|
|
return nil
|
|
|
|
}, index)
|
2017-01-26 21:51:12 +01:00
|
|
|
}
|
2019-10-14 18:44:51 +02:00
|
|
|
g.Wait()
|
2017-01-26 21:51:12 +01:00
|
|
|
}
|
|
|
|
|
2020-08-22 06:39:54 +02:00
|
|
|
// Clean-up the old multipart uploads. Should be run in a Go routine.
|
2020-12-10 16:28:37 +01:00
|
|
|
func (er erasureObjects) cleanupStaleUploads(ctx context.Context, expiry time.Duration) {
|
|
|
|
// run multiple cleanup's local to this server.
|
2021-02-11 19:22:03 +01:00
|
|
|
var wg sync.WaitGroup
|
2020-12-10 16:28:37 +01:00
|
|
|
for _, disk := range er.getLoadBalancedLocalDisks() {
|
|
|
|
if disk != nil {
|
2021-02-11 19:22:03 +01:00
|
|
|
wg.Add(1)
|
|
|
|
go func(disk StorageAPI) {
|
|
|
|
defer wg.Done()
|
|
|
|
er.cleanupStaleUploadsOnDisk(ctx, disk, expiry)
|
|
|
|
}(disk)
|
2020-08-22 06:39:54 +02:00
|
|
|
}
|
|
|
|
}
|
2021-02-11 19:22:03 +01:00
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (er erasureObjects) renameAll(ctx context.Context, bucket, prefix string) {
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
for _, disk := range er.getDisks() {
|
|
|
|
if disk == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
wg.Add(1)
|
|
|
|
go func(disk StorageAPI) {
|
|
|
|
defer wg.Done()
|
|
|
|
disk.RenameFile(ctx, bucket, prefix, minioMetaTmpBucket, mustGetUUID())
|
|
|
|
}(disk)
|
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (er erasureObjects) deleteAll(ctx context.Context, bucket, prefix string) {
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
for _, disk := range er.getDisks() {
|
|
|
|
if disk == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
wg.Add(1)
|
|
|
|
go func(disk StorageAPI) {
|
|
|
|
defer wg.Done()
|
|
|
|
disk.Delete(ctx, bucket, prefix, true)
|
|
|
|
}(disk)
|
|
|
|
}
|
|
|
|
wg.Wait()
|
2020-08-22 06:39:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove the old multipart uploads on the given disk.
|
2020-09-09 00:55:40 +02:00
|
|
|
func (er erasureObjects) cleanupStaleUploadsOnDisk(ctx context.Context, disk StorageAPI, expiry time.Duration) {
|
2020-08-22 06:39:54 +02:00
|
|
|
now := time.Now()
|
2021-02-26 18:52:27 +01:00
|
|
|
diskPath := disk.Endpoint().Path
|
|
|
|
|
|
|
|
readDirFn(pathJoin(diskPath, minioMetaMultipartBucket), func(shaDir string, typ os.FileMode) error {
|
|
|
|
return readDirFn(pathJoin(diskPath, minioMetaMultipartBucket, shaDir), func(uploadIDDir string, typ os.FileMode) error {
|
2020-08-22 06:39:54 +02:00
|
|
|
uploadIDPath := pathJoin(shaDir, uploadIDDir)
|
2021-01-08 04:27:31 +01:00
|
|
|
fi, err := disk.ReadVersion(ctx, minioMetaMultipartBucket, uploadIDPath, "", false)
|
2020-08-22 06:39:54 +02:00
|
|
|
if err != nil {
|
2021-02-26 18:52:27 +01:00
|
|
|
return nil
|
2020-08-22 06:39:54 +02:00
|
|
|
}
|
2021-02-26 18:52:27 +01:00
|
|
|
wait := er.deletedCleanupSleeper.Timer(ctx)
|
2020-08-22 06:39:54 +02:00
|
|
|
if now.Sub(fi.ModTime) > expiry {
|
2021-02-11 19:22:03 +01:00
|
|
|
er.renameAll(ctx, minioMetaMultipartBucket, uploadIDPath)
|
2020-08-22 06:39:54 +02:00
|
|
|
}
|
2021-02-26 18:52:27 +01:00
|
|
|
wait()
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
readDirFn(pathJoin(diskPath, minioMetaTmpBucket), func(tmpDir string, typ os.FileMode) error {
|
|
|
|
if tmpDir == ".trash/" { // do not remove .trash/ here, it has its own routines
|
|
|
|
return nil
|
2020-08-22 06:39:54 +02:00
|
|
|
}
|
2021-02-11 19:22:03 +01:00
|
|
|
vi, err := disk.StatVol(ctx, pathJoin(minioMetaTmpBucket, tmpDir))
|
2020-09-09 00:55:40 +02:00
|
|
|
if err != nil {
|
2021-02-26 18:52:27 +01:00
|
|
|
return nil
|
2020-09-09 00:55:40 +02:00
|
|
|
}
|
2021-02-26 18:52:27 +01:00
|
|
|
wait := er.deletedCleanupSleeper.Timer(ctx)
|
2021-02-11 19:22:03 +01:00
|
|
|
if now.Sub(vi.Created) > expiry {
|
|
|
|
er.deleteAll(ctx, minioMetaTmpBucket, tmpDir)
|
2020-09-09 00:55:40 +02:00
|
|
|
}
|
2021-02-26 18:52:27 +01:00
|
|
|
wait()
|
|
|
|
return nil
|
|
|
|
})
|
2020-08-22 06:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-12-01 00:58:46 +01:00
|
|
|
// ListMultipartUploads - lists all the pending multipart
|
|
|
|
// uploads for a particular object in a bucket.
|
|
|
|
//
|
|
|
|
// Implements minimal S3 compatible ListMultipartUploads API. We do
|
|
|
|
// not support prefix based listing, this is a deliberate attempt
|
|
|
|
// towards simplification of multipart APIs.
|
|
|
|
// The resulting ListMultipartsInfo structure is unmarshalled directly as XML.
|
2020-07-04 04:27:13 +02:00
|
|
|
func (er erasureObjects) ListMultipartUploads(ctx context.Context, bucket, object, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result ListMultipartsInfo, err error) {
|
2017-12-01 00:58:46 +01:00
|
|
|
result.MaxUploads = maxUploads
|
|
|
|
result.KeyMarker = keyMarker
|
|
|
|
result.Prefix = object
|
|
|
|
result.Delimiter = delimiter
|
|
|
|
|
2020-07-04 04:27:13 +02:00
|
|
|
var uploadIDs []string
|
2020-09-29 04:39:32 +02:00
|
|
|
var disk StorageAPI
|
2020-10-10 00:40:46 +02:00
|
|
|
for _, disk = range er.getLoadBalancedDisks(true) {
|
2020-09-04 18:45:06 +02:00
|
|
|
uploadIDs, err = disk.ListDir(ctx, minioMetaMultipartBucket, er.getMultipartSHADir(bucket, object), -1)
|
2016-06-02 01:43:31 +02:00
|
|
|
if err != nil {
|
2020-07-04 04:27:13 +02:00
|
|
|
if err == errDiskNotFound {
|
|
|
|
continue
|
|
|
|
}
|
2018-03-15 21:55:23 +01:00
|
|
|
if err == errFileNotFound {
|
|
|
|
return result, nil
|
|
|
|
}
|
2018-04-06 00:04:40 +02:00
|
|
|
logger.LogIf(ctx, err)
|
2020-07-04 04:27:13 +02:00
|
|
|
return result, toObjectErr(err, bucket, object)
|
2016-06-02 01:43:31 +02:00
|
|
|
}
|
2020-07-04 04:27:13 +02:00
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := range uploadIDs {
|
|
|
|
uploadIDs[i] = strings.TrimSuffix(uploadIDs[i], SlashSeparator)
|
|
|
|
}
|
|
|
|
|
|
|
|
// S3 spec says uploadIDs should be sorted based on initiated time, we need
|
|
|
|
// to read the metadata entry.
|
|
|
|
var uploads []MultipartInfo
|
|
|
|
|
|
|
|
populatedUploadIds := set.NewStringSet()
|
|
|
|
|
2020-09-29 04:39:32 +02:00
|
|
|
for _, uploadID := range uploadIDs {
|
|
|
|
if populatedUploadIds.Contains(uploadID) {
|
2020-07-04 04:27:13 +02:00
|
|
|
continue
|
2016-06-02 01:43:31 +02:00
|
|
|
}
|
2021-01-08 04:27:31 +01:00
|
|
|
fi, err := disk.ReadVersion(ctx, minioMetaMultipartBucket, pathJoin(er.getUploadIDDir(bucket, object, uploadID)), "", false)
|
2020-09-29 04:39:32 +02:00
|
|
|
if err != nil {
|
|
|
|
return result, toObjectErr(err, bucket, object)
|
2017-12-01 00:58:46 +01:00
|
|
|
}
|
2020-09-29 04:39:32 +02:00
|
|
|
populatedUploadIds.Add(uploadID)
|
|
|
|
uploads = append(uploads, MultipartInfo{
|
|
|
|
Object: object,
|
|
|
|
UploadID: uploadID,
|
|
|
|
Initiated: fi.ModTime,
|
|
|
|
})
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
2016-12-02 08:15:17 +01:00
|
|
|
|
2020-07-04 04:27:13 +02:00
|
|
|
sort.Slice(uploads, func(i int, j int) bool {
|
|
|
|
return uploads[i].Initiated.Before(uploads[j].Initiated)
|
|
|
|
})
|
|
|
|
|
|
|
|
uploadIndex := 0
|
|
|
|
if uploadIDMarker != "" {
|
|
|
|
for uploadIndex < len(uploads) {
|
|
|
|
if uploads[uploadIndex].UploadID != uploadIDMarker {
|
|
|
|
uploadIndex++
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if uploads[uploadIndex].UploadID == uploadIDMarker {
|
|
|
|
uploadIndex++
|
|
|
|
break
|
|
|
|
}
|
|
|
|
uploadIndex++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for uploadIndex < len(uploads) {
|
|
|
|
result.Uploads = append(result.Uploads, uploads[uploadIndex])
|
|
|
|
result.NextUploadIDMarker = uploads[uploadIndex].UploadID
|
|
|
|
uploadIndex++
|
|
|
|
if len(result.Uploads) == maxUploads {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result.IsTruncated = uploadIndex < len(uploads)
|
|
|
|
|
|
|
|
if !result.IsTruncated {
|
|
|
|
result.NextKeyMarker = ""
|
|
|
|
result.NextUploadIDMarker = ""
|
|
|
|
}
|
|
|
|
|
2017-12-01 00:58:46 +01:00
|
|
|
return result, nil
|
2016-06-02 01:43:31 +02:00
|
|
|
}
|
2016-05-21 05:48:47 +02:00
|
|
|
|
2016-06-02 01:43:31 +02:00
|
|
|
// newMultipartUpload - wrapper for initializing a new multipart
|
2016-10-25 02:37:18 +02:00
|
|
|
// request; returns a unique upload id.
|
2016-06-02 01:43:31 +02:00
|
|
|
//
|
|
|
|
// Internally this function creates 'uploads.json' associated for the
|
2016-10-25 02:37:18 +02:00
|
|
|
// incoming object at
|
|
|
|
// '.minio.sys/multipart/bucket/object/uploads.json' on all the
|
|
|
|
// disks. `uploads.json` carries metadata regarding on-going multipart
|
|
|
|
// operation(s) on the object.
|
2020-06-13 05:04:01 +02:00
|
|
|
func (er erasureObjects) newMultipartUpload(ctx context.Context, bucket string, object string, opts ObjectOptions) (string, error) {
|
|
|
|
onlineDisks := er.getDisks()
|
|
|
|
parityBlocks := globalStorageClass.GetParityForSC(opts.UserDefined[xhttp.AmzStorageClass])
|
2021-01-16 21:08:02 +01:00
|
|
|
if parityBlocks <= 0 {
|
|
|
|
parityBlocks = er.defaultParityCount
|
2019-10-07 07:50:24 +02:00
|
|
|
}
|
2017-12-22 12:28:13 +01:00
|
|
|
|
2021-01-16 21:08:02 +01:00
|
|
|
dataBlocks := len(onlineDisks) - parityBlocks
|
2021-02-25 19:11:31 +01:00
|
|
|
fi := newFileInfo(pathJoin(bucket, object), dataBlocks, parityBlocks)
|
2017-12-22 12:28:13 +01:00
|
|
|
|
|
|
|
// we now know the number of blocks this object needs for data and parity.
|
|
|
|
// establish the writeQuorum using this data
|
2020-06-10 04:19:03 +02:00
|
|
|
writeQuorum := dataBlocks
|
|
|
|
if dataBlocks == parityBlocks {
|
2021-01-16 21:08:02 +01:00
|
|
|
writeQuorum++
|
2020-06-10 04:19:03 +02:00
|
|
|
}
|
2017-12-22 12:28:13 +01:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
if opts.UserDefined["content-type"] == "" {
|
2018-10-02 08:18:17 +02:00
|
|
|
contentType := mimedb.TypeByExtension(path.Ext(object))
|
2020-06-13 05:04:01 +02:00
|
|
|
opts.UserDefined["content-type"] = contentType
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate the version to be saved.
|
|
|
|
if opts.Versioned {
|
2020-06-17 20:13:41 +02:00
|
|
|
fi.VersionID = opts.VersionID
|
|
|
|
if fi.VersionID == "" {
|
|
|
|
fi.VersionID = mustGetUUID()
|
|
|
|
}
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
2020-06-13 05:04:01 +02:00
|
|
|
|
|
|
|
fi.DataDir = mustGetUUID()
|
|
|
|
fi.ModTime = UTCNow()
|
2020-09-10 20:37:22 +02:00
|
|
|
fi.Metadata = cloneMSS(opts.UserDefined)
|
2016-05-21 05:48:47 +02:00
|
|
|
|
2016-11-23 01:52:37 +01:00
|
|
|
uploadID := mustGetUUID()
|
2020-06-13 05:04:01 +02:00
|
|
|
uploadIDPath := er.getUploadIDDir(bucket, object, uploadID)
|
2016-11-20 23:25:43 +01:00
|
|
|
tempUploadIDPath := uploadID
|
2017-08-15 03:08:42 +02:00
|
|
|
|
2019-04-25 16:33:26 +02:00
|
|
|
// Delete the tmp path later in case we fail to commit (ignore
|
|
|
|
// returned errors) - this will be a no-op in case of a commit
|
|
|
|
// success.
|
2021-03-24 22:19:52 +01:00
|
|
|
var online int
|
|
|
|
defer func() {
|
|
|
|
if online != len(onlineDisks) {
|
|
|
|
er.deleteObject(context.Background(), minioMetaTmpBucket, tempUploadIDPath, writeQuorum)
|
|
|
|
}
|
|
|
|
}()
|
2019-04-25 16:33:26 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
var partsMetadata = make([]FileInfo, len(onlineDisks))
|
2019-09-11 19:22:12 +02:00
|
|
|
for i := range onlineDisks {
|
2020-06-13 05:04:01 +02:00
|
|
|
partsMetadata[i] = fi
|
2019-09-11 19:22:12 +02:00
|
|
|
}
|
|
|
|
|
2020-10-28 08:09:15 +01:00
|
|
|
onlineDisks, partsMetadata = shuffleDisksAndPartsMetadata(onlineDisks, partsMetadata, fi.Erasure.Distribution)
|
|
|
|
|
2019-09-11 19:22:12 +02:00
|
|
|
var err error
|
2020-06-13 05:04:01 +02:00
|
|
|
// Write updated `xl.meta` to all disks.
|
|
|
|
onlineDisks, err = writeUniqueFileInfo(ctx, onlineDisks, minioMetaTmpBucket, tempUploadIDPath, partsMetadata, writeQuorum)
|
2017-01-31 18:38:34 +01:00
|
|
|
if err != nil {
|
2016-11-20 23:25:43 +01:00
|
|
|
return "", toObjectErr(err, minioMetaTmpBucket, tempUploadIDPath)
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
2016-10-25 02:37:18 +02:00
|
|
|
|
2017-02-22 04:43:44 +01:00
|
|
|
// Attempt to rename temp upload object to actual upload path object
|
2019-09-11 19:22:12 +02:00
|
|
|
_, err = rename(ctx, onlineDisks, minioMetaTmpBucket, tempUploadIDPath, minioMetaMultipartBucket, uploadIDPath, true, writeQuorum, nil)
|
|
|
|
if err != nil {
|
|
|
|
return "", toObjectErr(err, minioMetaMultipartBucket, uploadIDPath)
|
2016-10-25 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
2021-03-24 22:19:52 +01:00
|
|
|
online = countOnlineDisks(onlineDisks)
|
|
|
|
|
2016-10-25 02:37:18 +02:00
|
|
|
// Return success.
|
|
|
|
return uploadID, nil
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
|
|
|
|
2016-06-02 01:43:31 +02:00
|
|
|
// NewMultipartUpload - initialize a new multipart upload, returns a
|
|
|
|
// unique id. The unique id returned here is of UUID form, for each
|
|
|
|
// subsequent request each UUID is unique.
|
|
|
|
//
|
|
|
|
// Implements S3 compatible initiate multipart API.
|
2020-06-13 05:04:01 +02:00
|
|
|
func (er erasureObjects) NewMultipartUpload(ctx context.Context, bucket, object string, opts ObjectOptions) (string, error) {
|
2016-06-02 01:43:31 +02:00
|
|
|
// No metadata is set, allocate a new one.
|
2019-02-09 06:31:06 +01:00
|
|
|
if opts.UserDefined == nil {
|
|
|
|
opts.UserDefined = make(map[string]string)
|
2016-06-02 01:43:31 +02:00
|
|
|
}
|
2020-06-13 05:04:01 +02:00
|
|
|
return er.newMultipartUpload(ctx, bucket, object, opts)
|
2016-06-02 01:43:31 +02:00
|
|
|
}
|
|
|
|
|
2017-01-31 18:38:34 +01:00
|
|
|
// CopyObjectPart - reads incoming stream and internally erasure codes
|
|
|
|
// them. This call is similar to put object part operation but the source
|
|
|
|
// data is read from an existing object.
|
|
|
|
//
|
|
|
|
// Implements S3 compatible Upload Part Copy API.
|
2020-06-13 05:04:01 +02:00
|
|
|
func (er erasureObjects) CopyObjectPart(ctx context.Context, srcBucket, srcObject, dstBucket, dstObject, uploadID string, partID int, startOffset int64, length int64, srcInfo ObjectInfo, srcOpts, dstOpts ObjectOptions) (pi PartInfo, e error) {
|
2021-02-10 17:52:50 +01:00
|
|
|
partInfo, err := er.PutObjectPart(ctx, dstBucket, dstObject, uploadID, partID, NewPutObjReader(srcInfo.Reader), dstOpts)
|
2017-10-22 07:30:34 +02:00
|
|
|
if err != nil {
|
|
|
|
return pi, toObjectErr(err, dstBucket, dstObject)
|
|
|
|
}
|
|
|
|
|
2017-01-31 18:38:34 +01:00
|
|
|
// Success.
|
|
|
|
return partInfo, nil
|
|
|
|
}
|
|
|
|
|
2016-07-05 10:04:50 +02:00
|
|
|
// PutObjectPart - reads incoming stream and internally erasure codes
|
|
|
|
// them. This call is similar to single put operation but it is part
|
2016-08-05 07:01:58 +02:00
|
|
|
// of the multipart transaction.
|
2016-07-05 10:04:50 +02:00
|
|
|
//
|
|
|
|
// Implements S3 compatible Upload Part API.
|
2020-09-15 00:57:13 +02:00
|
|
|
func (er erasureObjects) PutObjectPart(ctx context.Context, bucket, object, uploadID string, partID int, r *PutObjReader, opts ObjectOptions) (pi PartInfo, err error) {
|
2020-11-04 17:25:42 +01:00
|
|
|
uploadIDLock := er.NewNSLock(bucket, pathJoin(object, uploadID))
|
2021-03-04 03:36:43 +01:00
|
|
|
ctx, err = uploadIDLock.GetRLock(ctx, globalOperationTimeout)
|
|
|
|
if err != nil {
|
2020-09-15 00:57:13 +02:00
|
|
|
return PartInfo{}, err
|
|
|
|
}
|
|
|
|
readLocked := true
|
|
|
|
defer func() {
|
|
|
|
if readLocked {
|
|
|
|
uploadIDLock.RUnlock()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2018-11-15 02:36:41 +01:00
|
|
|
data := r.Reader
|
2017-10-06 18:38:01 +02:00
|
|
|
// Validate input data size and it can never be less than zero.
|
2018-09-28 05:36:17 +02:00
|
|
|
if data.Size() < -1 {
|
2019-10-12 03:50:54 +02:00
|
|
|
logger.LogIf(ctx, errInvalidArgument, logger.Application)
|
2018-04-06 00:04:40 +02:00
|
|
|
return pi, toObjectErr(errInvalidArgument)
|
2017-10-06 18:38:01 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
var partsMetadata []FileInfo
|
2016-07-12 02:24:49 +02:00
|
|
|
var errs []error
|
2020-06-13 05:04:01 +02:00
|
|
|
uploadIDPath := er.getUploadIDDir(bucket, object, uploadID)
|
2017-10-06 18:38:01 +02:00
|
|
|
|
2016-07-12 02:24:49 +02:00
|
|
|
// Validates if upload ID exists.
|
2020-09-15 00:57:13 +02:00
|
|
|
if err = er.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil {
|
2019-04-23 23:54:28 +02:00
|
|
|
return pi, toObjectErr(err, bucket, object, uploadID)
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
2017-01-31 18:38:34 +01:00
|
|
|
|
2020-12-07 19:04:07 +01:00
|
|
|
storageDisks := er.getDisks()
|
|
|
|
|
2016-06-01 05:23:31 +02:00
|
|
|
// Read metadata associated with the object from all disks.
|
2020-12-07 19:04:07 +01:00
|
|
|
partsMetadata, errs = readAllFileInfo(ctx, storageDisks, minioMetaMultipartBucket,
|
2021-01-08 04:27:31 +01:00
|
|
|
uploadIDPath, "", false)
|
2017-12-22 12:28:13 +01:00
|
|
|
|
|
|
|
// get Quorum for this object
|
2021-01-16 21:08:02 +01:00
|
|
|
_, writeQuorum, err := objectQuorumFromMeta(ctx, partsMetadata, errs, er.defaultParityCount)
|
2017-12-22 12:28:13 +01:00
|
|
|
if err != nil {
|
|
|
|
return pi, toObjectErr(err, bucket, object)
|
|
|
|
}
|
|
|
|
|
2018-04-06 00:04:40 +02:00
|
|
|
reducedErr := reduceWriteQuorumErrs(ctx, errs, objectOpIgnoredErrs, writeQuorum)
|
2020-06-13 05:04:01 +02:00
|
|
|
if reducedErr == errErasureWriteQuorum {
|
2017-06-22 04:53:09 +02:00
|
|
|
return pi, toObjectErr(reducedErr, bucket, object)
|
2016-06-27 19:01:09 +02:00
|
|
|
}
|
2016-05-30 20:26:10 +02:00
|
|
|
|
2016-05-26 01:42:31 +02:00
|
|
|
// List all online disks.
|
2020-12-07 19:04:07 +01:00
|
|
|
onlineDisks, modTime := listOnlineDisks(storageDisks, partsMetadata, errs)
|
2016-07-13 00:20:31 +02:00
|
|
|
|
|
|
|
// Pick one from the first valid metadata.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi, err := pickValidFileInfo(ctx, partsMetadata, modTime, writeQuorum)
|
2016-11-21 05:56:44 +01:00
|
|
|
if err != nil {
|
2017-06-22 04:53:09 +02:00
|
|
|
return pi, err
|
2016-11-21 05:56:44 +01:00
|
|
|
}
|
2016-07-14 23:59:01 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
onlineDisks = shuffleDisks(onlineDisks, fi.Erasure.Distribution)
|
2016-05-27 04:55:48 +02:00
|
|
|
|
2016-07-12 02:24:49 +02:00
|
|
|
// Need a unique name for the part being written in minioMetaBucket to
|
|
|
|
// accommodate concurrent PutObjectPart requests
|
2016-07-13 00:20:31 +02:00
|
|
|
|
2016-06-28 06:42:33 +02:00
|
|
|
partSuffix := fmt.Sprintf("part.%d", partID)
|
2016-11-23 01:52:37 +01:00
|
|
|
tmpPart := mustGetUUID()
|
2020-06-13 05:04:01 +02:00
|
|
|
tmpPartPath := pathJoin(tmpPart, partSuffix)
|
2016-05-21 05:48:47 +02:00
|
|
|
|
2016-10-20 07:52:03 +02:00
|
|
|
// Delete the temporary object part. If PutObjectPart succeeds there would be nothing to delete.
|
2021-03-24 22:19:52 +01:00
|
|
|
var online int
|
|
|
|
defer func() {
|
|
|
|
if online != len(onlineDisks) {
|
|
|
|
er.deleteObject(context.Background(), minioMetaTmpBucket, tmpPart, writeQuorum)
|
|
|
|
}
|
|
|
|
}()
|
2018-11-26 22:20:21 +01:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
erasure, err := NewErasure(ctx, fi.Erasure.DataBlocks, fi.Erasure.ParityBlocks, fi.Erasure.BlockSize)
|
2017-08-15 03:08:42 +02:00
|
|
|
if err != nil {
|
|
|
|
return pi, toObjectErr(err, bucket, object)
|
|
|
|
}
|
2018-02-16 02:45:57 +01:00
|
|
|
|
|
|
|
// Fetch buffer for I/O, returns from the pool if not allocates a new one and returns.
|
2018-06-13 20:55:12 +02:00
|
|
|
var buffer []byte
|
|
|
|
switch size := data.Size(); {
|
|
|
|
case size == 0:
|
|
|
|
buffer = make([]byte, 1) // Allocate atleast a byte to reach EOF
|
2021-03-04 01:28:10 +01:00
|
|
|
case size == -1:
|
|
|
|
if size := data.ActualSize(); size > 0 && size < fi.Erasure.BlockSize {
|
|
|
|
buffer = make([]byte, data.ActualSize()+256, data.ActualSize()*2+512)
|
|
|
|
} else {
|
|
|
|
buffer = er.bp.Get()
|
|
|
|
defer er.bp.Put(buffer)
|
|
|
|
}
|
|
|
|
case size >= fi.Erasure.BlockSize:
|
2020-06-13 05:04:01 +02:00
|
|
|
buffer = er.bp.Get()
|
|
|
|
defer er.bp.Put(buffer)
|
|
|
|
case size < fi.Erasure.BlockSize:
|
|
|
|
// No need to allocate fully fi.Erasure.BlockSize buffer if the incoming data is smaller.
|
|
|
|
buffer = make([]byte, size, 2*size+int64(fi.Erasure.ParityBlocks+fi.Erasure.DataBlocks-1))
|
2018-06-13 20:55:12 +02:00
|
|
|
}
|
2018-02-16 02:45:57 +01:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
if len(buffer) > int(fi.Erasure.BlockSize) {
|
|
|
|
buffer = buffer[:fi.Erasure.BlockSize]
|
2018-08-07 00:14:08 +02:00
|
|
|
}
|
2019-01-17 13:58:18 +01:00
|
|
|
writers := make([]io.Writer, len(onlineDisks))
|
2018-08-07 00:14:08 +02:00
|
|
|
for i, disk := range onlineDisks {
|
|
|
|
if disk == nil {
|
|
|
|
continue
|
|
|
|
}
|
2021-03-18 22:09:55 +01:00
|
|
|
writers[i] = newBitrotWriter(disk, minioMetaTmpBucket, tmpPartPath,
|
|
|
|
erasure.ShardFileSize(data.Size()), DefaultBitrotAlgorithm, erasure.ShardSize(), false)
|
2018-08-07 00:14:08 +02:00
|
|
|
}
|
2018-11-26 22:20:21 +01:00
|
|
|
|
2020-08-03 21:15:08 +02:00
|
|
|
n, err := erasure.Encode(ctx, data, writers, buffer, writeQuorum)
|
2019-01-17 13:58:18 +01:00
|
|
|
closeBitrotWriters(writers)
|
2016-07-19 04:06:48 +02:00
|
|
|
if err != nil {
|
2017-06-22 04:53:09 +02:00
|
|
|
return pi, toObjectErr(err, bucket, object)
|
2016-07-19 04:06:48 +02:00
|
|
|
}
|
2016-10-20 07:52:03 +02:00
|
|
|
|
2016-07-19 04:06:48 +02:00
|
|
|
// Should return IncompleteBody{} error when reader has fewer bytes
|
|
|
|
// than specified in request header.
|
2018-08-07 00:14:08 +02:00
|
|
|
if n < data.Size() {
|
2020-09-08 23:22:04 +02:00
|
|
|
return pi, IncompleteBody{Bucket: bucket, Object: object}
|
2016-07-19 04:06:48 +02:00
|
|
|
}
|
2016-07-01 23:33:28 +02:00
|
|
|
|
2018-08-07 00:14:08 +02:00
|
|
|
for i := range writers {
|
|
|
|
if writers[i] == nil {
|
|
|
|
onlineDisks[i] = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-15 00:57:13 +02:00
|
|
|
// Unlock here before acquiring write locks all concurrent
|
|
|
|
// PutObjectParts would serialize here updating `xl.meta`
|
|
|
|
uploadIDLock.RUnlock()
|
|
|
|
readLocked = false
|
2021-03-04 03:36:43 +01:00
|
|
|
ctx, err = uploadIDLock.GetLock(ctx, globalOperationTimeout)
|
|
|
|
if err != nil {
|
2020-09-15 00:57:13 +02:00
|
|
|
return PartInfo{}, err
|
|
|
|
}
|
|
|
|
defer uploadIDLock.Unlock()
|
|
|
|
|
2019-04-23 23:54:28 +02:00
|
|
|
// Validates if upload ID exists.
|
2020-09-15 00:57:13 +02:00
|
|
|
if err = er.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil {
|
2019-04-23 23:54:28 +02:00
|
|
|
return pi, toObjectErr(err, bucket, object, uploadID)
|
2016-05-30 20:26:10 +02:00
|
|
|
}
|
|
|
|
|
2016-05-30 00:38:14 +02:00
|
|
|
// Rename temporary part file to its final location.
|
2020-06-13 05:04:01 +02:00
|
|
|
partPath := pathJoin(uploadIDPath, fi.DataDir, partSuffix)
|
2018-10-05 02:22:49 +02:00
|
|
|
onlineDisks, err = rename(ctx, onlineDisks, minioMetaTmpBucket, tmpPartPath, minioMetaMultipartBucket, partPath, false, writeQuorum, nil)
|
2016-05-21 05:48:47 +02:00
|
|
|
if err != nil {
|
2017-06-22 04:53:09 +02:00
|
|
|
return pi, toObjectErr(err, minioMetaMultipartBucket, partPath)
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
2016-05-26 12:15:01 +02:00
|
|
|
|
2016-07-14 23:59:01 +02:00
|
|
|
// Read metadata again because it might be updated with parallel upload of another part.
|
2021-01-08 04:27:31 +01:00
|
|
|
partsMetadata, errs = readAllFileInfo(ctx, onlineDisks, minioMetaMultipartBucket, uploadIDPath, "", false)
|
2018-04-06 00:04:40 +02:00
|
|
|
reducedErr = reduceWriteQuorumErrs(ctx, errs, objectOpIgnoredErrs, writeQuorum)
|
2020-06-13 05:04:01 +02:00
|
|
|
if reducedErr == errErasureWriteQuorum {
|
2017-06-22 04:53:09 +02:00
|
|
|
return pi, toObjectErr(reducedErr, bucket, object)
|
2016-07-12 02:24:49 +02:00
|
|
|
}
|
|
|
|
|
2016-07-14 23:59:01 +02:00
|
|
|
// Get current highest version based on re-read partsMetadata.
|
|
|
|
onlineDisks, modTime = listOnlineDisks(onlineDisks, partsMetadata, errs)
|
2016-07-12 02:24:49 +02:00
|
|
|
|
|
|
|
// Pick one from the first valid metadata.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi, err = pickValidFileInfo(ctx, partsMetadata, modTime, writeQuorum)
|
2016-11-21 05:56:44 +01:00
|
|
|
if err != nil {
|
2017-06-22 04:53:09 +02:00
|
|
|
return pi, err
|
2016-11-21 05:56:44 +01:00
|
|
|
}
|
2016-07-12 02:24:49 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
// Once part is successfully committed, proceed with updating erasure metadata.
|
|
|
|
fi.ModTime = UTCNow()
|
2016-06-17 20:57:51 +02:00
|
|
|
|
2018-11-15 02:36:41 +01:00
|
|
|
md5hex := r.MD5CurrentHexString()
|
2017-10-22 07:30:34 +02:00
|
|
|
|
2016-06-01 05:23:31 +02:00
|
|
|
// Add the current part.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi.AddObjectPart(partID, md5hex, n, data.ActualSize())
|
2016-05-26 12:15:01 +02:00
|
|
|
|
2017-08-15 03:08:42 +02:00
|
|
|
for i, disk := range onlineDisks {
|
|
|
|
if disk == OfflineDisk {
|
2016-07-14 23:59:01 +02:00
|
|
|
continue
|
|
|
|
}
|
2020-06-13 05:04:01 +02:00
|
|
|
partsMetadata[i].Size = fi.Size
|
|
|
|
partsMetadata[i].ModTime = fi.ModTime
|
|
|
|
partsMetadata[i].Parts = fi.Parts
|
2020-03-03 01:29:30 +01:00
|
|
|
partsMetadata[i].Erasure.AddChecksumInfo(ChecksumInfo{
|
|
|
|
PartNumber: partID,
|
|
|
|
Algorithm: DefaultBitrotAlgorithm,
|
|
|
|
Hash: bitrotWriterSum(writers[i]),
|
|
|
|
})
|
2016-06-01 05:23:31 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
// Writes update `xl.meta` format for each disk.
|
|
|
|
if _, err = writeUniqueFileInfo(ctx, onlineDisks, minioMetaMultipartBucket, uploadIDPath, partsMetadata, writeQuorum); err != nil {
|
2017-08-24 02:58:52 +02:00
|
|
|
return pi, toObjectErr(err, minioMetaMultipartBucket, uploadIDPath)
|
2017-01-31 18:38:34 +01:00
|
|
|
}
|
|
|
|
|
2021-03-24 22:19:52 +01:00
|
|
|
online = countOnlineDisks(onlineDisks)
|
|
|
|
|
2016-05-29 00:13:15 +02:00
|
|
|
// Return success.
|
2017-01-31 18:38:34 +01:00
|
|
|
return PartInfo{
|
|
|
|
PartNumber: partID,
|
2017-10-22 07:30:34 +02:00
|
|
|
ETag: md5hex,
|
2020-06-13 05:04:01 +02:00
|
|
|
LastModified: fi.ModTime,
|
|
|
|
Size: fi.Size,
|
2018-09-28 05:36:17 +02:00
|
|
|
ActualSize: data.ActualSize(),
|
2017-01-31 18:38:34 +01:00
|
|
|
}, nil
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
|
|
|
|
2020-05-28 21:36:20 +02:00
|
|
|
// GetMultipartInfo returns multipart metadata uploaded during newMultipartUpload, used
|
|
|
|
// by callers to verify object states
|
|
|
|
// - encrypted
|
|
|
|
// - compressed
|
2020-06-13 05:04:01 +02:00
|
|
|
func (er erasureObjects) GetMultipartInfo(ctx context.Context, bucket, object, uploadID string, opts ObjectOptions) (MultipartInfo, error) {
|
2020-05-28 21:36:20 +02:00
|
|
|
result := MultipartInfo{
|
|
|
|
Bucket: bucket,
|
|
|
|
Object: object,
|
|
|
|
UploadID: uploadID,
|
|
|
|
}
|
|
|
|
|
2021-03-04 03:36:43 +01:00
|
|
|
var err error
|
2020-11-04 17:25:42 +01:00
|
|
|
uploadIDLock := er.NewNSLock(bucket, pathJoin(object, uploadID))
|
2021-03-04 03:36:43 +01:00
|
|
|
ctx, err = uploadIDLock.GetRLock(ctx, globalOperationTimeout)
|
|
|
|
if err != nil {
|
2020-09-15 00:57:13 +02:00
|
|
|
return MultipartInfo{}, err
|
|
|
|
}
|
|
|
|
defer uploadIDLock.RUnlock()
|
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
if err := er.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil {
|
2020-05-28 21:36:20 +02:00
|
|
|
return result, toObjectErr(err, bucket, object, uploadID)
|
|
|
|
}
|
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
uploadIDPath := er.getUploadIDDir(bucket, object, uploadID)
|
2020-05-28 21:36:20 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
storageDisks := er.getDisks()
|
2020-05-28 21:36:20 +02:00
|
|
|
|
|
|
|
// Read metadata associated with the object from all disks.
|
2021-01-08 04:27:31 +01:00
|
|
|
partsMetadata, errs := readAllFileInfo(ctx, storageDisks, minioMetaMultipartBucket, uploadIDPath, opts.VersionID, false)
|
2020-05-28 21:36:20 +02:00
|
|
|
|
|
|
|
// get Quorum for this object
|
2021-01-16 21:08:02 +01:00
|
|
|
readQuorum, _, err := objectQuorumFromMeta(ctx, partsMetadata, errs, er.defaultParityCount)
|
2020-05-28 21:36:20 +02:00
|
|
|
if err != nil {
|
|
|
|
return result, toObjectErr(err, minioMetaMultipartBucket, uploadIDPath)
|
|
|
|
}
|
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
reducedErr := reduceWriteQuorumErrs(ctx, errs, objectOpIgnoredErrs, readQuorum)
|
|
|
|
if reducedErr == errErasureReadQuorum {
|
2020-05-28 21:36:20 +02:00
|
|
|
return result, toObjectErr(reducedErr, minioMetaMultipartBucket, uploadIDPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
_, modTime := listOnlineDisks(storageDisks, partsMetadata, errs)
|
|
|
|
|
|
|
|
// Pick one from the first valid metadata.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi, err := pickValidFileInfo(ctx, partsMetadata, modTime, readQuorum)
|
2020-05-28 21:36:20 +02:00
|
|
|
if err != nil {
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
|
2020-09-10 20:37:22 +02:00
|
|
|
result.UserDefined = cloneMSS(fi.Metadata)
|
2020-05-28 21:36:20 +02:00
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2018-03-15 21:55:23 +01:00
|
|
|
// ListObjectParts - lists all previously uploaded parts for a given
|
|
|
|
// object and uploadID. Takes additional input of part-number-marker
|
|
|
|
// to indicate where the listing should begin from.
|
|
|
|
//
|
|
|
|
// Implements S3 compatible ListObjectParts API. The resulting
|
2018-06-29 01:02:02 +02:00
|
|
|
// ListPartsInfo structure is marshaled directly into XML and
|
2018-03-15 21:55:23 +01:00
|
|
|
// replied back to the client.
|
2021-03-04 03:36:43 +01:00
|
|
|
func (er erasureObjects) ListObjectParts(ctx context.Context, bucket, object, uploadID string, partNumberMarker, maxParts int, opts ObjectOptions) (result ListPartsInfo, err error) {
|
2020-11-04 17:25:42 +01:00
|
|
|
uploadIDLock := er.NewNSLock(bucket, pathJoin(object, uploadID))
|
2021-03-04 03:36:43 +01:00
|
|
|
ctx, err = uploadIDLock.GetRLock(ctx, globalOperationTimeout)
|
|
|
|
if err != nil {
|
2020-09-15 00:57:13 +02:00
|
|
|
return ListPartsInfo{}, err
|
|
|
|
}
|
|
|
|
defer uploadIDLock.RUnlock()
|
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
if err := er.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil {
|
2019-04-23 23:54:28 +02:00
|
|
|
return result, toObjectErr(err, bucket, object, uploadID)
|
2018-03-15 21:55:23 +01:00
|
|
|
}
|
2016-05-21 05:48:47 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
uploadIDPath := er.getUploadIDDir(bucket, object, uploadID)
|
2016-06-01 05:23:31 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
storageDisks := er.getDisks()
|
2019-02-01 17:58:41 +01:00
|
|
|
|
|
|
|
// Read metadata associated with the object from all disks.
|
2021-01-08 04:27:31 +01:00
|
|
|
partsMetadata, errs := readAllFileInfo(ctx, storageDisks, minioMetaMultipartBucket, uploadIDPath, "", false)
|
2019-02-01 17:58:41 +01:00
|
|
|
|
|
|
|
// get Quorum for this object
|
2021-01-16 21:08:02 +01:00
|
|
|
_, writeQuorum, err := objectQuorumFromMeta(ctx, partsMetadata, errs, er.defaultParityCount)
|
2016-05-21 05:48:47 +02:00
|
|
|
if err != nil {
|
2018-03-15 21:55:23 +01:00
|
|
|
return result, toObjectErr(err, minioMetaMultipartBucket, uploadIDPath)
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
2016-05-25 06:24:20 +02:00
|
|
|
|
2019-02-01 17:58:41 +01:00
|
|
|
reducedErr := reduceWriteQuorumErrs(ctx, errs, objectOpIgnoredErrs, writeQuorum)
|
2020-06-13 05:04:01 +02:00
|
|
|
if reducedErr == errErasureWriteQuorum {
|
2019-09-16 23:27:34 +02:00
|
|
|
return result, toObjectErr(reducedErr, minioMetaMultipartBucket, uploadIDPath)
|
2019-02-01 17:58:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_, modTime := listOnlineDisks(storageDisks, partsMetadata, errs)
|
|
|
|
|
|
|
|
// Pick one from the first valid metadata.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi, err := pickValidFileInfo(ctx, partsMetadata, modTime, writeQuorum)
|
2019-02-01 17:58:41 +01:00
|
|
|
if err != nil {
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
|
2016-05-25 06:24:20 +02:00
|
|
|
// Populate the result stub.
|
|
|
|
result.Bucket = bucket
|
|
|
|
result.Object = object
|
|
|
|
result.UploadID = uploadID
|
|
|
|
result.MaxParts = maxParts
|
2018-01-31 22:17:24 +01:00
|
|
|
result.PartNumberMarker = partNumberMarker
|
2020-09-10 20:37:22 +02:00
|
|
|
result.UserDefined = cloneMSS(fi.Metadata)
|
2016-05-25 06:24:20 +02:00
|
|
|
|
|
|
|
// For empty number of parts or maxParts as zero, return right here.
|
2020-06-13 05:04:01 +02:00
|
|
|
if len(fi.Parts) == 0 || maxParts == 0 {
|
2016-05-25 06:24:20 +02:00
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Limit output to maxPartsList.
|
|
|
|
if maxParts > maxPartsList {
|
|
|
|
maxParts = maxPartsList
|
|
|
|
}
|
|
|
|
|
2016-05-21 05:48:47 +02:00
|
|
|
// Only parts with higher part numbers will be listed.
|
2020-06-13 05:04:01 +02:00
|
|
|
partIdx := objectPartIndex(fi.Parts, partNumberMarker)
|
|
|
|
parts := fi.Parts
|
2016-05-25 06:24:20 +02:00
|
|
|
if partIdx != -1 {
|
2020-06-13 05:04:01 +02:00
|
|
|
parts = fi.Parts[partIdx+1:]
|
2016-05-25 06:24:20 +02:00
|
|
|
}
|
2016-05-21 05:48:47 +02:00
|
|
|
count := maxParts
|
2016-05-25 06:24:20 +02:00
|
|
|
for _, part := range parts {
|
2017-01-31 18:38:34 +01:00
|
|
|
result.Parts = append(result.Parts, PartInfo{
|
2016-05-25 06:24:20 +02:00
|
|
|
PartNumber: part.Number,
|
2016-05-21 05:48:47 +02:00
|
|
|
ETag: part.ETag,
|
2020-06-13 05:04:01 +02:00
|
|
|
LastModified: fi.ModTime,
|
2016-05-28 09:18:58 +02:00
|
|
|
Size: part.Size,
|
2016-05-21 05:48:47 +02:00
|
|
|
})
|
|
|
|
count--
|
|
|
|
if count == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// If listed entries are more than maxParts, we set IsTruncated as true.
|
|
|
|
if len(parts) > len(result.Parts) {
|
|
|
|
result.IsTruncated = true
|
|
|
|
// Make sure to fill next part number marker if IsTruncated is
|
|
|
|
// true for subsequent listing.
|
|
|
|
nextPartNumberMarker := result.Parts[len(result.Parts)-1].PartNumber
|
|
|
|
result.NextPartNumberMarker = nextPartNumberMarker
|
|
|
|
}
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2016-06-02 01:43:31 +02:00
|
|
|
// CompleteMultipartUpload - completes an ongoing multipart
|
|
|
|
// transaction after receiving all the parts indicated by the client.
|
|
|
|
// Returns an md5sum calculated by concatenating all the individual
|
|
|
|
// md5sums of all the parts.
|
|
|
|
//
|
|
|
|
// Implements S3 compatible Complete multipart API.
|
2020-09-15 00:57:13 +02:00
|
|
|
func (er erasureObjects) CompleteMultipartUpload(ctx context.Context, bucket string, object string, uploadID string, parts []CompletePart, opts ObjectOptions) (oi ObjectInfo, err error) {
|
|
|
|
// Hold read-locks to verify uploaded parts, also disallows
|
|
|
|
// parallel part uploads as well.
|
2020-11-04 17:25:42 +01:00
|
|
|
uploadIDLock := er.NewNSLock(bucket, pathJoin(object, uploadID))
|
2021-03-04 03:36:43 +01:00
|
|
|
ctx, err = uploadIDLock.GetRLock(ctx, globalOperationTimeout)
|
|
|
|
if err != nil {
|
2020-09-15 00:57:13 +02:00
|
|
|
return oi, err
|
|
|
|
}
|
|
|
|
defer uploadIDLock.RUnlock()
|
|
|
|
|
|
|
|
if err = er.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil {
|
2019-04-23 23:54:28 +02:00
|
|
|
return oi, toObjectErr(err, bucket, object, uploadID)
|
2016-05-28 06:50:09 +02:00
|
|
|
}
|
2017-02-22 04:43:44 +01:00
|
|
|
|
|
|
|
// Check if an object is present as one of the parent dir.
|
|
|
|
// -- FIXME. (needs a new kind of lock).
|
2021-01-17 10:11:48 +01:00
|
|
|
if opts.ParentIsObject != nil && opts.ParentIsObject(ctx, bucket, path.Dir(object)) {
|
2019-03-20 21:06:53 +01:00
|
|
|
return oi, toObjectErr(errFileParentIsFile, bucket, object)
|
2017-02-22 04:43:44 +01:00
|
|
|
}
|
|
|
|
|
2020-11-12 21:10:59 +01:00
|
|
|
defer ObjectPathUpdated(pathJoin(bucket, object))
|
2020-04-27 19:06:21 +02:00
|
|
|
|
2016-05-21 05:48:47 +02:00
|
|
|
// Calculate s3 compatible md5sum for complete multipart.
|
2019-05-09 03:35:40 +02:00
|
|
|
s3MD5 := getCompleteMultipartMD5(parts)
|
2016-05-21 05:48:47 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
uploadIDPath := er.getUploadIDDir(bucket, object, uploadID)
|
2019-11-20 02:42:27 +01:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
storageDisks := er.getDisks()
|
2020-01-16 03:30:32 +01:00
|
|
|
|
2016-06-01 05:23:31 +02:00
|
|
|
// Read metadata associated with the object from all disks.
|
2021-01-08 04:27:31 +01:00
|
|
|
partsMetadata, errs := readAllFileInfo(ctx, storageDisks, minioMetaMultipartBucket, uploadIDPath, "", false)
|
2017-12-22 12:28:13 +01:00
|
|
|
|
|
|
|
// get Quorum for this object
|
2021-01-16 21:08:02 +01:00
|
|
|
_, writeQuorum, err := objectQuorumFromMeta(ctx, partsMetadata, errs, er.defaultParityCount)
|
2017-12-22 12:28:13 +01:00
|
|
|
if err != nil {
|
|
|
|
return oi, toObjectErr(err, bucket, object)
|
|
|
|
}
|
|
|
|
|
2018-04-06 00:04:40 +02:00
|
|
|
reducedErr := reduceWriteQuorumErrs(ctx, errs, objectOpIgnoredErrs, writeQuorum)
|
2020-06-13 05:04:01 +02:00
|
|
|
if reducedErr == errErasureWriteQuorum {
|
2017-06-22 04:53:09 +02:00
|
|
|
return oi, toObjectErr(reducedErr, bucket, object)
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
|
|
|
|
2020-01-16 03:30:32 +01:00
|
|
|
onlineDisks, modTime := listOnlineDisks(storageDisks, partsMetadata, errs)
|
2016-07-14 23:59:01 +02:00
|
|
|
|
2016-06-01 05:23:31 +02:00
|
|
|
// Calculate full object size.
|
2016-05-21 05:48:47 +02:00
|
|
|
var objectSize int64
|
2016-05-25 06:24:20 +02:00
|
|
|
|
2018-09-28 05:36:17 +02:00
|
|
|
// Calculate consolidated actual size.
|
|
|
|
var objectActualSize int64
|
|
|
|
|
2016-06-01 05:23:31 +02:00
|
|
|
// Pick one from the first valid metadata.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi, err := pickValidFileInfo(ctx, partsMetadata, modTime, writeQuorum)
|
2016-11-21 05:56:44 +01:00
|
|
|
if err != nil {
|
2017-06-22 04:53:09 +02:00
|
|
|
return oi, err
|
2016-11-21 05:56:44 +01:00
|
|
|
}
|
2016-06-01 05:23:31 +02:00
|
|
|
|
2016-07-27 20:57:08 +02:00
|
|
|
// Order online disks in accordance with distribution order.
|
|
|
|
// Order parts metadata in accordance with distribution order.
|
2021-03-16 04:03:13 +01:00
|
|
|
onlineDisks, partsMetadata = shuffleDisksAndPartsMetadataByIndex(onlineDisks, partsMetadata, fi)
|
2016-07-27 20:57:08 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
// Save current erasure metadata for validation.
|
|
|
|
var currentFI = fi
|
2016-05-25 06:24:20 +02:00
|
|
|
|
|
|
|
// Allocate parts similar to incoming slice.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi.Parts = make([]ObjectPartInfo, len(parts))
|
2016-05-25 06:24:20 +02:00
|
|
|
|
2016-06-02 01:43:31 +02:00
|
|
|
// Validate each part and then commit to disk.
|
2016-05-21 05:48:47 +02:00
|
|
|
for i, part := range parts {
|
2020-06-13 05:04:01 +02:00
|
|
|
partIdx := objectPartIndex(currentFI.Parts, part.PartNumber)
|
2016-06-19 23:51:20 +02:00
|
|
|
// All parts should have same part number.
|
2016-05-25 06:24:20 +02:00
|
|
|
if partIdx == -1 {
|
2018-08-15 03:35:30 +02:00
|
|
|
invp := InvalidPart{
|
|
|
|
PartNumber: part.PartNumber,
|
|
|
|
GotETag: part.ETag,
|
|
|
|
}
|
|
|
|
return oi, invp
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
2016-06-19 23:51:20 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
// ensure that part ETag is canonicalized to strip off extraneous quotes
|
|
|
|
part.ETag = canonicalizeETag(part.ETag)
|
|
|
|
if currentFI.Parts[partIdx].ETag != part.ETag {
|
2018-08-15 03:35:30 +02:00
|
|
|
invp := InvalidPart{
|
|
|
|
PartNumber: part.PartNumber,
|
2020-06-13 05:04:01 +02:00
|
|
|
ExpETag: currentFI.Parts[partIdx].ETag,
|
2018-08-15 03:35:30 +02:00
|
|
|
GotETag: part.ETag,
|
|
|
|
}
|
|
|
|
return oi, invp
|
2016-05-25 06:24:20 +02:00
|
|
|
}
|
2016-06-19 23:51:20 +02:00
|
|
|
|
2016-05-21 05:48:47 +02:00
|
|
|
// All parts except the last part has to be atleast 5MB.
|
2020-06-13 05:04:01 +02:00
|
|
|
if (i < len(parts)-1) && !isMinAllowedPartSize(currentFI.Parts[partIdx].ActualSize) {
|
2018-04-06 00:04:40 +02:00
|
|
|
return oi, PartTooSmall{
|
|
|
|
PartNumber: part.PartNumber,
|
2020-06-13 05:04:01 +02:00
|
|
|
PartSize: currentFI.Parts[partIdx].ActualSize,
|
2018-04-06 00:04:40 +02:00
|
|
|
PartETag: part.ETag,
|
|
|
|
}
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
2016-05-25 06:24:20 +02:00
|
|
|
|
|
|
|
// Save for total object size.
|
2020-06-13 05:04:01 +02:00
|
|
|
objectSize += currentFI.Parts[partIdx].Size
|
2016-05-25 06:24:20 +02:00
|
|
|
|
2018-09-28 05:36:17 +02:00
|
|
|
// Save the consolidated actual size.
|
2020-06-13 05:04:01 +02:00
|
|
|
objectActualSize += currentFI.Parts[partIdx].ActualSize
|
2018-09-28 05:36:17 +02:00
|
|
|
|
2016-05-25 06:24:20 +02:00
|
|
|
// Add incoming parts.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi.Parts[i] = ObjectPartInfo{
|
2018-09-28 05:36:17 +02:00
|
|
|
Number: part.PartNumber,
|
2020-06-13 05:04:01 +02:00
|
|
|
Size: currentFI.Parts[partIdx].Size,
|
|
|
|
ActualSize: currentFI.Parts[partIdx].ActualSize,
|
2016-05-25 06:24:20 +02:00
|
|
|
}
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Save the final object size and modtime.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi.Size = objectSize
|
2020-07-09 02:36:56 +02:00
|
|
|
fi.ModTime = opts.MTime
|
|
|
|
if opts.MTime.IsZero() {
|
|
|
|
fi.ModTime = UTCNow()
|
|
|
|
}
|
2016-05-21 05:48:47 +02:00
|
|
|
|
|
|
|
// Save successfully calculated md5sum.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi.Metadata["etag"] = s3MD5
|
2020-08-13 02:32:24 +02:00
|
|
|
if opts.UserDefined["etag"] != "" { // preserve ETag if set
|
|
|
|
fi.Metadata["etag"] = opts.UserDefined["etag"]
|
|
|
|
}
|
2017-10-22 07:30:34 +02:00
|
|
|
|
2018-09-28 05:36:17 +02:00
|
|
|
// Save the consolidated actual size.
|
2020-06-13 05:04:01 +02:00
|
|
|
fi.Metadata[ReservedMetadataPrefix+"actual-size"] = strconv.FormatInt(objectActualSize, 10)
|
2018-09-28 05:36:17 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
// Update all erasure metadata, make sure to not modify fields like
|
2016-06-01 05:23:31 +02:00
|
|
|
// checksum which are different on each disks.
|
|
|
|
for index := range partsMetadata {
|
2020-11-20 18:10:48 +01:00
|
|
|
if partsMetadata[index].IsValid() {
|
|
|
|
partsMetadata[index].Size = fi.Size
|
|
|
|
partsMetadata[index].ModTime = fi.ModTime
|
|
|
|
partsMetadata[index].Metadata = fi.Metadata
|
|
|
|
partsMetadata[index].Parts = fi.Parts
|
|
|
|
}
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
2016-08-31 20:39:08 +02:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
// Write final `xl.meta` at uploadID location
|
|
|
|
if onlineDisks, err = writeUniqueFileInfo(ctx, onlineDisks, minioMetaMultipartBucket, uploadIDPath, partsMetadata, writeQuorum); err != nil {
|
|
|
|
return oi, toObjectErr(err, minioMetaMultipartBucket, uploadIDPath)
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
|
|
|
|
2016-06-10 15:13:16 +02:00
|
|
|
// Remove parts that weren't present in CompleteMultipartUpload request.
|
2020-06-13 05:04:01 +02:00
|
|
|
for _, curpart := range currentFI.Parts {
|
|
|
|
if objectPartIndex(fi.Parts, curpart.Number) == -1 {
|
2016-05-28 22:23:08 +02:00
|
|
|
// Delete the missing part files. e.g,
|
|
|
|
// Request 1: NewMultipart
|
|
|
|
// Request 2: PutObjectPart 1
|
|
|
|
// Request 3: PutObjectPart 2
|
|
|
|
// Request 4: CompleteMultipartUpload --part 2
|
|
|
|
// N.B. 1st part is not present. This part should be removed from the storage.
|
2020-06-13 05:04:01 +02:00
|
|
|
er.removeObjectPart(bucket, object, uploadID, fi.DataDir, curpart.Number)
|
2016-05-28 22:23:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-15 00:57:13 +02:00
|
|
|
// Hold namespace to complete the transaction
|
2020-11-04 17:25:42 +01:00
|
|
|
lk := er.NewNSLock(bucket, object)
|
2021-03-04 03:36:43 +01:00
|
|
|
ctx, err = lk.GetLock(ctx, globalOperationTimeout)
|
|
|
|
if err != nil {
|
2020-09-15 00:57:13 +02:00
|
|
|
return oi, err
|
|
|
|
}
|
|
|
|
defer lk.Unlock()
|
|
|
|
|
2016-05-29 09:42:09 +02:00
|
|
|
// Rename the multipart object to final location.
|
2020-06-13 05:04:01 +02:00
|
|
|
if onlineDisks, err = renameData(ctx, onlineDisks, minioMetaMultipartBucket, uploadIDPath,
|
2021-04-20 19:44:39 +02:00
|
|
|
partsMetadata, bucket, object, writeQuorum); err != nil {
|
2017-06-22 04:53:09 +02:00
|
|
|
return oi, toObjectErr(err, bucket, object)
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
|
|
|
|
2020-01-16 03:30:32 +01:00
|
|
|
// Check if there is any offline disk and add it to the MRF list
|
2020-12-22 18:16:43 +01:00
|
|
|
for _, disk := range onlineDisks {
|
|
|
|
if disk != nil && disk.IsOnline() {
|
|
|
|
continue
|
2020-01-16 03:30:32 +01:00
|
|
|
}
|
2020-12-22 18:16:43 +01:00
|
|
|
er.addPartial(bucket, object, fi.VersionID)
|
|
|
|
break
|
2020-01-16 03:30:32 +01:00
|
|
|
}
|
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
for i := 0; i < len(onlineDisks); i++ {
|
2020-12-22 18:16:43 +01:00
|
|
|
if onlineDisks[i] != nil && onlineDisks[i].IsOnline() {
|
|
|
|
// Object info is the same in all disks, so we can pick
|
|
|
|
// the first meta from online disk
|
|
|
|
fi = partsMetadata[i]
|
|
|
|
break
|
2020-06-13 05:04:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-17 04:23:43 +01:00
|
|
|
// Success, return object info.
|
2020-06-13 05:04:01 +02:00
|
|
|
return fi.ToObjectInfo(bucket, object), nil
|
2016-05-21 05:48:47 +02:00
|
|
|
}
|
|
|
|
|
2016-06-02 01:43:31 +02:00
|
|
|
// AbortMultipartUpload - aborts an ongoing multipart operation
|
|
|
|
// signified by the input uploadID. This is an atomic operation
|
|
|
|
// doesn't require clients to initiate multiple such requests.
|
|
|
|
//
|
|
|
|
// All parts are purged from all disks and reference to the uploadID
|
|
|
|
// would be removed from the system, rollback is not possible on this
|
|
|
|
// operation.
|
2021-03-04 03:36:43 +01:00
|
|
|
func (er erasureObjects) AbortMultipartUpload(ctx context.Context, bucket, object, uploadID string, opts ObjectOptions) (err error) {
|
2020-11-04 17:25:42 +01:00
|
|
|
lk := er.NewNSLock(bucket, pathJoin(object, uploadID))
|
2021-03-04 03:36:43 +01:00
|
|
|
ctx, err = lk.GetLock(ctx, globalOperationTimeout)
|
|
|
|
if err != nil {
|
2020-09-15 00:57:13 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer lk.Unlock()
|
|
|
|
|
2019-04-23 23:54:28 +02:00
|
|
|
// Validates if upload ID exists.
|
2020-06-13 05:04:01 +02:00
|
|
|
if err := er.checkUploadIDExists(ctx, bucket, object, uploadID); err != nil {
|
2019-04-23 23:54:28 +02:00
|
|
|
return toObjectErr(err, bucket, object, uploadID)
|
2016-05-28 22:23:08 +02:00
|
|
|
}
|
2018-03-15 21:55:23 +01:00
|
|
|
|
2020-06-13 05:04:01 +02:00
|
|
|
uploadIDPath := er.getUploadIDDir(bucket, object, uploadID)
|
2019-11-20 02:42:27 +01:00
|
|
|
|
2018-03-15 21:55:23 +01:00
|
|
|
// Read metadata associated with the object from all disks.
|
2021-01-08 04:27:31 +01:00
|
|
|
partsMetadata, errs := readAllFileInfo(ctx, er.getDisks(), minioMetaMultipartBucket, uploadIDPath, "", false)
|
2018-03-15 21:55:23 +01:00
|
|
|
|
|
|
|
// get Quorum for this object
|
2021-01-16 21:08:02 +01:00
|
|
|
_, writeQuorum, err := objectQuorumFromMeta(ctx, partsMetadata, errs, er.defaultParityCount)
|
2018-03-15 21:55:23 +01:00
|
|
|
if err != nil {
|
2019-11-09 18:27:23 +01:00
|
|
|
return toObjectErr(err, bucket, object, uploadID)
|
2018-03-15 21:55:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cleanup all uploaded parts.
|
2020-06-13 05:04:01 +02:00
|
|
|
if err = er.deleteObject(ctx, minioMetaMultipartBucket, uploadIDPath, writeQuorum); err != nil {
|
2019-11-09 18:27:23 +01:00
|
|
|
return toObjectErr(err, bucket, object, uploadID)
|
2018-03-15 21:55:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Successfully purged.
|
|
|
|
return nil
|
|
|
|
}
|