[PATCH 1/3] jfs: stop kmapping metapage folios
From: Tal Zussman
Date: Tue Nov 17 2026 - 01:57:04 EST
insert_metapage() kmaps the folio for as long as a metapage is attached
to it, but both metadata mappings use GFP_NOFS, so their folios never
come from highmem. __get_metapage() already relies on that by setting
mp->data from folio_address().
Remove the kmap() and kunmap() calls, and add a comment at the two
mapping_set_gfp_mask() calls so the mask doesn't gain __GFP_HIGHMEM
later. This removes the last users of the deprecated kmap() API in jfs.
While at it, fix three comments that refer to pages instead of folios.
Signed-off-by: Tal Zussman <tz2294@xxxxxxxxxxxx>
---
fs/jfs/jfs_imap.c | 1 +
fs/jfs/jfs_metapage.c | 11 +++--------
fs/jfs/jfs_metapage.h | 2 +-
fs/jfs/super.c | 1 +
4 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index b84ba4d7dfb4..aa60437d51af 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -467,6 +467,7 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
}
ip->i_mapping->a_ops = &jfs_metapage_aops;
+ /* Metapages are accessed through folio_address(), so no highmem. */
mapping_set_gfp_mask(ip->i_mapping, GFP_NOFS);
/* Allocations to metadata inodes should not affect quotas */
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 41fe12e641ce..b483c8d4d999 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -102,7 +102,6 @@ static inline int insert_metapage(struct folio *folio, struct metapage *mp)
if (!a)
return -ENOMEM;
folio_attach_private(folio, a);
- kmap(&folio->page);
}
if (mp) {
@@ -129,7 +128,6 @@ static inline void remove_metapage(struct folio *folio, struct metapage *mp)
if (--a->mp_count == 0) {
kfree(a);
folio_detach_private(folio);
- kunmap(&folio->page);
}
}
@@ -212,17 +210,14 @@ static inline struct metapage *folio_to_mp(struct folio *folio, int offset)
static inline int insert_metapage(struct folio *folio, struct metapage *mp)
{
- if (mp) {
+ if (mp)
folio_attach_private(folio, mp);
- kmap(&folio->page);
- }
return 0;
}
static inline void remove_metapage(struct folio *folio, struct metapage *mp)
{
folio_detach_private(folio);
- kunmap(&folio->page);
}
#define inc_io(folio) do {} while(0)
@@ -405,7 +400,7 @@ static void last_write_complete(struct folio *folio, blk_status_t status)
}
/*
* I'd like to call drop_metapage here, but I don't think it's
- * safe unless I have the page locked
+ * safe unless I have the folio locked
*/
}
folio_end_writeback(folio);
@@ -652,7 +647,7 @@ static int metapage_migrate_folio(struct address_space *mapping,
if (!src->private)
return filemap_migrate_folio(mapping, dst, src, mode);
- /* Check whether page does not have extra refs before we do more work */
+ /* Check whether folio does not have extra refs before we do more work */
expected_count = folio_expected_ref_count(src) + 1;
if (folio_ref_count(src) != expected_count)
return -EAGAIN;
diff --git a/fs/jfs/jfs_metapage.h b/fs/jfs/jfs_metapage.h
index 2e5015c2705b..5c1fd9c1a84e 100644
--- a/fs/jfs/jfs_metapage.h
+++ b/fs/jfs/jfs_metapage.h
@@ -62,7 +62,7 @@ extern void grab_metapage(struct metapage *);
extern void force_metapage(struct metapage *);
/*
- * hold_metapage and put_metapage are used in conjunction. The page lock
+ * hold_metapage and put_metapage are used in conjunction. The folio lock
* is not dropped between the two, so no other threads can get or release
* the metapage
*/
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 8180d83d33fe..3cd173e03a38 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -517,6 +517,7 @@ static int jfs_fill_super(struct super_block *sb, struct fs_context *fc)
inode->i_size = bdev_nr_bytes(sb->s_bdev);
inode->i_mapping->a_ops = &jfs_metapage_aops;
inode_fake_hash(inode);
+ /* Metapages are accessed through folio_address(), so no highmem. */
mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
sbi->direct_inode = inode;
--
2.39.5