From 54a061bdda7df87810c46a7d921a99eb30c7deb1 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 29 Jun 2022 22:45:49 +0100 Subject: [PATCH] Save minio version information centrally (#15181) --- cmd/erasure-multipart.go | 1 - cmd/erasure-object.go | 1 - cmd/erasure-single-drive.go | 2 -- cmd/xl-storage-format-v2.go | 5 +++-- cmd/xl-storage-free-version.go | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cmd/erasure-multipart.go b/cmd/erasure-multipart.go index 0b02eedae..38e9a13cf 100644 --- a/cmd/erasure-multipart.go +++ b/cmd/erasure-multipart.go @@ -326,7 +326,6 @@ func (er erasureObjects) newMultipartUpload(ctx context.Context, bucket string, partsMetadata := make([]FileInfo, len(onlineDisks)) fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives) - fi.WrittenByVersion = globalVersionUnix fi.VersionID = opts.VersionID if opts.Versioned && fi.VersionID == "" { fi.VersionID = mustGetUUID() diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index a78518b0f..caab62919 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -944,7 +944,6 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st partsMetadata := make([]FileInfo, len(storageDisks)) fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives) - fi.WrittenByVersion = globalVersionUnix fi.VersionID = opts.VersionID if opts.Versioned && fi.VersionID == "" { fi.VersionID = mustGetUUID() diff --git a/cmd/erasure-single-drive.go b/cmd/erasure-single-drive.go index 58d6c59a7..8b12f7376 100644 --- a/cmd/erasure-single-drive.go +++ b/cmd/erasure-single-drive.go @@ -941,7 +941,6 @@ func (es *erasureSingle) putObject(ctx context.Context, bucket string, object st partsMetadata := make([]FileInfo, len(storageDisks)) fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives) - fi.WrittenByVersion = globalVersionUnix fi.VersionID = opts.VersionID if opts.Versioned && fi.VersionID == "" { fi.VersionID = mustGetUUID() @@ -2071,7 +2070,6 @@ func (es *erasureSingle) newMultipartUpload(ctx context.Context, bucket string, partsMetadata := make([]FileInfo, len(onlineDisks)) fi := newFileInfo(pathJoin(bucket, object), dataDrives, parityDrives) - fi.WrittenByVersion = globalVersionUnix fi.VersionID = opts.VersionID if opts.Versioned && fi.VersionID == "" { fi.VersionID = mustGetUUID() diff --git a/cmd/xl-storage-format-v2.go b/cmd/xl-storage-format-v2.go index aaba3054d..319e04902 100644 --- a/cmd/xl-storage-format-v2.go +++ b/cmd/xl-storage-format-v2.go @@ -1189,6 +1189,7 @@ func (x *xlMetaV2) DeleteVersion(fi FileInfo) (string, error) { ModTime: fi.ModTime.UnixNano(), MetaSys: make(map[string][]byte), }, + WrittenByVersion: globalVersionUnix, } if !ventry.Valid() { return "", errors.New("internal error: invalid version entry generated") @@ -1432,7 +1433,7 @@ func (x *xlMetaV2) AddVersion(fi FileInfo) error { } ventry := xlMetaV2Version{ - WrittenByVersion: fi.WrittenByVersion, + WrittenByVersion: globalVersionUnix, } if fi.Deleted { @@ -1598,7 +1599,7 @@ func (x *xlMetaV2) AddLegacy(m *xlMetaV1Object) error { } m.VersionID = nullVersionID - return x.addVersion(xlMetaV2Version{ObjectV1: m, Type: LegacyType}) + return x.addVersion(xlMetaV2Version{ObjectV1: m, Type: LegacyType, WrittenByVersion: globalVersionUnix}) } // ToFileInfo converts xlMetaV2 into a common FileInfo datastructure diff --git a/cmd/xl-storage-free-version.go b/cmd/xl-storage-free-version.go index 3187595e1..c1afd171f 100644 --- a/cmd/xl-storage-free-version.go +++ b/cmd/xl-storage-free-version.go @@ -35,7 +35,7 @@ func (j xlMetaV2Object) InitFreeVersion(fi FileInfo) (xlMetaV2Version, bool) { if err != nil { panic(fmt.Errorf("Invalid Tier Object delete marker versionId %s %v", fi.TierFreeVersionID(), err)) } - freeEntry := xlMetaV2Version{Type: DeleteType} + freeEntry := xlMetaV2Version{Type: DeleteType, WrittenByVersion: globalVersionUnix} freeEntry.DeleteMarker = &xlMetaV2DeleteMarker{ VersionID: vID, ModTime: j.ModTime, // fi.ModTime may be empty