Skip to contentSkip to conversation

efs: fix direct extent lookup for indirect extents

PATCH In review Keshav Verma 2 participants 3 messages Jun 18 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efs: fix direct extent lookup for indirect extents

The loop that finds the direct extent containing an indirect extent used cur < ibase as its condition. Since ibase starts at zero, the loop never advances for normal non-negative cur values, so only the first direct extent is considered.

Iterate over the direct extents and stop when cur falls within the range covered by the current direct extent.

---
 fs/efs/inode.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fs/efs/inode.c +7 -2
index 4b132729e638..16b5ee10e323 100644
@@ -254,9 +254,14 @@ efs_block_t efs_map_block(struct inode *inode, efs_block_t block) {
 		 *
 		 */
 		ibase = 0;
-		for(dirext = 0; cur < ibase && dirext < direxts; dirext++) {
-			ibase += in->extents[dirext].cooked.ex_length *
+		for (dirext = 0; dirext < direxts; dirext++) {
+			int entries = in->extents[dirext].cooked.ex_length *
 				(EFS_BLOCKSIZE / sizeof(efs_extent));
+
+			if (cur < ibase + entries)
+				break;
+
+			ibase += entries;
 		}
 
 		if (dirext == direxts) {
Signature · 1 line
2.39.5
#1 lore raw
Quoted 7 lines · Keshav Verma

The loop that finds the direct extent containing an indirect extent used cur < ibase as its condition. Since ibase starts at zero, the loop never advances for normal non-negative cur values, so only the first direct extent is considered.

Iterate over the direct extents and stop when cur falls within the range covered by the current direct extent.

Nah.

https://lore.kernel.org/linux-fsdevel/[email protected]/