|
|
|
@ -507,9 +507,8 @@ func (s *xlSets) Shutdown(ctx context.Context) error { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MakeBucketLocation - creates a new bucket across all sets simultaneously
|
|
|
|
|
// even if one of the sets fail to create buckets, we proceed to undo a
|
|
|
|
|
// successful operation.
|
|
|
|
|
// MakeBucketLocation - creates a new bucket across all sets simultaneously,
|
|
|
|
|
// then return the first encountered error
|
|
|
|
|
func (s *xlSets) MakeBucketWithLocation(ctx context.Context, bucket, location string, lockEnabled bool) error { |
|
|
|
|
g := errgroup.WithNErrs(len(s.sets)) |
|
|
|
|
|
|
|
|
@ -522,11 +521,10 @@ func (s *xlSets) MakeBucketWithLocation(ctx context.Context, bucket, location st |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
errs := g.Wait() |
|
|
|
|
// Upon any error we try to undo the make bucket operation if possible
|
|
|
|
|
// on all sets where it succeeded.
|
|
|
|
|
|
|
|
|
|
// Return the first encountered error
|
|
|
|
|
for _, err := range errs { |
|
|
|
|
if err != nil { |
|
|
|
|
undoMakeBucketSets(bucket, s.sets, errs) |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -535,25 +533,6 @@ func (s *xlSets) MakeBucketWithLocation(ctx context.Context, bucket, location st |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// This function is used to undo a successful MakeBucket operation.
|
|
|
|
|
func undoMakeBucketSets(bucket string, sets []*xlObjects, errs []error) { |
|
|
|
|
g := errgroup.WithNErrs(len(sets)) |
|
|
|
|
|
|
|
|
|
// Undo previous make bucket entry on all underlying sets.
|
|
|
|
|
for index := range sets { |
|
|
|
|
index := index |
|
|
|
|
g.Go(func() error { |
|
|
|
|
if errs[index] == nil { |
|
|
|
|
return sets[index].DeleteBucket(GlobalContext, bucket, false) |
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
}, index) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Wait for all delete bucket to finish.
|
|
|
|
|
g.Wait() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// hashes the key returning an integer based on the input algorithm.
|
|
|
|
|
// This function currently supports
|
|
|
|
|
// - CRCMOD
|
|
|
|
|