Skip to content

Conversation

@ssel
Copy link

@ssel ssel commented Nov 12, 2023

Fix for ExtentsFileBuffer.Read, which reads a portion of the contents of a single file in an ext file system.

The old code relied on a private method FindExtent which, given the next logical block number to read in the file, sometimes returned the extent containing that block but sometimes returned a prior extent. This logic was sufficient for non-sparse files without "holes" but could not properly handle sparse files. In the presence of holes, the Read method could fall into an infinite loop trying to read the file but never making progress.

The new code redefines FindExtent to return the extent containing a given logical block or, if none, the first extent beyond it. Given this information, the Read method is guaranteed to always make forward progress.

This pull request also fixes a problem in which the high-order bit of the Extent.NumBlocks field is misinterpreted. That bit is used as a flag by the Linux kernel to indicate an unwritten extent, and should not be considered part of the actual block count.

* Fix ExtentsFileBuffer.Read for sparse files with holes.
@ssel
Copy link
Author

ssel commented Nov 12, 2023

@LordMike could you please review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant