Skip to contentSkip to conversation

udf: Simplify udf_table_prealloc_blocks()

PATCH New Jan Kara 1 participant 1 message Nov 5

Subsystems (2)
lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 udf: Simplify udf_table_prealloc_blocks()

Simplify handling when the specified extent is not found in the table of free blocks.

---
 fs/udf/balloc.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

I plan to merge this through my tree.

fs/udf/balloc.c +10 -18
index 75124188e745..b6551cc7c6cf 100644
@@ -525,30 +525,22 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
 
 	while (first_block != eloc.logicalBlockNum) {
 		ret = udf_next_aext(table, &epos, &eloc, &elen, &etype, 1);
-		if (ret < 0)
+		if (ret <= 0)
 			goto err_out;
-		if (ret == 0)
-			break;
 		udf_debug("eloc=%u, elen=%u, first_block=%u\n",
 			  eloc.logicalBlockNum, elen, first_block);
 	}
 
-	if (ret > 0 && first_block == eloc.logicalBlockNum) {
-		epos.offset -= adsize;
-
-		alloc_count = (elen >> sb->s_blocksize_bits);
-		if (alloc_count > block_count) {
-			alloc_count = block_count;
-			eloc.logicalBlockNum += alloc_count;
-			elen -= (alloc_count << sb->s_blocksize_bits);
-			udf_write_aext(table, &epos, &eloc,
-					(etype << 30) | elen, 1);
-		} else
-			udf_delete_aext(table, epos, &freed);
-	} else {
-		alloc_count = 0;
-	}
+	epos.offset -= adsize;
 
+	alloc_count = (elen >> sb->s_blocksize_bits);
+	if (alloc_count > block_count) {
+		alloc_count = block_count;
+		eloc.logicalBlockNum += alloc_count;
+		elen -= (alloc_count << sb->s_blocksize_bits);
+		udf_write_aext(table, &epos, &eloc, (etype << 30) | elen, 1);
+	} else
+		udf_delete_aext(table, epos, &freed);
 err_out:
 	brelse(epos.bh);
 
Signature · 1 line
2.53.0