From 2c5f2e96697b628ab62d58584432b833ce535521 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 2 Apr 2018 22:18:06 -0700 Subject: [PATCH] Stop deleting 'format.json' upon unsuccessful save (#5747) An issue was reproduced when there a no more inodes available on an existing setup of 4 disks, now we took one of the disks and reformatted it to relinquish inodes. Now we attempt to bring the fresh disk back into setup and perform a heal - at this point creating new `format.json` fails on existing disks since they do not have more inodes available. At this point due to quorum failure, we end up deleting existing `format.json` as well, this PR removes the code which deletes existing `format.json` as there is no need to delete them. --- cmd/format-xl.go | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/cmd/format-xl.go b/cmd/format-xl.go index a03a49420..2df283da0 100644 --- a/cmd/format-xl.go +++ b/cmd/format-xl.go @@ -362,26 +362,6 @@ func loadFormatXLAll(endpoints EndpointList) ([]*formatXLV3, []error) { return formats, sErrs } -func undoSaveFormatXLAll(disks []StorageAPI) { - // Initialize sync waitgroup. - var wg = &sync.WaitGroup{} - // Undo previous save format.json entry from all underlying storage disks. - for index, disk := range disks { - if disk == nil { - continue - } - wg.Add(1) - // Delete a bucket inside a go-routine. - go func(index int, disk StorageAPI) { - defer wg.Done() - _ = disk.DeleteFile(minioMetaBucket, formatConfigFile) - }(index, disk) - } - - // Wait for all make vol to finish. - wg.Wait() -} - func saveFormatXL(disk StorageAPI, format interface{}) error { // Marshal and write to disk. formatBytes, err := json.Marshal(format) @@ -390,7 +370,7 @@ func saveFormatXL(disk StorageAPI, format interface{}) error { } // Purge any existing temporary file, okay to ignore errors here. - disk.DeleteFile(minioMetaBucket, formatConfigFileTmp) + defer disk.DeleteFile(minioMetaBucket, formatConfigFileTmp) // Append file `format.json.tmp`. if err = disk.AppendFile(minioMetaBucket, formatConfigFileTmp, formatBytes); err != nil { @@ -577,14 +557,7 @@ func saveFormatXLAll(endpoints EndpointList, formats []*formatXLV3) error { wg.Wait() writeQuorum := len(endpoints)/2 + 1 - err = reduceWriteQuorumErrs(errs, nil, writeQuorum) - if errors.Cause(err) == errXLWriteQuorum { - // Purge all successfully created `format.json` - // when we do not have enough quorum. - undoSaveFormatXLAll(storageDisks) - } - - return err + return reduceWriteQuorumErrs(errs, nil, writeQuorum) } // Initialize storage disks based on input arguments.