You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
![]()
8 years ago
|
/*
|
||
|
* Minio Cloud Storage, (C) 2016 Minio, Inc.
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
![]()
8 years ago
|
package cmd
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
import (
|
||
![]()
7 years ago
|
"context"
|
||
![]()
6 years ago
|
"io"
|
||
![]()
7 years ago
|
|
||
![]()
7 years ago
|
"github.com/minio/minio/cmd/logger"
|
||
![]()
7 years ago
|
)
|
||
|
|
||
![]()
6 years ago
|
// Heal heals the shard files on non-nil writers. Note that the quorum passed is 1
|
||
![]()
6 years ago
|
// as healing should continue even if it has been successful healing only one shard file.
|
||
![]()
6 years ago
|
func (e Erasure) Heal(ctx context.Context, readers []*bitrotReader, writers []*bitrotWriter, size int64) error {
|
||
![]()
6 years ago
|
r, w := io.Pipe()
|
||
|
go func() {
|
||
![]()
6 years ago
|
if err := e.Decode(ctx, w, readers, 0, size, size); err != nil {
|
||
![]()
6 years ago
|
w.CloseWithError(err)
|
||
|
return
|
||
|
}
|
||
|
w.Close()
|
||
|
}()
|
||
![]()
6 years ago
|
buf := make([]byte, e.blockSize)
|
||
![]()
6 years ago
|
// quorum is 1 because CreateFile should continue writing as long as we are writing to even 1 disk.
|
||
![]()
6 years ago
|
n, err := e.Encode(ctx, r, writers, buf, 1)
|
||
![]()
7 years ago
|
if err != nil {
|
||
![]()
6 years ago
|
return err
|
||
![]()
8 years ago
|
}
|
||
![]()
6 years ago
|
if n != size {
|
||
|
logger.LogIf(ctx, errLessData)
|
||
|
return errLessData
|
||
![]()
7 years ago
|
}
|
||
![]()
6 years ago
|
return nil
|
||
![]()
7 years ago
|
}
|