Re: [PATCH] xfs: drain inodegc before quota teardown on mount failure
From: Cen Zhang
Date: Thu May 28 2026 - 09:33:51 EST
Hi Christoph,
> Can you come up with an xfstest for this? I guess you'd need a new
> error injection point, but that should not be horrible.
I tried to turn this into an xfstest.
In my local attempts, a mount-failure errortag after
xfs_qm_mount_quotas() was not enough by itself, because ordinary test
setup did not reliably leave an inodegc item that would enter the
dqattach/eofblocks path during the mount-failure unwind.
The draft I have locally uses two DEBUG-only errortags:
- mount_fail_after_qm_mount_quotas
This injects -EIO immediately after xfs_qm_mount_quotas().
- force_inodegc_eofblocks
This makes a regular inode released after quotacheck scanning go
through inodegc/eofblocks cleanup, and delays that inodegc work so
the mount-failure unwind can reach quota teardown first.
The xfstest creates one regular scratch file without quotas enabled,
unmounts, and then remounts with:
-o uquota,errortag=force_inodegc_eofblocks,errortag=mount_fail_after_qm_mount_quotas
On a kernel with the errortags but without the inodegc drain fix, this
reproduces the same teardown ordering problem:
KASAN: null-ptr-deref
Workqueue: xfs-inodegc/vdc xfs_inodegc_worker
xfs_qm_dqget_cache_lookup()
xfs_qm_dqget_inode()
xfs_qm_dqattach_locked()
xfs_qm_dqattach()
xfs_free_eofblocks()
xfs_inactive()
xfs_inodegc_worker()
With the drain fix applied, the same xfstest passes and the filesystem
can be mounted again cleanly afterwards.
I do not have much experience with XFS-specific fstests, so I wanted to
check whether this is the right shape before posting it formally. If
this approach looks acceptable, I can send a small kernel series adding
the DEBUG errortags and the mount-failure fix, followed by a separate
xfstests patch.
Thanks,
Zhang Cen