Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
lvm: add comments explaining logic around locking
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustav Paul committed Aug 9, 2019
1 parent 871c19a commit 248f7a6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/lvm/lvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,15 @@ func LookupPhysicalVolume(name string) (*PhysicalVolume, error) {
// https://github.com/Jajcus/lvm2/blob/266d6564d7a72fcff5b25367b7a95424ccf8089e/lib/metadata/metadata.c#L983

func run(cmd string, v interface{}, extraArgs ...string) error {
// lvmlock can be nil, as it is a global variable that is intended to be
// initialized from calling code outside this package. We have no way of
// knowing whether the caller performed that initialization and must
// defensively check. In the future, we may decide to simply panic with a
// nil pointer dereference.
if lvmlock != nil {
// We use Lock instead of TryLock as we have no alternative way of
// making progress. We expect lvm2 command-line utilities invoked by
// this package to return within a reasonable amount of time.
lvmlock.Lock()
defer lvmlock.Unlock()
}
Expand Down

0 comments on commit 248f7a6

Please sign in to comment.