diff options
author | Marek BehĂșn <marek.behun@nic.cz> | 2020-03-30 18:48:42 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-04-20 12:23:29 -0400 |
commit | 48180e15d3eaff51b1da30a90bc64b7acba8fb51 (patch) | |
tree | 21b51f587ddac3a906c1329be9c97efb8742d0c6 /fs | |
parent | f4a1426fd6e473ff523147a67d079c7ccb2a4e27 (diff) | |
download | u-boot-48180e15d3eaff51b1da30a90bc64b7acba8fb51.tar.gz u-boot-48180e15d3eaff51b1da30a90bc64b7acba8fb51.tar.bz2 u-boot-48180e15d3eaff51b1da30a90bc64b7acba8fb51.zip |
fs: btrfs: support sparse extents
When logical address of a regular extent is 0, the extent is sparse and
consists of all zeros.
Without this when sparse extents are used in a file reading fails with
Cannot map logical address 0 to physical
Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/extent-io.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/extent-io.c b/fs/btrfs/extent-io.c index 66d0e1c7d6..2e4599cf64 100644 --- a/fs/btrfs/extent-io.c +++ b/fs/btrfs/extent-io.c @@ -78,6 +78,12 @@ u64 btrfs_read_extent_reg(struct btrfs_path *path, if (size > dlen - offset) size = dlen - offset; + /* sparse extent */ + if (extent->disk_bytenr == 0) { + memset(out, 0, size); + return size; + } + physical = btrfs_map_logical_to_physical(extent->disk_bytenr); if (physical == -1ULL) return -1ULL; |