All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiaming Zhang" <r772577952@gmail.com>,
	"Andreas Gruenbacher" <agruenba@redhat.com>,
	gfs2@lists.linux.dev
Cc: "Theodore Ts'o" <tytso@mit.edu>, "Al Viro" <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] gfs2: skip gfs2_dirty_inode in PF_MEMALLOC context
Date: Sat, 05 Dec 2026 17:21:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-251763@kernel.org> (raw)
In-Reply-To: <20261205170424.3686244-1-r772577952@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] gfs2: early PF_MEMALLOC return in gfs2_dirty_inode() loses
  lazytime timestamps
- [Medium] gfs2: wrong-layer PF_MEMALLOC skip in gfs2_dirty_inode()
  loses lazytime
--

commit c1c530e233dcbc62874e126ec2bff49723b1b936
Author: Jiaming Zhang <r772577952@gmail.com>

gfs2: skip gfs2_dirty_inode in PF_MEMALLOC context

This patch adds an early return to gfs2_dirty_inode() when PF_MEMALLOC
is set in current->flags, avoiding glock acquisition and metadata buffer
allocation during memory reclaim.

> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
> index 04bb4cf787d4d..3ec6599a36e68 100644
> --- a/fs/gfs2/super.c
> +++ b/fs/gfs2/super.c
> @@ -497,6 +497,8 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)
>  
>  	if (gfs2_withdrawn(sdp))
>  		return;
> +	if (current->flags & PF_MEMALLOC)
> +		return;

[Severity: High]
Can this early return permanently lose lazytime timestamp updates?

When dentry reclaim drops a linked inode under PF_MEMALLOC, iput() ->
sync_lazytime() -> __mark_inode_dirty() clears I_DIRTY_TIME before
calling gfs2_dirty_inode().  Returning here skips gfs2_dinode_out(),
and gfs2_write_inode() never serializes the dinode.

Because I_DIRTY_TIME is already clear, later fsync(), sync(), or
unmount never writes the updated mtime, ctime, or atime to disk, so
they are lost once the inode is evicted.

Unlike gfs2_drop_inode() and gfs2_glock_put_eventually(), this discards
metadata instead of deferring work, while __mark_inode_dirty() still
sets I_DIRTY_SYNC and triggers a wasted gfs2_write_inode() flush.

[Severity: Medium]
Should this PF_MEMALLOC reclaim hazard be fixed in VFS iput() rather
than inside gfs2_dirty_inode()?

iput() calls sync_lazytime() under PF_MEMALLOC and retries if
I_DIRTY_TIME stays set, so filesystems cannot leave it set in
->dirty_inode().  XFS (xfs_vn_sync_lazytime()), ext4
(ext4_dirty_inode()), and nilfs2 hit the same __GFP_NOFAIL hazard here.

Deferring sync_lazytime() in iput()/iput_final() under PF_MEMALLOC for
normal cached linked inodes (while still handling immediate-eviction
cases like drop or I_DONTCACHE) would leave the inode on
wb->b_dirty_time for non-PF_MEMALLOC writeback across all filesystems.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205170424.3686244-1-r772577952@gmail.com?part=1

      reply	other threads:[~2026-12-05 17:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 17:04 [PATCH] gfs2: skip gfs2_dirty_inode in PF_MEMALLOC context Jiaming Zhang
2026-12-05 17:21 ` sashiko-bot [this message]

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=sashiko-outbox-251763@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=r772577952@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.