[PATCH v1 1/1] affs: replace get_zeroed_page() with kzalloc()
From: Xixin Liu
Date: Tue Jul 14 2026 - 01:38:15 EST
affs_grow_extcache() allocates the per-inode extent lookup cache with
get_zeroed_page(); affs_evict_inode() frees it with free_page() through
an unsigned long cache_page local.
The cache is one zeroed buffer of AFFS_CACHE_SIZE bytes: i_lc and i_ac
share it in process context, not as a page frame. Use u32 *lc with
kzalloc()/kfree() and AFFS_LC_SIZE to split the two tables.
Signed-off-by: Xixin Liu <liuxixin@xxxxxxxxxx>
---
fs/affs/file.c | 10 ++++++----
fs/affs/inode.c | 8 ++++----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 144b17482d12..b8da8c54e0d7 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -56,11 +56,13 @@ affs_grow_extcache(struct inode *inode, u32 lc_idx)
int i, j, key;
if (!AFFS_I(inode)->i_lc) {
- char *ptr = (char *)get_zeroed_page(GFP_NOFS);
- if (!ptr)
+ u32 *lc;
+
+ lc = kzalloc(AFFS_CACHE_SIZE, GFP_NOFS);
+ if (!lc)
return -ENOMEM;
- AFFS_I(inode)->i_lc = (u32 *)ptr;
- AFFS_I(inode)->i_ac = (struct affs_ext_key *)(ptr + AFFS_CACHE_SIZE / 2);
+ AFFS_I(inode)->i_lc = lc;
+ AFFS_I(inode)->i_ac = (struct affs_ext_key *)(lc + AFFS_LC_SIZE);
}
lc_max = AFFS_LC_SIZE << AFFS_I(inode)->i_lc_shift;
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 5dd1b016bcb0..07c3a6376aaa 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -258,7 +258,7 @@ affs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
void
affs_evict_inode(struct inode *inode)
{
- unsigned long cache_page;
+ u32 *lc;
pr_debug("evict_inode(ino=%llu, nlink=%u)\n",
inode->i_ino, inode->i_nlink);
truncate_inode_pages_final(&inode->i_data);
@@ -273,12 +273,12 @@ affs_evict_inode(struct inode *inode)
mmb_invalidate(&AFFS_I(inode)->i_metadata_bhs);
clear_inode(inode);
affs_free_prealloc(inode);
- cache_page = (unsigned long)AFFS_I(inode)->i_lc;
- if (cache_page) {
+ lc = AFFS_I(inode)->i_lc;
+ if (lc) {
pr_debug("freeing ext cache\n");
AFFS_I(inode)->i_lc = NULL;
AFFS_I(inode)->i_ac = NULL;
- free_page(cache_page);
+ kfree(lc);
}
affs_brelse(AFFS_I(inode)->i_ext_bh);
AFFS_I(inode)->i_ext_last = ~1;
--
2.43.0