xl-erasure: RenameFile should support quorum. (#1487)

Fixes #1463
master
Bala FA 8 years ago committed by Harshavardhana
parent 247e835d7b
commit 658a595d7a
  1. 25
      xl-erasure-v1.go

@ -640,6 +640,7 @@ func (xl XL) RenameFile(srcVolume, srcPath, dstVolume, dstPath string) error {
nsMutex.Lock(dstVolume, dstPath)
defer nsMutex.Unlock(dstVolume, dstPath)
errCount := 0
for index, disk := range xl.storageDisks {
// Make sure to rename all the files only, not directories.
srcErasurePartPath := slashpath.Join(srcPath, fmt.Sprintf("file.%d", index))
@ -652,6 +653,14 @@ func (xl XL) RenameFile(srcVolume, srcPath, dstVolume, dstPath string) error {
"dstVolume": dstVolume,
"dstPath": dstErasurePartPath,
}).Errorf("RenameFile failed with %s", err)
errCount++
// We can safely allow RenameFile errors up to len(xl.storageDisks) - xl.writeQuorum
// otherwise return failure.
if errCount <= len(xl.storageDisks)-xl.writeQuorum {
continue
}
return err
}
srcXLMetaPath := slashpath.Join(srcPath, xlMetaV1File)
@ -664,6 +673,14 @@ func (xl XL) RenameFile(srcVolume, srcPath, dstVolume, dstPath string) error {
"dstVolume": dstVolume,
"dstPath": dstXLMetaPath,
}).Errorf("RenameFile failed with %s", err)
errCount++
// We can safely allow RenameFile errors up to len(xl.storageDisks) - xl.writeQuorum
// otherwise return failure.
if errCount <= len(xl.storageDisks)-xl.writeQuorum {
continue
}
return err
}
err = disk.DeleteFile(srcVolume, srcPath)
@ -672,6 +689,14 @@ func (xl XL) RenameFile(srcVolume, srcPath, dstVolume, dstPath string) error {
"srcVolume": srcVolume,
"srcPath": srcPath,
}).Errorf("DeleteFile failed with %s", err)
errCount++
// We can safely allow RenameFile errors up to len(xl.storageDisks) - xl.writeQuorum
// otherwise return failure.
if errCount <= len(xl.storageDisks)-xl.writeQuorum {
continue
}
return err
}
}

Loading…
Cancel
Save