From 6266328a8570c081e5652b173e9485a5a77cd135 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 8 Jul 2016 15:28:09 -0700 Subject: [PATCH] XL/metadata: use new hashOrder algorithm for newXLMeta. (#2147) --- .travis.yml | 6 +++--- xl-v1-metadata.go | 7 +++---- xl-v1-metadata_test.go | 2 +- xl-v1-multipart.go | 2 +- xl-v1-object.go | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index e45d49310..9cab4601a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,9 @@ language: go os: - linux -## Turning off for now. -# - osx -# osx_image: xcode7.2 +- osx + +osx_image: xcode7.2 env: - ARCH=x86_64 diff --git a/xl-v1-metadata.go b/xl-v1-metadata.go index 3233ff5db..921590472 100644 --- a/xl-v1-metadata.go +++ b/xl-v1-metadata.go @@ -107,9 +107,8 @@ type xlMetaV1 struct { Parts []objectPartInfo `json:"parts,omitempty"` } -// newXLMetaV1 - initializes new xlMetaV1, adds version, allocates a -// fresh erasure info. -func newXLMetaV1(dataBlocks, parityBlocks int) (xlMeta xlMetaV1) { +// newXLMetaV1 - initializes new xlMetaV1, adds version, allocates a fresh erasure info. +func newXLMetaV1(object string, dataBlocks, parityBlocks int) (xlMeta xlMetaV1) { xlMeta = xlMetaV1{} xlMeta.Version = "1.0.0" xlMeta.Format = "xl" @@ -119,7 +118,7 @@ func newXLMetaV1(dataBlocks, parityBlocks int) (xlMeta xlMetaV1) { DataBlocks: dataBlocks, ParityBlocks: parityBlocks, BlockSize: blockSizeV1, - Distribution: hashOrder(time.Now().UTC().String(), dataBlocks+parityBlocks), + Distribution: hashOrder(object, dataBlocks+parityBlocks), } return xlMeta } diff --git a/xl-v1-metadata_test.go b/xl-v1-metadata_test.go index 1439b074a..29373961e 100644 --- a/xl-v1-metadata_test.go +++ b/xl-v1-metadata_test.go @@ -39,7 +39,7 @@ func TestXLMetaV1(t *testing.T) { } // Create a XLMetaV1 structure to test on. - meta := newXLMetaV1(8, 8) + meta := newXLMetaV1("minio", 8, 8) // Add 5 parts. for _, test := range testCases { diff --git a/xl-v1-multipart.go b/xl-v1-multipart.go index 6847cd747..e418f7cc3 100644 --- a/xl-v1-multipart.go +++ b/xl-v1-multipart.go @@ -252,7 +252,7 @@ func (xl xlObjects) ListMultipartUploads(bucket, prefix, keyMarker, uploadIDMark // 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) { - xlMeta := newXLMetaV1(xl.dataBlocks, xl.parityBlocks) + xlMeta := newXLMetaV1(object, xl.dataBlocks, xl.parityBlocks) // If not set default to "application/octet-stream" if meta["content-type"] == "" { contentType := "application/octet-stream" diff --git a/xl-v1-object.go b/xl-v1-object.go index 4c28bb284..f5718e0e2 100644 --- a/xl-v1-object.go +++ b/xl-v1-object.go @@ -368,7 +368,7 @@ func (xl xlObjects) PutObject(bucket string, object string, size int64, data io. tempObj := uniqueID // Initialize xl meta. - xlMeta := newXLMetaV1(xl.dataBlocks, xl.parityBlocks) + xlMeta := newXLMetaV1(object, xl.dataBlocks, xl.parityBlocks) // Read metadata associated with the object from all disks. partsMetadata, errs := xl.readAllXLMetadata(bucket, object)