@ -309,7 +309,7 @@ func (ahs *allHealState) PopHealStatusJSON(path string,
// healSource denotes single entity and heal option.
// healSource denotes single entity and heal option.
type healSource struct {
type healSource struct {
path string // entity path (format, buckets, objects) to heal
path string // entity path (format, buckets, objects) to heal
opts * madmin . HealOpts // optional heal option overrides default setting
opts madmin . HealOpts // optional heal option overrides default setting
}
}
// healSequence - state for each heal sequence initiated on the
// healSequence - state for each heal sequence initiated on the
@ -321,9 +321,12 @@ type healSequence struct {
// path is just pathJoin(bucket, objPrefix)
// path is just pathJoin(bucket, objPrefix)
path string
path string
// List of entities (format, buckets, objects) to heal
// A channel of entities (format, buckets, objects) to heal
sourceCh chan healSource
sourceCh chan healSource
// A channel of entities with heal result
respCh chan healResult
// Report healing progress
// Report healing progress
reportProgress bool
reportProgress bool
@ -385,6 +388,7 @@ func newHealSequence(bucket, objPrefix, clientAddr string,
ctx := logger . SetReqInfo ( GlobalContext , reqInfo )
ctx := logger . SetReqInfo ( GlobalContext , reqInfo )
return & healSequence {
return & healSequence {
respCh : make ( chan healResult ) ,
bucket : bucket ,
bucket : bucket ,
objPrefix : objPrefix ,
objPrefix : objPrefix ,
path : pathJoin ( bucket , objPrefix ) ,
path : pathJoin ( bucket , objPrefix ) ,
@ -636,20 +640,19 @@ func (h *healSequence) healSequenceStart() {
}
}
func ( h * healSequence ) queueHealTask ( source healSource , healType madmin . HealItemType ) error {
func ( h * healSequence ) queueHealTask ( source healSource , healType madmin . HealItemType ) error {
var respCh = make ( chan healResult )
defer close ( respCh )
// Send heal request
// Send heal request
task := healTask {
task := healTask {
path : source . path ,
path : source . path ,
responseCh : respCh ,
opts : h . settings ,
opts : h . settings ,
responseCh : h . respCh ,
}
}
if source . opts != nil {
if ! source . opts . Equal ( h . settings ) {
task . opts = * source . opts
task . opts = source . opts
}
}
globalBackgroundHealRoutine . queueHealTask ( task )
globalBackgroundHealRoutine . queueHealTask ( task )
// Wait for answer and push result to the client
res := <- respCh
select {
case res := <- h . respCh :
if ! h . reportProgress {
if ! h . reportProgress {
h . mutex . Lock ( )
h . mutex . Lock ( )
defer h . mutex . Unlock ( )
defer h . mutex . Unlock ( )
@ -683,6 +686,12 @@ func (h *healSequence) queueHealTask(source healSource, healType madmin.HealItem
res . result . Detail = res . err . Error ( )
res . result . Detail = res . err . Error ( )
}
}
return h . pushHealResultItem ( res . result )
return h . pushHealResultItem ( res . result )
case <- h . ctx . Done ( ) :
return nil
case <- h . traverseAndHealDoneCh :
return nil
}
}
}
func ( h * healSequence ) healItemsFromSourceCh ( ) error {
func ( h * healSequence ) healItemsFromSourceCh ( ) error {