Skip to content

Commit 13c8f5f

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. Signed-off-by: John Garry <[email protected]>
1 parent 2702f55 commit 13c8f5f

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
@@ -268,6 +268,10 @@ int blk_validate_limits(struct queue_limits *lim)
268268
}
269269
if (lim->physical_block_size < lim->logical_block_size)
270270
lim->physical_block_size = lim->logical_block_size;
271+
else if (!is_power_of_2(lim->physical_block_size)) {
272+
pr_warn("Invalid physical block size (%d)\n", lim->physical_block_size);
273+
return -EINVAL;
274+
}
271275

272276
/*
273277
* The minimum I/O size defaults to the physical block size unless

0 commit comments

Comments
 (0)