Skip to content

Commit

Permalink
Document the locking hierarchy of the various store locks
Browse files Browse the repository at this point in the history
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Dec 5, 2022
1 parent bf13cef commit 273e81c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,15 @@ type ContainerOptions struct {
}

type store struct {
// # Locking hierarchy:
// These locks do not all need to be held simultaneously, but if some code does need to lock more than one, it MUST do so in this order:
// - graphLock
// - layerStore.start{Reading,Writing}
// - roLayerStores[].startReading (in the order of the items of the roLayerStores array)
// - imageStore.start{Reading,Writing}
// - roImageStores[].startReading (in the order of the items of the roImageStores array)
// - containerStore.start{Reading,Writing}

// The following fields are only set when constructing store, and must never be modified afterwards.
// They are safe to access without any other locking.
runRoot string
Expand Down

0 comments on commit 273e81c

Please sign in to comment.