mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Store object EC in metadata header (#19534)
Keep the EC in header, so it can be retrieved easily for dynamic quorum calculations.
To not force a full metadata decode on every read the value will be 0/0 for data written in previous versions.
Size is expected to increase by 2 bytes per version, since all valid values can be represented with 1 byte each.
Example:
```
λ xl-meta xl.meta
{
"Versions": [
{
"Header": {
"EcM": 4,
"EcN": 8,
"Flags": 6,
"ModTime": "2024-04-17T11:46:25.325613+02:00",
"Signature": "0a409875",
"Type": 1,
"VersionID": "8e03504e11234957b2727bc53eda0d55"
},
...
```
Not used for operations yet.
This commit is contained in:
@@ -250,15 +250,17 @@ type xlMetaV2VersionHeader struct {
|
||||
Signature [4]byte
|
||||
Type VersionType
|
||||
Flags xlFlags
|
||||
EcM, EcN uint8 // Note that these will be 0/0 for non-v2 objects and older xl.meta
|
||||
}
|
||||
|
||||
func (x xlMetaV2VersionHeader) String() string {
|
||||
return fmt.Sprintf("Type: %s, VersionID: %s, Signature: %s, ModTime: %s, Flags: %s",
|
||||
return fmt.Sprintf("Type: %s, VersionID: %s, Signature: %s, ModTime: %s, Flags: %s, N: %d, M: %d",
|
||||
x.Type.String(),
|
||||
hex.EncodeToString(x.VersionID[:]),
|
||||
hex.EncodeToString(x.Signature[:]),
|
||||
time.Unix(0, x.ModTime),
|
||||
x.Flags.String(),
|
||||
x.EcN, x.EcM,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -274,6 +276,11 @@ func (x xlMetaV2VersionHeader) matchesNotStrict(o xlMetaV2VersionHeader) bool {
|
||||
x.Type == o.Type
|
||||
}
|
||||
|
||||
// hasEC will return true if the version has erasure coding information.
|
||||
func (x xlMetaV2VersionHeader) hasEC() bool {
|
||||
return x.EcM > 0 && x.EcN > 0
|
||||
}
|
||||
|
||||
// sortsBefore can be used as a tiebreaker for stable sorting/selecting.
|
||||
// Returns false on ties.
|
||||
func (x xlMetaV2VersionHeader) sortsBefore(o xlMetaV2VersionHeader) bool {
|
||||
@@ -351,12 +358,18 @@ func (j *xlMetaV2Version) header() xlMetaV2VersionHeader {
|
||||
if j.Type == ObjectType && j.ObjectV2.InlineData() {
|
||||
flags |= xlFlagInlineData
|
||||
}
|
||||
var ecM, ecN uint8
|
||||
if j.Type == ObjectType && j.ObjectV2 != nil {
|
||||
ecM, ecN = uint8(j.ObjectV2.ErasureM), uint8(j.ObjectV2.ErasureN)
|
||||
}
|
||||
return xlMetaV2VersionHeader{
|
||||
VersionID: j.getVersionID(),
|
||||
ModTime: j.getModTime().UnixNano(),
|
||||
Signature: j.getSignature(),
|
||||
Type: j.Type,
|
||||
Flags: flags,
|
||||
EcN: ecM,
|
||||
EcM: ecN,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +453,7 @@ func (j *xlMetaV2Version) ToFileInfo(volume, path string, allParts bool) (fi Fil
|
||||
}
|
||||
|
||||
const (
|
||||
xlHeaderVersion = 2
|
||||
xlHeaderVersion = 3
|
||||
xlMetaVersion = 2
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user