From de2c1063865c3537903b433e5b2986b5f58035c9 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 1 Feb 2019 17:58:41 +0100 Subject: [PATCH] xl: ListObjectParts uses the latest valid xl meta (#7184) ListObjectParts is using xl.readXLMetaParts which picks the first xl meta found in any disk, which is an inconsistent information. E.g.: In a middle of a multipart upload, one node can go offline and get back later with an outdated multipart information. --- cmd/xl-v1-multipart.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/cmd/xl-v1-multipart.go b/cmd/xl-v1-multipart.go index bb0e200a8..5117f3e38 100644 --- a/cmd/xl-v1-multipart.go +++ b/cmd/xl-v1-multipart.go @@ -505,11 +505,33 @@ func (xl xlObjects) ListObjectParts(ctx context.Context, bucket, object, uploadI uploadIDPath := xl.getUploadIDDir(bucket, object, uploadID) - xlParts, xlMeta, err := xl.readXLMetaParts(ctx, minioMetaMultipartBucket, uploadIDPath) + storageDisks := xl.getDisks() + + // Read metadata associated with the object from all disks. + partsMetadata, errs := readAllXLMetadata(ctx, storageDisks, minioMetaMultipartBucket, uploadIDPath) + + // get Quorum for this object + _, writeQuorum, err := objectQuorumFromMeta(ctx, xl, partsMetadata, errs) if err != nil { return result, toObjectErr(err, minioMetaMultipartBucket, uploadIDPath) } + reducedErr := reduceWriteQuorumErrs(ctx, errs, objectOpIgnoredErrs, writeQuorum) + if reducedErr == errXLWriteQuorum { + return result, toObjectErr(err, minioMetaMultipartBucket, uploadIDPath) + } + + _, modTime := listOnlineDisks(storageDisks, partsMetadata, errs) + + // Pick one from the first valid metadata. + xlValidMeta, err := pickValidXLMeta(ctx, partsMetadata, modTime, writeQuorum) + if err != nil { + return result, err + } + + var xlMeta = xlValidMeta.Meta + var xlParts = xlValidMeta.Parts + // Populate the result stub. result.Bucket = bucket result.Object = object