r.mountsLockfile.Touch() directly in saveMounts()

... instead of doing it in callers.

This makes it clearer that the Touch() always happens,
and it adds error handling.

OTOH there might be some undocumented reason why the Touch()
should happen in callers even if the saveMounts() call is
not reached.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2022-09-30 23:37:15 +02:00
parent 5e8eb4c69a
commit 9ca93b641f
1 changed files with 3 additions and 3 deletions

View File

@ -479,7 +479,6 @@ func (r *layerStore) loadMounts() error {
func (r *layerStore) Save() error {
r.mountsLockfile.Lock()
defer r.mountsLockfile.Unlock()
defer r.mountsLockfile.Touch()
if err := r.saveLayers(); err != nil {
return err
}
@ -535,6 +534,9 @@ func (r *layerStore) saveMounts() error {
if err = ioutils.AtomicWriteFile(mpath, jmdata, 0600); err != nil {
return err
}
if err := r.mountsLockfile.Touch(); err != nil {
return err
}
return r.loadMounts()
}
@ -953,7 +955,6 @@ func (r *layerStore) Mount(id string, options drivers.MountOpts) (string, error)
return "", err
}
}
defer r.mountsLockfile.Touch()
layer, ok := r.lookup(id)
if !ok {
return "", ErrLayerUnknown
@ -1004,7 +1005,6 @@ func (r *layerStore) Unmount(id string, force bool) (bool, error) {
return false, err
}
}
defer r.mountsLockfile.Touch()
layer, ok := r.lookup(id)
if !ok {
layerByMount, ok := r.bymount[filepath.Clean(id)]