Skip to contentSkip to conversation

fs: btrfs: support sparse extents

PATCH New Marek Behún 2 participants 2 messages Mar 30, 2020 – Apr 21, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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

---
 fs/btrfs/extent-io.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/btrfs/extent-io.c +6 -0
index 66d0e1c7d6..2e4599cf64 100644
@@ -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;
Signature · 1 line
2.24.1
#1 lore raw

PATCH v2 1/1 fs: btrfs: support sparse extents

Quoted 7 lines · Marek Beh?n

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

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200421/7eb4d34d/attachment.sig>