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

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Deadlock due to missing NOFS protection when allocating page cache memory under mrec_lock
--

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

ntfs: Remove FGP_NOFS from __ntfs_inode_resident_attr_pwrite()

This commit removes the FGP_NOFS flag from the folio allocation in
__ntfs_inode_resident_attr_pwrite(). The commit message notes that if the
protection is needed, it should be done using memalloc_nofs_save() at a
higher level.

> diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
> index 32edb4045178a..36a0d6b26c02e 100644
> --- a/fs/ntfs/inode.c
> +++ b/fs/ntfs/inode.c
> @@ -3676,7 +3676,7 @@ static s64 __ntfs_inode_resident_attr_pwrite(struct inode *vi,
>  	mark_mft_record_dirty(ctx->ntfs_ino);
>  
>  	/* Keep the first page clean and uptodate */
> -	folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
> +	folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,

[Severity: High]
Does removing FGP_NOFS here without adding the higher-level
memalloc_nofs_save() protection introduce a deadlock with flusher threads?

If a user writes a resident extended attribute via ntfs_setxattr(), the
call path acquires mrec_lock before reaching this allocation:

fs/ntfs/ea.c:ntfs_setxattr() {
    ...
    mutex_lock(&ni->mrec_lock);
    err = ntfs_set_ea(inode, name, strlen(name), value, size, flags, NULL);
    mutex_unlock(&ni->mrec_lock);
    ...
}

Without FGP_NOFS, the folio allocation can now occur with __GFP_FS enabled.
If the system is under memory pressure and blocks to wait for flusher
threads, those threads may attempt to write back pages for this NTFS
filesystem. The writeback path also unconditionally acquires the same
mrec_lock:

fs/ntfs/iomap.c:ntfs_write_iomap_begin_non_resident() {
    ...
    mutex_lock(&NTFS_I(inode)->mrec_lock);
    ...
}

Can this cause a cyclic deadlock on mrec_lock if the flusher thread blocks
waiting on the locked inode?

>  				   mapping_gfp_mask(mapping));
>  	if (IS_ERR(folio)) {
>  		err = PTR_ERR(folio);

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

  reply	other threads:[~2026-08-30  4:39 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 [this message]
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
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=20260830043941.13C3A1F000E9@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