Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Commit

Permalink
file_data: mark correct path dirty when clearing iptr sizes
Browse files Browse the repository at this point in the history
This fixes test flakes that have increased recently (such as
`TestTruncateLargeThenWriteToSmallerOffsetWithHoles`).
  • Loading branch information
strib committed Dec 20, 2018
1 parent bc4dba0 commit 36451f8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions libkbfs/file_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ func (fd *fileData) findIPtrsAndClearSize(
}
infoSeen[parentPtr] = true

for _, iptr := range pb.pblock.(*FileBlock).IPtrs {
for i, iptr := range pb.pblock.(*FileBlock).IPtrs {
if ptrs[iptr.BlockPointer] {
// Mark this pointer, and all parent blocks, as dirty.
parentPtr := fd.rootBlockPointer()
Expand All @@ -1052,7 +1052,16 @@ func (fd *fileData) findIPtrsAndClearSize(
path[i].pblock = pblock
parentPtr = path[i].childBlockPtr()
}
_, _, err = fd.tree.markParentsDirty(path[:level+1])
// Because we only check each parent once, the
// `path` we're using here will be the one with a
// childIndex of 0. But, that's not necessarily
// the one that matches the pointer that needs to
// be dirty. So make a new path and set the
// childIndex to the correct pointer instead.
newPath := make([]parentBlockAndChildIndex, level+1)
copy(newPath, path[:level+1])
newPath[level].childIndex = i
_, _, err = fd.tree.markParentsDirty(newPath)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 36451f8

Please sign in to comment.