I think the implemented extent traversal logic is incorrect.
This is not documented anywhere but ext4_extent_idx structs after the ext4_extent_header are sorted by the ei_block.
The current logic picks the ext4_extent_idx which satisfies ext4_extent_idx.ei_block < file_block_no but that will always choose the first ext4_extent_idx struct. This will lead to incorrect results for larger files.
The linux kernel implementation does a binary search: look at ext4_ext_binsearch_idx.
I think the implemented extent traversal logic is incorrect. This is not documented anywhere but
ext4_extent_idx
structs after theext4_extent_header
are sorted by theei_block
.The current logic picks the
ext4_extent_idx
which satisfiesext4_extent_idx.ei_block < file_block_no
but that will always choose the firstext4_extent_idx
struct. This will lead to incorrect results for larger files.The linux kernel implementation does a binary search: look at
ext4_ext_binsearch_idx
.