commit
2f858a07c7
|
@ -360,10 +360,10 @@ func (cm *cacheManager) prune(ctx context.Context, ch chan client.UsageInfo, opt
|
||||||
gcMode := opt.keepBytes != 0
|
gcMode := opt.keepBytes != 0
|
||||||
cutOff := time.Now().Add(-opt.keepDuration)
|
cutOff := time.Now().Add(-opt.keepDuration)
|
||||||
|
|
||||||
locked := map[*cacheRecord]struct{}{}
|
locked := map[*sync.Mutex]struct{}{}
|
||||||
|
|
||||||
for _, cr := range cm.records {
|
for _, cr := range cm.records {
|
||||||
if _, ok := locked[cr]; ok {
|
if _, ok := locked[cr.mu]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cr.mu.Lock()
|
cr.mu.Lock()
|
||||||
|
@ -431,7 +431,7 @@ func (cm *cacheManager) prune(ctx context.Context, ch chan client.UsageInfo, opt
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
locked[cr] = struct{}{}
|
locked[cr.mu] = struct{}{}
|
||||||
continue // leave the record locked
|
continue // leave the record locked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,7 +454,6 @@ func (cm *cacheManager) prune(ctx context.Context, ch chan client.UsageInfo, opt
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
toDelete = toDelete[:1]
|
toDelete = toDelete[:1]
|
||||||
opt.totalSize -= getSize(toDelete[0].md)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cm.mu.Unlock()
|
cm.mu.Unlock()
|
||||||
|
@ -483,7 +482,9 @@ func (cm *cacheManager) prune(ctx context.Context, ch chan client.UsageInfo, opt
|
||||||
if cr.parent != nil {
|
if cr.parent != nil {
|
||||||
c.Parent = cr.parent.ID()
|
c.Parent = cr.parent.ID()
|
||||||
}
|
}
|
||||||
|
if c.Size == sizeUnknown && cr.equalImmutable != nil {
|
||||||
|
c.Size = getSize(cr.equalImmutable.md) // benefit from DiskUsage calc
|
||||||
|
}
|
||||||
if c.Size == sizeUnknown {
|
if c.Size == sizeUnknown {
|
||||||
cr.mu.Unlock() // all the non-prune modifications already protected by cr.dead
|
cr.mu.Unlock() // all the non-prune modifications already protected by cr.dead
|
||||||
s, err := cr.Size(ctx)
|
s, err := cr.Size(ctx)
|
||||||
|
@ -494,6 +495,8 @@ func (cm *cacheManager) prune(ctx context.Context, ch chan client.UsageInfo, opt
|
||||||
cr.mu.Lock()
|
cr.mu.Lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opt.totalSize -= c.Size
|
||||||
|
|
||||||
if cr.equalImmutable != nil {
|
if cr.equalImmutable != nil {
|
||||||
if err1 := cr.equalImmutable.remove(ctx, false); err == nil {
|
if err1 := cr.equalImmutable.remove(ctx, false); err == nil {
|
||||||
err = err1
|
err = err1
|
||||||
|
|
Loading…
Reference in New Issue