Thread (7 messages) 7 messages, 4 authors, 2025-07-29
STALE330d LANDED: 2 (2M)
Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 2/2] block: Enforce power-of-2 physical block size

From: John Garry <john.g.garry@oracle.com>
Date: 2025-07-29 09:15:32
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

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 <martin.petersen@oracle.com>
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 block/blk-settings.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/block/blk-settings.c b/block/blk-settings.c
index fa53a330f9b99..5ae0a253e43fd 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -274,6 +274,10 @@ int blk_validate_limits(struct queue_limits *lim)
 	}
 	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
-- 
2.43.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help