Skip to content

Commit 67fe1d6

Browse files
johnpgarrykawasaki
authored andcommitted
block: Enforce power-of-2 physical block size
The merging/splitting code and other queue limits checking depends on the physical block size being a power-of-2, so enforce it. Reviewed-by: Martin K. Petersen <[email protected]> Signed-off-by: John Garry <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Damien Le Moal <[email protected]>
1 parent 3fa7bdd commit 67fe1d6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

block/blk-settings.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ int blk_validate_limits(struct queue_limits *lim)
314314
}
315315
if (lim->physical_block_size < lim->logical_block_size)
316316
lim->physical_block_size = lim->logical_block_size;
317+
else if (!is_power_of_2(lim->physical_block_size)) {
318+
pr_warn("Invalid physical block size (%d)\n", lim->physical_block_size);
319+
return -EINVAL;
320+
}
317321

318322
/*
319323
* The minimum I/O size defaults to the physical block size unless

0 commit comments

Comments
 (0)