[RFC PATCH v2 07/13] null_blk: Size the nullb_page bitmap for PAGE_SIZE_MAX

From: Eric Curtin

Date: Tue Dec 01 2026 - 22:17:38 EST


From: Eric Curtin <eric.curtin@xxxxxxxxxx>

With arm64 boot-time page size selection PAGE_SIZE is not a
compile-time constant, but struct nullb_page embeds a bitmap with one
bit per sector of a page plus two flag bits.

Add MAP_SZ_MAX, based on PAGE_SIZE_MAX, and use it to declare the
bitmap. The runtime logic (NULLB_PAGE_LOCK and NULLB_PAGE_FREE) keeps
using MAP_SZ, derived from the actual page size, so the extra bitmap
space is simply unused on smaller pages.

No functional change for compile-time page sizes.

Signed-off-by: Eric Curtin <eric.curtin@xxxxxxxxxx>
---
drivers/block/null_blk/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index ec0d7ba4d938..f5a02a861daf 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -46,6 +46,7 @@ enum nullb_device_flags {
};

#define MAP_SZ ((PAGE_SIZE >> SECTOR_SHIFT) + 2)
+#define MAP_SZ_MAX ((PAGE_SIZE_MAX >> SECTOR_SHIFT) + 2)
/*
* nullb_page is a page in memory for nullb devices.
*
@@ -60,7 +61,7 @@ enum nullb_device_flags {
*/
struct nullb_page {
struct page *page;
- DECLARE_BITMAP(bitmap, MAP_SZ);
+ DECLARE_BITMAP(bitmap, MAP_SZ_MAX);
};
#define NULLB_PAGE_LOCK (MAP_SZ - 1)
#define NULLB_PAGE_FREE (MAP_SZ - 2)