mirror of
https://github.com/minio/minio.git
synced 2025-04-24 04:10:43 -04:00
Remove inline data hack (#12946)
move the code down to the storage layer, this logic decouples the inline data from the size parameter making it flexible and future proof.
This commit is contained in:
parent
f31a00de01
commit
24722ddd02
@ -256,26 +256,6 @@ func (er erasureObjects) getObjectWithFileInfo(ctx context.Context, bucket, obje
|
|||||||
return toObjectErr(err, bucket, object)
|
return toObjectErr(err, bucket, object)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This hack is needed to avoid a bug found when overwriting
|
|
||||||
// the inline data object with a un-inlined version, for the
|
|
||||||
// time being we need this as we have released inline-data
|
|
||||||
// version already and this bug is already present in newer
|
|
||||||
// releases.
|
|
||||||
//
|
|
||||||
// This mainly happens with objects < smallFileThreshold when
|
|
||||||
// they are overwritten with un-inlined objects >= smallFileThreshold,
|
|
||||||
// due to a bug in RenameData() the fi.Data is not niled leading to
|
|
||||||
// GetObject thinking that fi.Data is valid while fi.Size has
|
|
||||||
// changed already.
|
|
||||||
if fi.InlineData() {
|
|
||||||
shardFileSize := erasure.ShardFileSize(fi.Size)
|
|
||||||
if shardFileSize >= 0 && shardFileSize >= smallFileThreshold {
|
|
||||||
for i := range metaArr {
|
|
||||||
metaArr[i].Data = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var healOnce sync.Once
|
var healOnce sync.Once
|
||||||
|
|
||||||
// once we have obtained a common FileInfo i.e latest, we should stick
|
// once we have obtained a common FileInfo i.e latest, we should stick
|
||||||
|
@ -190,7 +190,10 @@ func (fi FileInfo) InlineData() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetInlineData marks object (version) as inline.
|
// SetInlineData marks object (version) as inline.
|
||||||
func (fi FileInfo) SetInlineData() {
|
func (fi *FileInfo) SetInlineData() {
|
||||||
|
if fi.Metadata == nil {
|
||||||
|
fi.Metadata = make(map[string]string, 1)
|
||||||
|
}
|
||||||
fi.Metadata[ReservedMetadataPrefixLower+"inline-data"] = "true"
|
fi.Metadata[ReservedMetadataPrefixLower+"inline-data"] = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ type xlMetaV2 struct {
|
|||||||
//msgp:ignore xlMetaInlineData
|
//msgp:ignore xlMetaInlineData
|
||||||
type xlMetaInlineData []byte
|
type xlMetaInlineData []byte
|
||||||
|
|
||||||
// xlMetaInlineDataVer indicates the vesrion of the inline data structure.
|
// xlMetaInlineDataVer indicates the version of the inline data structure.
|
||||||
const xlMetaInlineDataVer = 1
|
const xlMetaInlineDataVer = 1
|
||||||
|
|
||||||
// versionOK returns whether the version is ok.
|
// versionOK returns whether the version is ok.
|
||||||
|
@ -1130,13 +1130,30 @@ func (s *xlStorage) ReadVersion(ctx context.Context, volume, path, versionID str
|
|||||||
|
|
||||||
if readData {
|
if readData {
|
||||||
if len(fi.Data) > 0 || fi.Size == 0 {
|
if len(fi.Data) > 0 || fi.Size == 0 {
|
||||||
if len(fi.Data) > 0 {
|
if fi.InlineData() {
|
||||||
if !fi.InlineData() {
|
// If written with header we are fine.
|
||||||
fi.SetInlineData()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fi, nil
|
return fi, nil
|
||||||
}
|
}
|
||||||
|
if fi.Size == 0 || !(fi.VersionID != "" && fi.VersionID != nullVersionID) {
|
||||||
|
// If versioned we have no conflicts.
|
||||||
|
fi.SetInlineData()
|
||||||
|
return fi, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// For overwritten objects without header we might have a conflict with
|
||||||
|
// data written later.
|
||||||
|
// Check the data path if there is a part with data.
|
||||||
|
partPath := fmt.Sprintf("part.%d", fi.Parts[0].Number)
|
||||||
|
dataPath := pathJoin(path, fi.DataDir, partPath)
|
||||||
|
_, err = s.StatInfoFile(ctx, volume, dataPath)
|
||||||
|
if err != nil {
|
||||||
|
// Set the inline header, our inlined data is fine.
|
||||||
|
fi.SetInlineData()
|
||||||
|
return fi, nil
|
||||||
|
}
|
||||||
|
// Data exists on disk, remove the version from metadata.
|
||||||
|
fi.Data = nil
|
||||||
|
}
|
||||||
|
|
||||||
// Reading data for small objects when
|
// Reading data for small objects when
|
||||||
// - object has not yet transitioned
|
// - object has not yet transitioned
|
||||||
|
Loading…
x
Reference in New Issue
Block a user