From bb07df7e7b1aa47d405e9c1a75a675ce96e43628 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 30 Aug 2024 09:02:26 -0700 Subject: [PATCH] do not list dangling objects with unmatched ECs (#20351) This mostly applies to all new objects, this simply ignores these objects and no application would have to deal with getting 503s on them. --- cmd/xl-storage-format-v2.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cmd/xl-storage-format-v2.go b/cmd/xl-storage-format-v2.go index 6f5326171..48f6d3b88 100644 --- a/cmd/xl-storage-format-v2.go +++ b/cmd/xl-storage-format-v2.go @@ -267,13 +267,19 @@ func (x xlMetaV2VersionHeader) String() string { // matchesNotStrict returns whether x and o have both have non-zero version, // their versions match and their type match. // If they have zero version, modtime must match. -func (x xlMetaV2VersionHeader) matchesNotStrict(o xlMetaV2VersionHeader) bool { +func (x xlMetaV2VersionHeader) matchesNotStrict(o xlMetaV2VersionHeader) (ok bool) { + ok = x.VersionID == o.VersionID && x.Type == o.Type && x.matchesEC(o) if x.VersionID == [16]byte{} { - return x.VersionID == o.VersionID && - x.Type == o.Type && o.ModTime == x.ModTime + ok = ok && o.ModTime == x.ModTime } - return x.VersionID == o.VersionID && - x.Type == o.Type + return ok +} + +func (x xlMetaV2VersionHeader) matchesEC(o xlMetaV2VersionHeader) bool { + if x.hasEC() && o.hasEC() { + return x.EcN == o.EcN && x.EcM == o.EcM + } // if no EC header this is an older object + return true } // hasEC will return true if the version has erasure coding information. @@ -1967,6 +1973,11 @@ func mergeXLV2Versions(quorum int, strict bool, requestedVersions int, versions continue } if !strict { + // we must match EC, when we are not strict. + if !a.header.matchesEC(ver.header) { + continue + } + a.header.Signature = [4]byte{} } x[a.header]++