Skip to content

Commit

Permalink
Merge pull request #427 from nalind/cri-o-release-1.14-mountslock
Browse files Browse the repository at this point in the history
[cri-o-release-1.14] layerStore.Load(): avoid double-locking the mounts list for Save
  • Loading branch information
rhatdan authored Sep 12, 2019
2 parents 1e0ff02 + 0ea4009 commit da6eb54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (r *layerStore) Load() error {
}
}
if shouldSave {
return r.Save()
return r.saveLayers()
}
}
return err
Expand Down Expand Up @@ -406,6 +406,16 @@ 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
}
return r.saveMounts()
}

func (r *layerStore) saveLayers() error {
if !r.IsReadWrite() {
return errors.Wrapf(ErrStoreIsReadOnly, "not allowed to modify the layer store at %q", r.layerspath())
}
Expand All @@ -421,13 +431,7 @@ func (r *layerStore) Save() error {
return err
}
defer r.Touch()
if err := ioutils.AtomicWriteFile(rpath, jldata, 0600); err != nil {
return err
}
r.mountsLockfile.Lock()
defer r.mountsLockfile.Unlock()
defer r.mountsLockfile.Touch()
return r.saveMounts()
return ioutils.AtomicWriteFile(rpath, jldata, 0600)
}

func (r *layerStore) saveMounts() error {
Expand Down
2 changes: 1 addition & 1 deletion layers_ffjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit da6eb54

Please sign in to comment.