remove rename2 entirely, avoids the risk of moving data (#19058)

This commit is contained in:
Harshavardhana 2024-02-14 17:09:38 -08:00 committed by GitHub
parent b5791e6f28
commit 7e4a6b4bcd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 4 additions and 25 deletions

View File

@ -51,7 +51,7 @@ const (
osMetricReadDirent
osMetricFdatasync
osMetricSync
osMetricRename2 // Linux specific
// .... add more
osMetricLast

View File

@ -22,16 +22,8 @@ package cmd
import (
"syscall"
"golang.org/x/sys/unix"
)
// Rename2 captures time taken to call os.Rename
func Rename2(src, dst string) (err error) {
defer updateOSMetrics(osMetricRename2, src, dst)(err)
return unix.Renameat2(unix.AT_FDCWD, src, unix.AT_FDCWD, dst, uint(2)) // RENAME_EXCHANGE from 'man renameat2'
}
// RenameSys is low level call in case of Linux this uses syscall.Rename() directly.
func RenameSys(src, dst string) (err error) {
return syscall.Rename(src, dst)

View File

@ -24,11 +24,6 @@ import (
"os"
)
// Rename2 is not implemented in a non linux environment
func Rename2(src, dst string) (err error) {
return errSkipFile
}
// RenameSys is low level call in case of non-Linux this just uses os.Rename()
func RenameSys(src, dst string) (err error) {
return os.Rename(src, dst)

View File

@ -26,13 +26,12 @@ func _() {
_ = x[osMetricReadDirent-15]
_ = x[osMetricFdatasync-16]
_ = x[osMetricSync-17]
_ = x[osMetricRename2-18]
_ = x[osMetricLast-19]
_ = x[osMetricLast-18]
}
const _osMetric_name = "RemoveAllMkdirAllMkdirRenameOpenFileWOpenFileROpenFileWFdOpenFileRFdOpenOpenFileDirectIOLstatRemoveStatAccessCreateReadDirentFdatasyncSyncRename2Last"
const _osMetric_name = "RemoveAllMkdirAllMkdirRenameOpenFileWOpenFileROpenFileWFdOpenFileRFdOpenOpenFileDirectIOLstatRemoveStatAccessCreateReadDirentFdatasyncSyncLast"
var _osMetric_index = [...]uint8{0, 9, 17, 22, 28, 37, 46, 57, 68, 72, 88, 93, 99, 103, 109, 115, 125, 134, 138, 145, 149}
var _osMetric_index = [...]uint8{0, 9, 17, 22, 28, 37, 46, 57, 68, 72, 88, 93, 99, 103, 109, 115, 125, 134, 138, 142}
func (i osMetric) String() string {
if i >= osMetric(len(_osMetric_index)-1) {

View File

@ -2633,13 +2633,6 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
}
diskHealthCheckOK(ctx, err)
if !fi.Versioned && !fi.DataMov() && !fi.Healing() {
// Use https://man7.org/linux/man-pages/man2/rename.2.html if possible on unversioned bucket.
if err := Rename2(pathutil.Join(srcVolumeDir, srcPath), pathutil.Join(dstVolumeDir, dstPath)); err == nil {
return sign, nil
} // if Rename2 is not successful fallback.
}
// renameAll only for objects that have xl.meta not saved inline.
if len(fi.Data) == 0 && fi.Size > 0 {
s.moveToTrash(dstDataPath, true, false)