cache: reenable last used metadata
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>docker-18.09
parent
acdaf17cf0
commit
a66885e70c
|
@ -185,24 +185,22 @@ func getLastUsed(si *metadata.StorageItem) (int, *time.Time) {
|
||||||
return usageCount, &tm
|
return usageCount, &tm
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: temporarily removed until there is an implementation that can do this
|
func updateLastUsed(si *metadata.StorageItem) error {
|
||||||
// on background or one that doesn't get new refs for every operation
|
count, _ := getLastUsed(si)
|
||||||
// func updateLastUsed(si *metadata.StorageItem) error {
|
count++
|
||||||
// count, _ := getLastUsed(si)
|
|
||||||
// count++
|
v, err := metadata.NewValue(count)
|
||||||
//
|
if err != nil {
|
||||||
// v, err := metadata.NewValue(count)
|
return errors.Wrap(err, "failed to create usageCount value")
|
||||||
// if err != nil {
|
}
|
||||||
// return errors.Wrap(err, "failed to create usageCount value")
|
v2, err := metadata.NewValue(time.Now().UnixNano())
|
||||||
// }
|
if err != nil {
|
||||||
// v2, err := metadata.NewValue(time.Now().UnixNano())
|
return errors.Wrap(err, "failed to create lastUsedAt value")
|
||||||
// if err != nil {
|
}
|
||||||
// return errors.Wrap(err, "failed to create lastUsedAt value")
|
return si.Update(func(b *bolt.Bucket) error {
|
||||||
// }
|
if err := si.SetValue(b, keyUsageCount, v); err != nil {
|
||||||
// return si.Update(func(b *bolt.Bucket) error {
|
return err
|
||||||
// if err := si.SetValue(b, keyUsageCount, v); err != nil {
|
}
|
||||||
// return err
|
return si.SetValue(b, keyLastUsedAt, v2)
|
||||||
// }
|
})
|
||||||
// return si.SetValue(b, keyLastUsedAt, v2)
|
}
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
|
@ -212,11 +212,10 @@ func (sr *immutableRef) Release(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sr *immutableRef) release(ctx context.Context) error {
|
func (sr *immutableRef) release(ctx context.Context) error {
|
||||||
// updateLastUsed(sr.md)
|
|
||||||
|
|
||||||
delete(sr.refs, sr)
|
delete(sr.refs, sr)
|
||||||
|
|
||||||
if len(sr.refs) == 0 {
|
if len(sr.refs) == 0 {
|
||||||
|
updateLastUsed(sr.md)
|
||||||
if sr.viewMount != nil { // TODO: release viewMount earlier if possible
|
if sr.viewMount != nil { // TODO: release viewMount earlier if possible
|
||||||
if err := sr.cm.Snapshotter.Remove(ctx, sr.view); err != nil {
|
if err := sr.cm.Snapshotter.Remove(ctx, sr.view); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -333,7 +332,6 @@ func (sr *mutableRef) Release(ctx context.Context) error {
|
||||||
|
|
||||||
func (sr *mutableRef) release(ctx context.Context) error {
|
func (sr *mutableRef) release(ctx context.Context) error {
|
||||||
delete(sr.refs, sr)
|
delete(sr.refs, sr)
|
||||||
// updateLastUsed(sr.md)
|
|
||||||
if getCachePolicy(sr.md) != cachePolicyRetain {
|
if getCachePolicy(sr.md) != cachePolicyRetain {
|
||||||
if sr.equalImmutable != nil {
|
if sr.equalImmutable != nil {
|
||||||
if getCachePolicy(sr.equalImmutable.md) == cachePolicyRetain {
|
if getCachePolicy(sr.equalImmutable.md) == cachePolicyRetain {
|
||||||
|
@ -349,6 +347,8 @@ func (sr *mutableRef) release(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sr.remove(ctx, true)
|
return sr.remove(ctx, true)
|
||||||
|
} else {
|
||||||
|
updateLastUsed(sr.md)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue