]> git.ipfire.org Git - thirdparty/linux.git/commit
xfs: nlink scrub must take IOLOCK before determining ILOCK state
authorDarrick J. Wong <djwong@kernel.org>
Mon, 27 Jul 2026 05:24:02 +0000 (22:24 -0700)
committerCarlos Maiolino <cem@kernel.org>
Mon, 3 Aug 2026 08:17:34 +0000 (10:17 +0200)
commitb1a296fc2241f724ef8f14da6a4efa800d444dac
treef7e13c35624b1afcd77c344b923fa8fcc654a635
parent5ee37132ea81abd36213b31a72140660c2aac54b
xfs: nlink scrub must take IOLOCK before determining ILOCK state

In xchk_nlinks_ilock_dir, take the IOLOCK before accessing internal
inode state to figure out if we need to take ILOCK shared or exclusive.
That way we can't race with directory updates.  LOLLM pointed out that
the code was initially correct w.r.t. the IOLOCK, but then I broke it.

Cc: stable@vger.kernel.org # v6.18
Fixes: f477af0cfa0487 ("xfs: fix locking in xchk_nlinks_collect_dir")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/scrub/nlinks.c