mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ramfs: convert alloc_pages() to folio_alloc() in ramfs_nommu_expand_for_mapping()
@ 2026-02-24 20:31 AnishMulay
  2026-02-25 18:44 ` Viacheslav Dubeyko
  0 siblings, 1 reply; 3+ messages in thread
From: AnishMulay @ 2026-02-24 20:31 UTC (permalink / raw)
  To: Christian Brauner, Jan Kara
  Cc: Viacheslav Dubeyko, Damien Le Moal, Lorenzo Stoakes,
	linux-kernel, AnishMulay

Currently, ramfs_nommu_expand_for_mapping() utilizes the deprecated
alloc_pages() API. This patch converts the allocation step to use
the modern folio_alloc() API, removing a legacy caller and helping
pave the way for the eventual removal of alloc_pages().

Because nommu architectures require physically contiguous memory that
often needs to be trimmed to the exact requested size, the allocated
folio is immediately shattered using split_page().

Since split_page() destroys the compound folio metadata, using folio
iteration helpers (like folio_page) becomes unsafe. Therefore, this
patch deliberately drops back to a standard struct page array after
the split. This safely isolates the folio conversion to the allocation
phase while strictly preserving the existing trimming and page cache
insertion behavior.

Signed-off-by: AnishMulay <anishm7030@gmail.com>
---
 fs/ramfs/file-nommu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 77b8ca2757e0d..767de8fc56f0f 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -62,6 +62,7 @@ const struct inode_operations ramfs_file_inode_operations = {
 int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
 {
 	unsigned long npages, xpages, loop;
+	struct folio *folio;
 	struct page *pages;
 	unsigned order;
 	void *data;
@@ -81,10 +82,12 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
 
 	/* allocate enough contiguous pages to be able to satisfy the
 	 * request */
-	pages = alloc_pages(gfp, order);
-	if (!pages)
+	folio = folio_alloc(gfp, order);
+	if (!folio)
 		return -ENOMEM;
 
+	pages = &folio->page;
+
 	/* split the high-order page into an array of single pages */
 	xpages = 1UL << order;
 	npages = (newsize + PAGE_SIZE - 1) >> PAGE_SHIFT;
-- 
2.51.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-25 22:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-24 20:31 [PATCH] ramfs: convert alloc_pages() to folio_alloc() in ramfs_nommu_expand_for_mapping() AnishMulay
2026-02-25 18:44 ` Viacheslav Dubeyko
2026-02-25 22:18   ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®