From dce0345f8f8a4654d92dbb28d46a09f19db1d26d Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Sun, 26 Feb 2017 20:58:32 +0100 Subject: [PATCH] Set disk to nil after write which needs quorum (#3795) Ignore a disk which wasn't able to successfully perform an action to avoid eventual perturbations when the disk comes back in the middle of write change. --- cmd/erasure-createfile.go | 3 +++ cmd/xl-v1-metadata.go | 4 ++++ cmd/xl-v1-multipart.go | 2 ++ cmd/xl-v1-object.go | 2 ++ 4 files changed, 11 insertions(+) diff --git a/cmd/erasure-createfile.go b/cmd/erasure-createfile.go index f95c0c18c..807684210 100644 --- a/cmd/erasure-createfile.go +++ b/cmd/erasure-createfile.go @@ -114,6 +114,7 @@ func appendFile(disks []StorageAPI, volume, path string, enBlocks [][]byte, hash // Write encoded data to quorum disks in parallel. for index, disk := range disks { if disk == nil { + wErrs[index] = traceError(errDiskNotFound) continue } wg.Add(1) @@ -123,6 +124,8 @@ func appendFile(disks []StorageAPI, volume, path string, enBlocks [][]byte, hash wErr := disk.AppendFile(volume, path, enBlocks[index]) if wErr != nil { wErrs[index] = traceError(wErr) + // Ignore disk which returned an error. + disks[index] = nil return } diff --git a/cmd/xl-v1-metadata.go b/cmd/xl-v1-metadata.go index 243dab9fe..29613e480 100644 --- a/cmd/xl-v1-metadata.go +++ b/cmd/xl-v1-metadata.go @@ -361,6 +361,8 @@ func writeUniqueXLMetadata(disks []StorageAPI, bucket, prefix string, xlMetas [] err := writeXLMetadata(disk, bucket, prefix, xlMetas[index]) if err != nil { mErrs[index] = err + // Ignore disk which returned an error. + disks[index] = nil } }(index, disk) } @@ -399,6 +401,8 @@ func writeSameXLMetadata(disks []StorageAPI, bucket, prefix string, xlMeta xlMet err := writeXLMetadata(disk, bucket, prefix, metadata) if err != nil { mErrs[index] = err + // Ignore disk which returned an error. + disks[index] = nil } }(index, disk, xlMeta) } diff --git a/cmd/xl-v1-multipart.go b/cmd/xl-v1-multipart.go index c456fd22d..2fa73630c 100644 --- a/cmd/xl-v1-multipart.go +++ b/cmd/xl-v1-multipart.go @@ -254,6 +254,8 @@ func commitXLMetadata(disks []StorageAPI, srcBucket, srcPrefix, dstBucket, dstPr rErr := disk.RenameFile(srcBucket, srcJSONFile, dstBucket, dstJSONFile) if rErr != nil { mErrs[index] = traceError(rErr) + // Ignore disk which returned an error. + disks[index] = nil return } mErrs[index] = nil diff --git a/cmd/xl-v1-object.go b/cmd/xl-v1-object.go index 1316670e3..61d582330 100644 --- a/cmd/xl-v1-object.go +++ b/cmd/xl-v1-object.go @@ -395,6 +395,8 @@ func rename(disks []StorageAPI, srcBucket, srcEntry, dstBucket, dstEntry string, err := disk.RenameFile(srcBucket, srcEntry, dstBucket, dstEntry) if err != nil && err != errFileNotFound { errs[index] = traceError(err) + // Ignore disk which returned an error. + disks[index] = nil } }(index, disk) }