use renameat2 Linux extension syscall (#17757)

this is a faster and safer alternative
on newer kernel versions.
This commit is contained in:
Harshavardhana
2023-08-27 09:57:11 -07:00
committed by GitHub
parent 6f0ed2a091
commit 8a57b6bced
10 changed files with 146 additions and 67 deletions
+7
View File
@@ -2485,6 +2485,13 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
}
diskHealthCheckOK(ctx, err)
if !fi.Versioned && !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)