Linux EXT4 FS development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org,
	"Chuck Lever" <cel@kernel.org>,
	"Jeff Layton" <jlayton@kernel.org>,
	"Anna Schumaker" <anna@kernel.org>
Subject: Re: [PATCH 7/9] squashfs: Remove use of FGP_NOFS
Date: Sun, 30 Aug 2026 04:33:13 +0000	[thread overview]
Message-ID: <20260830043313.7F8271F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830041901.2668-8-willy@infradead.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Unprotected GFP_KERNEL allocations while holding folio locks can cause compaction deadlocks.
--

commit f9b201cd220cb4651ba3f51b039ab61732317528
Author: Matthew Wilcox (Oracle) <willy@infradead.org>

squashfs: Remove use of FGP_NOFS

This commit replaces the use of FGP_NOFS with memalloc_nofs_save() in
squashfs_copy_cache() to prevent page reclaim from calling into the
filesystem and attempting to compact the locked folio.

> diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
> index d83594ce91d23..34c550a266bcf 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();
>  
>  	/*
>  	 * Loop copying datablock into pages.  As the datablock likely covers

[Severity: High]
This is a pre-existing issue, but while this patch fixes the allocation
context in squashfs_copy_cache(), does the same compaction deadlock risk
apply to other GFP_KERNEL allocations in the read_folio path?

For example, in fs/squashfs/file.c:read_indexes():

    __le32 *blist = kmalloc(PAGE_SIZE, GFP_KERNEL);

And in fs/squashfs/file_direct.c:squashfs_readpage_block():

    page = kmalloc_array(pages, sizeof(void *), GFP_KERNEL);

Both of these allocations occur deep within the read_folio call chain while
the target folio is held locked by the VFS. If memory pressure triggers
direct reclaim and synchronous compaction, it could attempt to lock the
exact same folio that the thread is already holding, leading to a deadlock.

While VFS readahead callers establish a NOFS context via
memalloc_nofs_save(), read_folio callers like filemap_read_folio() do not.
Should these locations also be updated to prevent compaction deadlocks?

> @@ -430,6 +431,8 @@ void squashfs_copy_cache(struct folio *folio,
>  		if (i != folio->index)
>  			folio_put(push_folio);
>  	}
> +
> +	memalloc_nofs_restore(nofs);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260830041901.2668-1-willy@infradead.org?part=7

  reply	other threads:[~2026-08-30  4:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30  4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
2026-08-30  4:18 ` [PATCH 1/9] mm: Improve memalloc_nofs_save() documentation Matthew Wilcox (Oracle)
2026-08-30  4:21   ` sashiko-bot
2026-08-30  4:18 ` [PATCH 2/9] ext4: Remove uses of FGP_NOFS Matthew Wilcox (Oracle)
2026-08-30  4:27   ` sashiko-bot
2026-08-30  4:18 ` [PATCH 3/9] erofs: Remove redundant FGP_NOFS Matthew Wilcox (Oracle)
2026-08-30  4:24   ` sashiko-bot
2026-08-30  4:18 ` [PATCH 4/9] nfs: " Matthew Wilcox (Oracle)
2026-08-30  4:26   ` sashiko-bot
2026-08-30  4:18 ` [PATCH 5/9] ntfs: Remove FGP_NOFS from __ntfs_inode_resident_attr_pwrite() Matthew Wilcox (Oracle)
2026-08-30  4:39   ` sashiko-bot
2026-08-30  4:18 ` [PATCH 6/9] ntfs: Remove redundant FGP_NOFS from ntfs_wof_collect_dest() Matthew Wilcox (Oracle)
2026-08-30  4:25   ` sashiko-bot
2026-08-30  4:18 ` [PATCH 7/9] squashfs: Remove use of FGP_NOFS Matthew Wilcox (Oracle)
2026-08-30  4:33   ` sashiko-bot [this message]
2026-08-30  4:18 ` [PATCH 8/9] filemap: Remove redundant FGP_NOFS Matthew Wilcox (Oracle)
2026-08-30  4:25   ` sashiko-bot
2026-08-30  4:18 ` [PATCH 9/9] filemap: Remove FGP_NOFS Matthew Wilcox (Oracle)
2026-08-30  4:27   ` sashiko-bot
2026-08-30  4:32     ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260830043313.7F8271F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=anna@kernel.org \
    --cc=cel@kernel.org \
    --cc=jlayton@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox