[RFC PATCH v2 12/22] ecryptfs: Resolve the PAGE_SIZE cache sizes at cache creation time

From: Eric Curtin

Date: Tue Dec 01 2026 - 22:17:09 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 initialise the static ecryptfs_cache_infos[]
table.

Drop the PAGE_SIZE sizes of the ecryptfs_headers and
ecryptfs_xattr_cache entries, and treat a size of 0 as PAGE_SIZE in
ecryptfs_init_kmem_caches(), where the value is known at run time.

No functional change for compile-time page sizes.

Signed-off-by: Eric Curtin <eric.curtin@xxxxxxxxxx>
---
fs/ecryptfs/main.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 5f37cddb956f..bce3250047e3 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -655,7 +655,7 @@ inode_info_init_once(void *vptr)
static struct ecryptfs_cache_info {
struct kmem_cache **cache;
const char *name;
- size_t size;
+ size_t size; /* 0 means PAGE_SIZE */
slab_flags_t flags;
void (*ctor)(void *obj);
} ecryptfs_cache_infos[] = {
@@ -684,12 +684,10 @@ static struct ecryptfs_cache_info {
{
.cache = &ecryptfs_header_cache,
.name = "ecryptfs_headers",
- .size = PAGE_SIZE,
},
{
.cache = &ecryptfs_xattr_cache,
.name = "ecryptfs_xattr_cache",
- .size = PAGE_SIZE,
},
{
.cache = &ecryptfs_key_record_cache,
@@ -744,7 +742,7 @@ static int ecryptfs_init_kmem_caches(void)
struct ecryptfs_cache_info *info;

info = &ecryptfs_cache_infos[i];
- *(info->cache) = kmem_cache_create(info->name, info->size, 0,
+ *(info->cache) = kmem_cache_create(info->name, info->size ?: PAGE_SIZE, 0,
SLAB_HWCACHE_ALIGN | info->flags, info->ctor);
if (!*(info->cache)) {
ecryptfs_free_kmem_caches();