From 182109f0debee85e017171b4b9f6b577a4312cb6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 6 Sep 2016 20:31:50 -0700 Subject: [PATCH] xl: Heal `format.json` properly on fresh disks. --- cmd/format-config-v1.go | 7 ++++++- cmd/fs-v1-multipart.go | 16 ++++++++-------- cmd/fs-v1.go | 2 +- cmd/object-common.go | 10 +++++++--- cmd/xl-v1-multipart.go | 10 +++++----- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/cmd/format-config-v1.go b/cmd/format-config-v1.go index 079684d58..f75a060d1 100644 --- a/cmd/format-config-v1.go +++ b/cmd/format-config-v1.go @@ -524,6 +524,11 @@ func healFormatXLFreshDisks(storageDisks []StorageAPI) error { } } + // Initialize meta volume, if volume already exists ignores it. + if err := initMetaVolume(orderedDisks); err != nil { + return fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %s", err) + } + // Save new `format.json` across all disks, in JBOD order. return saveFormatXL(orderedDisks, newFormatConfigs) } @@ -872,7 +877,7 @@ func initFormatXL(storageDisks []StorageAPI) (err error) { // Initialize meta volume, if volume already exists ignores it. if err := initMetaVolume(storageDisks); err != nil { - return fmt.Errorf("Unable to initialize '.minio' meta volume, %s", err) + return fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %s", err) } // Save formats `format.json` across all disks. diff --git a/cmd/fs-v1-multipart.go b/cmd/fs-v1-multipart.go index 447839bf1..37d9965fb 100644 --- a/cmd/fs-v1-multipart.go +++ b/cmd/fs-v1-multipart.go @@ -221,7 +221,7 @@ func (fs fsObjects) ListMultipartUploads(bucket, prefix, keyMarker, uploadIDMark // request, returns back a unique upload id. // // Internally this function creates 'uploads.json' associated for the -// incoming object at '.minio/multipart/bucket/object/uploads.json' on +// incoming object at '.minio.sys/multipart/bucket/object/uploads.json' on // all the disks. `uploads.json` carries metadata regarding on going // multipart operation on the object. func (fs fsObjects) newMultipartUpload(bucket string, object string, meta map[string]string) (uploadID string, err error) { @@ -237,7 +237,7 @@ func (fs fsObjects) newMultipartUpload(bucket string, object string, meta map[st // used for instrumentation on locks. opsID := getOpsID() - // This lock needs to be held for any changes to the directory contents of ".minio/multipart/object/" + // This lock needs to be held for any changes to the directory contents of ".minio.sys/multipart/object/" nsMutex.Lock(minioMetaBucket, pathJoin(mpartMetaPrefix, bucket, object), opsID) defer nsMutex.Unlock(minioMetaBucket, pathJoin(mpartMetaPrefix, bucket, object), opsID) @@ -393,8 +393,8 @@ func appendParts(disk StorageAPI, bucket, object, uploadID, opsID string) { // PutObjectPart - reads incoming data until EOF for the part file on // an ongoing multipart transaction. Internally incoming data is -// written to '.minio/tmp' location and safely renamed to -// '.minio/multipart' for reach parts. +// written to '.minio.sys/tmp' location and safely renamed to +// '.minio.sys/multipart' for reach parts. func (fs fsObjects) PutObjectPart(bucket, object, uploadID string, partID int, size int64, data io.Reader, md5Hex string) (string, error) { // Verify if bucket is valid. if !IsValidBucketName(bucket) { @@ -513,8 +513,8 @@ func (fs fsObjects) PutObjectPart(bucket, object, uploadID string, partID int, s } // listObjectParts - wrapper scanning through -// '.minio/multipart/bucket/object/UPLOADID'. Lists all the parts -// saved inside '.minio/multipart/bucket/object/UPLOADID'. +// '.minio.sys/multipart/bucket/object/UPLOADID'. Lists all the parts +// saved inside '.minio.sys/multipart/bucket/object/UPLOADID'. func (fs fsObjects) listObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, error) { result := ListPartsInfo{} @@ -787,7 +787,7 @@ func (fs fsObjects) CompleteMultipartUpload(bucket string, object string, upload // abortMultipartUpload - wrapper for purging an ongoing multipart // transaction, deletes uploadID entry from `uploads.json` and purges -// the directory at '.minio/multipart/bucket/object/uploadID' holding +// the directory at '.minio.sys/multipart/bucket/object/uploadID' holding // all the upload parts. func (fs fsObjects) abortMultipartUpload(bucket, object, uploadID string) error { // Cleanup all uploaded parts. @@ -813,7 +813,7 @@ func (fs fsObjects) abortMultipartUpload(bucket, object, uploadID string) error return nil } } // No more pending uploads for the object, we purge the entire - // entry at '.minio/multipart/bucket/object'. + // entry at '.minio.sys/multipart/bucket/object'. if err = fs.storage.DeleteFile(minioMetaBucket, path.Join(mpartMetaPrefix, bucket, object, uploadsJSONFile)); err != nil { return toObjectErr(traceError(err), minioMetaBucket, path.Join(mpartMetaPrefix, bucket, object)) } diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 364e2d149..b9ee3380e 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -67,7 +67,7 @@ func newFSObjects(disk string) (ObjectLayer, error) { return nil, err } - // Attempt to create `.minio`. + // Attempt to create `.minio.sys`. err = storage.MakeVol(minioMetaBucket) if err != nil { switch err { diff --git a/cmd/object-common.go b/cmd/object-common.go index 9f0f35382..c6243842f 100644 --- a/cmd/object-common.go +++ b/cmd/object-common.go @@ -134,7 +134,7 @@ func initMetaVolume(storageDisks []StorageAPI) error { // Indicate this wait group is done. defer wg.Done() - // Attempt to create `.minio`. + // Attempt to create `.minio.sys`. err := disk.MakeVol(minioMetaBucket) if err != nil { switch err { @@ -184,8 +184,12 @@ func xlHouseKeeping(storageDisks []StorageAPI) error { // Cleanup all temp entries upon start. err := cleanupDir(disk, minioMetaBucket, tmpMetaPrefix) - if err != nil && err != errDiskNotFound { - errs[index] = err + if err != nil { + switch errorCause(err) { + case errDiskNotFound, errVolumeNotFound: + default: + errs[index] = err + } } }(index, disk) } diff --git a/cmd/xl-v1-multipart.go b/cmd/xl-v1-multipart.go index b2805856d..db6e3214b 100644 --- a/cmd/xl-v1-multipart.go +++ b/cmd/xl-v1-multipart.go @@ -259,7 +259,7 @@ func (xl xlObjects) ListMultipartUploads(bucket, prefix, keyMarker, uploadIDMark // request, returns back a unique upload id. // // Internally this function creates 'uploads.json' associated for the -// incoming object at '.minio/multipart/bucket/object/uploads.json' on +// incoming object at '.minio.sys/multipart/bucket/object/uploads.json' on // all the disks. `uploads.json` carries metadata regarding on going // multipart operation on the object. func (xl xlObjects) newMultipartUpload(bucket string, object string, meta map[string]string) (uploadID string, err error) { @@ -282,7 +282,7 @@ func (xl xlObjects) newMultipartUpload(bucket string, object string, meta map[st // used for instrumentation on locks. opsID := getOpsID() - // This lock needs to be held for any changes to the directory contents of ".minio/multipart/object/" + // This lock needs to be held for any changes to the directory contents of ".minio.sys/multipart/object/" nsMutex.Lock(minioMetaBucket, pathJoin(mpartMetaPrefix, bucket, object), opsID) defer nsMutex.Unlock(minioMetaBucket, pathJoin(mpartMetaPrefix, bucket, object), opsID) @@ -826,7 +826,7 @@ func (xl xlObjects) CompleteMultipartUpload(bucket string, object string, upload // Return success. return s3MD5, nil } // No more pending uploads for the object, proceed to delete - // object completely from '.minio/multipart'. + // object completely from '.minio.sys/multipart'. if err = xl.deleteObject(minioMetaBucket, path.Join(mpartMetaPrefix, bucket, object)); err != nil { return "", toObjectErr(err, minioMetaBucket, path.Join(mpartMetaPrefix, bucket, object)) } @@ -837,7 +837,7 @@ func (xl xlObjects) CompleteMultipartUpload(bucket string, object string, upload // abortMultipartUpload - wrapper for purging an ongoing multipart // transaction, deletes uploadID entry from `uploads.json` and purges -// the directory at '.minio/multipart/bucket/object/uploadID' holding +// the directory at '.minio.sys/multipart/bucket/object/uploadID' holding // all the upload parts. func (xl xlObjects) abortMultipartUpload(bucket, object, uploadID string) (err error) { // Cleanup all uploaded parts. @@ -870,7 +870,7 @@ func (xl xlObjects) abortMultipartUpload(bucket, object, uploadID string) (err e } return nil } // No more pending uploads for the object, we purge the entire - // entry at '.minio/multipart/bucket/object'. + // entry at '.minio.sys/multipart/bucket/object'. if err = xl.deleteObject(minioMetaBucket, path.Join(mpartMetaPrefix, bucket, object)); err != nil { return toObjectErr(err, minioMetaBucket, path.Join(mpartMetaPrefix, bucket, object)) }