@ -251,7 +251,6 @@ func listAllBuckets(storageDisks []StorageAPI) (buckets map[string]VolInfo,
// Heals an object by re-writing corrupt/missing erasure blocks.
// Heals an object by re-writing corrupt/missing erasure blocks.
func healObject ( ctx context . Context , storageDisks [ ] StorageAPI , bucket string , object string ,
func healObject ( ctx context . Context , storageDisks [ ] StorageAPI , bucket string , object string ,
quorum int , dryRun bool ) ( result madmin . HealResultItem , err error ) {
quorum int , dryRun bool ) ( result madmin . HealResultItem , err error ) {
partsMetadata , errs := readAllXLMetadata ( ctx , storageDisks , bucket , object )
partsMetadata , errs := readAllXLMetadata ( ctx , storageDisks , bucket , object )
errCount := 0
errCount := 0
@ -432,20 +431,21 @@ func healObject(ctx context.Context, storageDisks []StorageAPI, bucket string, o
partActualSize := latestMeta . Parts [ partIndex ] . ActualSize
partActualSize := latestMeta . Parts [ partIndex ] . ActualSize
partNumber := latestMeta . Parts [ partIndex ] . Number
partNumber := latestMeta . Parts [ partIndex ] . Number
tillOffset := erasure . ShardFileTillOffset ( 0 , partSize , partSize )
tillOffset := erasure . ShardFileTillOffset ( 0 , partSize , partSize )
checksumInfo := erasureInfo . GetChecksumInfo ( partName )
readers := make ( [ ] io . ReaderAt , len ( latestDisks ) )
readers := make ( [ ] io . ReaderAt , len ( latestDisks ) )
checksumAlgo := erasureInfo . GetChecksumInfo ( partName ) . Algorithm
for i , disk := range latestDisks {
for i , disk := range latestDisks {
if disk == OfflineDisk {
if disk == OfflineDisk {
continue
continue
}
}
readers [ i ] = newBitrotReader ( disk , bucket , pathJoin ( object , partName ) , tillOffset , checksumInfo . Algorithm , checksumInfo . Hash , erasure . ShardSize ( ) )
checksumInfo := partsMetadata [ i ] . Erasure . GetChecksumInfo ( partName )
readers [ i ] = newBitrotReader ( disk , bucket , pathJoin ( object , partName ) , tillOffset , checksumAlgo , checksumInfo . Hash , erasure . ShardSize ( ) )
}
}
writers := make ( [ ] io . Writer , len ( outDatedDisks ) )
writers := make ( [ ] io . Writer , len ( outDatedDisks ) )
for i , disk := range outDatedDisks {
for i , disk := range outDatedDisks {
if disk == OfflineDisk {
if disk == OfflineDisk {
continue
continue
}
}
writers [ i ] = newBitrotWriter ( disk , minioMetaTmpBucket , pathJoin ( tmpID , partName ) , tillOffset , checksumInfo . Algorithm , erasure . ShardSize ( ) )
writers [ i ] = newBitrotWriter ( disk , minioMetaTmpBucket , pathJoin ( tmpID , partName ) , tillOffset , checksumAlgo , erasure . ShardSize ( ) )
}
}
hErr := erasure . Heal ( ctx , readers , writers , partSize )
hErr := erasure . Heal ( ctx , readers , writers , partSize )
closeBitrotReaders ( readers )
closeBitrotReaders ( readers )
@ -467,7 +467,7 @@ func healObject(ctx context.Context, storageDisks []StorageAPI, bucket string, o
continue
continue
}
}
partsMetadata [ i ] . AddObjectPart ( partNumber , partName , "" , partSize , partActualSize )
partsMetadata [ i ] . AddObjectPart ( partNumber , partName , "" , partSize , partActualSize )
partsMetadata [ i ] . Erasure . AddChecksumInfo ( ChecksumInfo { partName , checksumInfo . Algorithm , bitrotWriterSum ( writers [ i ] ) } )
partsMetadata [ i ] . Erasure . AddChecksumInfo ( ChecksumInfo { partName , checksumAlgo , bitrotWriterSum ( writers [ i ] ) } )
}
}
// If all disks are having errors, we give up.
// If all disks are having errors, we give up.
@ -476,14 +476,6 @@ func healObject(ctx context.Context, storageDisks []StorageAPI, bucket string, o
}
}
}
}
// xl.json should be written to all the healed disks.
for index , disk := range outDatedDisks {
if disk == nil {
continue
}
partsMetadata [ index ] = latestMeta
}
// Generate and write `xl.json` generated from other disks.
// Generate and write `xl.json` generated from other disks.
outDatedDisks , aErr := writeUniqueXLMetadata ( ctx , outDatedDisks , minioMetaTmpBucket , tmpID ,
outDatedDisks , aErr := writeUniqueXLMetadata ( ctx , outDatedDisks , minioMetaTmpBucket , tmpID ,
partsMetadata , diskCount ( outDatedDisks ) )
partsMetadata , diskCount ( outDatedDisks ) )