From 5a0c0079a138cc298f6020cef80ed430ea265a17 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Thu, 17 Feb 2022 15:05:19 -0800 Subject: [PATCH] Don't add free-version on restore-object (#14340) --- cmd/erasure-metadata.go | 12 ++++++++++++ cmd/xl-storage.go | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cmd/erasure-metadata.go b/cmd/erasure-metadata.go index 365f43892..85e07b75a 100644 --- a/cmd/erasure-metadata.go +++ b/cmd/erasure-metadata.go @@ -477,6 +477,18 @@ func (fi *FileInfo) TierFreeVersion() bool { return ok } +// IsRestoreObjReq returns true if fi corresponds to a RestoreObject request. +func (fi *FileInfo) IsRestoreObjReq() bool { + if restoreHdr, ok := fi.Metadata[xhttp.AmzRestore]; ok { + if restoreStatus, err := parseRestoreObjStatus(restoreHdr); err == nil { + if !restoreStatus.Ongoing() { + return true + } + } + } + return false +} + // VersionPurgeStatus returns overall version purge status for this object version across targets func (fi *FileInfo) VersionPurgeStatus() VersionPurgeStatusType { return fi.ReplicationState.CompositeVersionPurgeStatus() diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index 5cf6e7517..204b24bb3 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -2241,7 +2241,13 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f // suspended or disabled on this bucket. RenameData will replace // the 'null' version. We add a free-version to track its tiered // content for asynchronous deletion. - xlMeta.AddFreeVersion(fi) + if !fi.IsRestoreObjReq() { + // Note: Restore object request reuses PutObject/Multipart + // upload to copy back its data from the remote tier. This + // doesn't replace the existing version, so we don't need to add + // a free-version. + xlMeta.AddFreeVersion(fi) + } } // indicates if RenameData() is called by healing.