[RFC PATCH v2 03/22] ocfs2: Use PAGE_SIZE_MIN/MAX for the page-count limits
From: Eric Curtin
Date: Tue Dec 01 2026 - 22:16:04 EST
From: Eric Curtin <eric.curtin@xxxxxxxxxx>
With arm64 boot-time page size selection PAGE_SIZE is not a compile-time
constant, so it cannot be used in #if or in the macros that size arrays
in struct ocfs2_write_ctxt.
In aops.c, use PAGE_SIZE_MIN for OCFS2_MAX_CTXT_PAGES, since the
smallest page needs the most pages per cluster, and PAGE_SIZE_MAX for
OCFS2_MAX_CLUSTERS_PER_PAGE, since the largest page holds the most
clusters. In dlmcommon.h, replace the #if that selected DLM_HASH_PAGES
with a conditional expression, since the value is only used at run time.
No functional change for compile-time page sizes.
Signed-off-by: Eric Curtin <eric.curtin@xxxxxxxxxx>
---
fs/ocfs2/aops.c | 6 +++---
fs/ocfs2/dlm/dlmcommon.h | 8 +++-----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 4acdbb70882c..8c549de9035e 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -663,13 +663,13 @@ int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno,
return ret;
}
-#if (PAGE_SIZE >= OCFS2_MAX_CLUSTERSIZE)
+#if (PAGE_SIZE_MIN >= OCFS2_MAX_CLUSTERSIZE)
#define OCFS2_MAX_CTXT_PAGES 1
#else
-#define OCFS2_MAX_CTXT_PAGES (OCFS2_MAX_CLUSTERSIZE / PAGE_SIZE)
+#define OCFS2_MAX_CTXT_PAGES (OCFS2_MAX_CLUSTERSIZE / PAGE_SIZE_MIN)
#endif
-#define OCFS2_MAX_CLUSTERS_PER_PAGE (PAGE_SIZE / OCFS2_MIN_CLUSTERSIZE)
+#define OCFS2_MAX_CLUSTERS_PER_PAGE (PAGE_SIZE_MAX / OCFS2_MIN_CLUSTERSIZE)
struct ocfs2_unwritten_extent {
struct list_head ue_node;
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index 58b28dfa8d34..6e16291586b5 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -18,11 +18,9 @@
#define DLM_LOCK_RES_OWNER_UNKNOWN O2NM_MAX_NODES
#define DLM_HASH_SIZE_DEFAULT (1 << 17)
-#if DLM_HASH_SIZE_DEFAULT < PAGE_SIZE
-# define DLM_HASH_PAGES 1
-#else
-# define DLM_HASH_PAGES (DLM_HASH_SIZE_DEFAULT / PAGE_SIZE)
-#endif
+#define DLM_HASH_PAGES \
+ (DLM_HASH_SIZE_DEFAULT < PAGE_SIZE ? 1 : \
+ DLM_HASH_SIZE_DEFAULT / PAGE_SIZE)
#define DLM_BUCKETS_PER_PAGE (PAGE_SIZE / sizeof(struct hlist_head))
#define DLM_HASH_BUCKETS (DLM_HASH_PAGES * DLM_BUCKETS_PER_PAGE)