Skip to content

Commit

Permalink
[VBD] Fix missing lock in COWStore
Browse files Browse the repository at this point in the history
  • Loading branch information
maggie-lou committed Oct 10, 2023
1 parent 95e498a commit d138e73
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,16 @@ func (c *COWStore) GetChunkStartAddressAndSize(offset uintptr, write bool) (uint
func (c *COWStore) GetPageAddress(offset uintptr, write bool) (uintptr, error) {
chunkStartOffset := c.chunkStartOffset(int64(offset))
chunkRelativeAddress := offset - uintptr(chunkStartOffset)

c.mu.Lock()
defer c.mu.Unlock()
if write {
if err := c.copyChunkIfNotDirty(chunkStartOffset); err != nil {
return 0, status.WrapError(err, "copy chunk")
}
}

c.mu.RLock()
chunk := c.chunks[chunkStartOffset]
c.mu.RUnlock()
if chunk == nil {
// No data (yet); map into our static zero-filled buf. Note that this
// can only happen for reads, since for writes we call copyChunkIfNotDirty above.
Expand Down

0 comments on commit d138e73

Please sign in to comment.