Re: [PATCH v9 1/8] mm: Introduce memfd_restricted system call to create restricted user memory

From: Isaku Yamahata
Date: Wed Oct 26 2022 - 13:31:58 EST


On Tue, Oct 25, 2022 at 11:13:37PM +0800,
Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx> wrote:

> +int restrictedmem_get_page(struct file *file, pgoff_t offset,
> + struct page **pagep, int *order)
> +{
> + struct restrictedmem_data *data = file->f_mapping->private_data;
> + struct file *memfd = data->memfd;
> + struct page *page;
> + int ret;
> +
> + ret = shmem_getpage(file_inode(memfd), offset, &page, SGP_WRITE);

shmem_getpage() was removed.
https://lkml.kernel.org/r/20220902194653.1739778-34-willy@xxxxxxxxxxxxx

I needed the following fix to compile.

thanks,

diff --git a/mm/restrictedmem.c b/mm/restrictedmem.c
index e5bf8907e0f8..4694dd5609d6 100644
--- a/mm/restrictedmem.c
+++ b/mm/restrictedmem.c
@@ -231,13 +231,15 @@ int restrictedmem_get_page(struct file *file, pgoff_t offset,
{
struct restrictedmem_data *data = file->f_mapping->private_data;
struct file *memfd = data->memfd;
+ struct folio *folio = NULL;
struct page *page;
int ret;

- ret = shmem_getpage(file_inode(memfd), offset, &page, SGP_WRITE);
+ ret = shmem_get_folio(file_inode(memfd), offset, &folio, SGP_WRITE);
if (ret)
return ret;

+ page = folio_file_page(folio, offset);
*pagep = page;
if (order)
*order = thp_order(compound_head(page));
--
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>