Commit 1da67b5b authored by John Garry's avatar John Garry Committed by Jens Axboe
Browse files

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: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarJohn Garry <john.g.garry@oracle.com>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20250729091448.1691334-3-john.g.garry@oracle.com


[axboe: add missing braces]
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 448dfecc
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -320,8 +320,12 @@ int blk_validate_limits(struct queue_limits *lim)
		pr_warn("Invalid logical block size (%d)\n", lim->logical_block_size);
		return -EINVAL;
	}
	if (lim->physical_block_size < lim->logical_block_size)
	if (lim->physical_block_size < lim->logical_block_size) {
		lim->physical_block_size = lim->logical_block_size;
	} else if (!is_power_of_2(lim->physical_block_size)) {
		pr_warn("Invalid physical block size (%d)\n", lim->physical_block_size);
		return -EINVAL;
	}

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