Re: [PATCH 7/9] squashfs: Remove use of FGP_NOFS
From: Jan Kara
Date: Mon Aug 31 2026 - 06:23:42 EST
On Sun 30-08-26 05:18:54, Matthew Wilcox (Oracle) wrote:
> Since we can allocate memory while holding a folio locked, we cannot
> allow page reclaim to call into the filesystem and attempt to compact
> the folio we're currently holding locked. Use memalloc_nofs_save()
> instead of FGP_NOFS here.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> ---
> fs/squashfs/file.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
> index d83594ce91d2..34c550a266bc 100644
> --- a/fs/squashfs/file.c
> +++ b/fs/squashfs/file.c
> @@ -398,6 +398,7 @@ void squashfs_copy_cache(struct folio *folio,
> struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
> int i, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
> int start_index = folio->index & ~mask, end_index = start_index | mask;
> + unsigned int nofs = memalloc_nofs_save();
Why do you need this? The only allocation I can see is the one using
FGP_NOWAIT below...
Honza
>
> /*
> * Loop copying datablock into pages. As the datablock likely covers
> @@ -415,7 +416,7 @@ void squashfs_copy_cache(struct folio *folio,
>
> push_folio = (i == folio->index) ? folio :
> __filemap_get_folio(mapping, i,
> - FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
> + FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
> mapping_gfp_mask(mapping));
>
> if (IS_ERR(push_folio))
> @@ -430,6 +431,8 @@ void squashfs_copy_cache(struct folio *folio,
> if (i != folio->index)
> folio_put(push_folio);
> }
> +
> + memalloc_nofs_restore(nofs);
> }
>
> /* Read datablock stored packed inside a fragment (tail-end packed block) */
> --
> 2.47.3
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR