Skip to content

Commit bd96e07

Browse files
committed
Fix flush to use BlockCeilIdx for end boundary
Changed the flush closure in WriteAtWithoutLock to use BlockCeilIdx instead of BlockIdx for the end boundary calculation. This makes it consistent with setIsCached, isCached, and WriteZeroesAt functions, preventing edge cases where non-block-aligned end offsets could cause the tracker to miss the final partial block while still operating on it with punchHole or copy.
1 parent 11438b0 commit bd96e07

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • packages/orchestrator/pkg/sandbox/block

packages/orchestrator/pkg/sandbox/block/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func (c *Cache) WriteAtWithoutLock(b []byte, off int64) (int, error) {
350350
// same-state run as a single bulk copy / punchHole / SetRange.
351351
flush := func(runStart, runEnd int64, runZero bool) {
352352
startIdx := uint32(header.BlockIdx(runStart, c.blockSize))
353-
endIdx := uint32(header.BlockIdx(runEnd, c.blockSize))
353+
endIdx := uint32(header.BlockCeilIdx(runEnd, c.blockSize))
354354
if runZero {
355355
c.punchHole(runStart, runEnd-runStart)
356356
c.tracker.SetRange(startIdx, endIdx, Zero)

0 commit comments

Comments
 (0)