[RFC PATCH v2 20/22] NFSv4: Use PAGE_SIZE_MIN to size ACL and xattr page arrays
From: Eric Curtin
Date: Tue Dec 01 2026 - 22:17:43 EST
From: Ryan Roberts <ryan.roberts@xxxxxxx>
With boot-time page size selection PAGE_SIZE is not a compile-time
constant, but NFS4ACL_MAXPAGES and NFS4XATTR_MAXPAGES are used to size
on-stack page pointer arrays.
Compute both from PAGE_SIZE_MIN, which gives the largest possible page
count. Likewise, make the BUILD_BUG_ON() in nfs4_xattr_alloc_entry()
compare against PAGE_SIZE_MIN; if it holds for the smallest page size it
holds for all of them.
No functional change for compile-time page sizes.
Signed-off-by: Ryan Roberts <ryan.roberts@xxxxxxx>
Signed-off-by: Eric Curtin <eric.curtin@xxxxxxxxxx>
---
fs/nfs/nfs42proc.c | 2 +-
fs/nfs/nfs42xattr.c | 2 +-
fs/nfs/nfs4proc.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 09b4a6ecad88..c22b76034c9b 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -1388,7 +1388,7 @@ int nfs42_proc_clone(struct file *src_f, struct file *dst_f,
return err;
}
-#define NFS4XATTR_MAXPAGES DIV_ROUND_UP(XATTR_SIZE_MAX, PAGE_SIZE)
+#define NFS4XATTR_MAXPAGES DIV_ROUND_UP(XATTR_SIZE_MAX, PAGE_SIZE_MIN)
static int _nfs42_proc_removexattr(struct inode *inode, const char *name)
{
diff --git a/fs/nfs/nfs42xattr.c b/fs/nfs/nfs42xattr.c
index 37d79400e5f4..4eb6870dd618 100644
--- a/fs/nfs/nfs42xattr.c
+++ b/fs/nfs/nfs42xattr.c
@@ -183,7 +183,7 @@ nfs4_xattr_alloc_entry(const char *name, const void *value,
uint32_t flags;
BUILD_BUG_ON(sizeof(struct nfs4_xattr_entry) +
- XATTR_NAME_MAX + 1 > PAGE_SIZE);
+ XATTR_NAME_MAX + 1 > PAGE_SIZE_MIN);
alloclen = sizeof(struct nfs4_xattr_entry);
if (name != NULL) {
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6759fa61b9b4..5cc547a1d9b9 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6003,7 +6003,7 @@ static bool nfs4_server_supports_acls(const struct nfs_server *server,
* it's OK to put sizeof(void) * (XATTR_SIZE_MAX/PAGE_SIZE) bytes on
* the stack.
*/
-#define NFS4ACL_MAXPAGES DIV_ROUND_UP(XATTR_SIZE_MAX, PAGE_SIZE)
+#define NFS4ACL_MAXPAGES DIV_ROUND_UP(XATTR_SIZE_MAX, PAGE_SIZE_MIN)
int nfs4_buf_to_pages_noslab(const void *buf, size_t buflen,
struct page **pages)