Krzysztof Nowicki 1e5ed5f5f5 fs/ext2: Fix handling of missing sparse extent leafs
When a file on ext4 is stored as sparse the data belonging to
zero-filled blocks is not written to storage and the extent map is
missing entries for these blocks. Such case can happen both for depth
0 extents (leafs) as well as higher-level tables.

Consider a scenario of a file which has a zero-filled beginning (e.g.
ISO image). In such case real data starts at block 8. If such a file is
stored using 2-level extent structure the extent list in the inode will
be depth 1 and will have an entry to a depth 0 (leaf) extent header for
blocks 8-n.

Unfortunately existing GRUB2 ext2 driver is only able to handle missing
entries in leaf extent tables, for which the grub_ext2_read_block()
function returns 0. In case the whole leaf extent list is missing for
a block the function fails with "invalid extent" error.

The fix for this problem relies on the grub_ext4_find_leaf() helper
function to distinguish two error cases: missing extent and error
walking through the extent tree. The existing error message is raised
only for the latter case, while for the missing leaf extent zero is
returned from grub_ext2_read_block() indicating a sparse block.

Signed-off-by: Krzysztof Nowicki <krzysztof.nowicki@nokia.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2021-10-04 14:38:25 +02:00
..
2011-10-30 16:10:18 +01:00
2015-07-27 13:19:02 +02:00
2019-04-09 10:03:29 +10:00
2011-04-11 18:13:00 +02:00
2021-03-02 15:54:18 +01:00
2011-04-11 08:16:13 +02:00
2020-07-29 16:55:47 +02:00
2019-04-09 10:03:29 +10:00
2019-04-09 10:03:29 +10:00
2020-07-29 16:55:47 +02:00
2010-05-06 11:34:04 +05:30
2012-12-08 20:56:58 +01:00