All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Yun Zhou <yun.zhou@windriver.com>
Cc: cem@kernel.org, djwong@kernel.org, hch@lst.de,
	willy@infradead.org, akpm@linux-foundation.org,
	hwenwur@gmail.com, linux-xfs@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] xfs: restore nofs context unconditionally in xfs_trans_roll
Date: Mon, 20 Jul 2026 10:39:40 +0200	[thread overview]
Message-ID: <20260720083940.GA21000@lst.de> (raw)
In-Reply-To: <20260719095732.1813590-3-yun.zhou@windriver.com>

On Sun, Jul 19, 2026 at 05:57:32PM +0800, Yun Zhou wrote:
> When __xfs_trans_commit() fails in xfs_trans_roll(), the NOFS context
> is cleared but only restored in the success path.  This leaves the
> error path without nofs protection, causing a circular lock dependency
> between xfs_nondir_ilock_class and fs_reclaim:
> 
>        CPU0                    CPU1
>        ----                    ----
>   lock(&xfs_nondir_ilock_class);
>                                lock(fs_reclaim);
>                                lock(&xfs_nondir_ilock_class);
>   lock(fs_reclaim);
> 
> Fix this by transferring the nofs context from the old transaction to
> the new one in xfs_trans_dup() via memalloc_flags_move(), so it remains
> active throughout the entire roll sequence regardless of commit success
> or failure.

Good find, but we keep adding more magic here that will just lead
to further bugs.  Your previous version was much better, and could
be improved by also removing the hiding under xfs_trans_set_context as
a follow on. 

Having a maze of single or two caller magic macros that modify global
(or rather global-ish as it's per thread) state makes hairy bits like
this really error prone as seen by the bugs now found.

      reply	other threads:[~2026-07-20  8:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-19  9:57 [PATCH v2 0/2] xfs: restore nofs context unconditionally in xfs_trans_roll Yun Zhou
2026-07-19  9:57 ` [PATCH v2 1/2] mm: introduce memalloc_flags_move() for transferring allocation scopes Yun Zhou
2026-07-19 20:57   ` Andrew Morton
2026-07-20  4:43     ` Zhou, Yun
2026-07-19  9:57 ` [PATCH v2 2/2] xfs: restore nofs context unconditionally in xfs_trans_roll Yun Zhou
2026-07-20  8:39   ` Christoph Hellwig [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=20260720083940.GA21000@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=hwenwur@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=willy@infradead.org \
    --cc=yun.zhou@windriver.com \
    /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.