[lvc-project] [PATCH v4 1/2] xfs: skip inode inactivation on a shut down mount
Christoph Hellwig
hch at infradead.org
Wed Jun 10 15:12:57 MSK 2026
On Sun, Jun 07, 2026 at 09:30:25PM +0300, Mikhail Lobanov wrote:
> v4: brace both branches of the if/else. Without CONFIG_XFS_QUOTA
> xfs_qm_dqdetach() expands to nothing, leaving the else with an empty
> body, which trips -Wempty-body on a W=1 build (i386-allnoconfig,
> reported by the kernel test robot).
We should really turn these stubs from macros into inlines, but..
> @@ -1940,10 +1940,26 @@ static int
> xfs_inodegc_inactivate(
> struct xfs_inode *ip)
> {
> - int error;
> + int error = 0;
>
> trace_xfs_inode_inactivating(ip);
> - error = xfs_inactive(ip);
> +
> + /*
> + * If the filesystem has been shut down - for example a mount that
> + * failed after background inactivation was enabled - do not
> + * inactivate the inode. Inactivation modifies persistent metadata,
> + * its transactions cannot complete on a shut down mount, and the
> + * subsystems it relies on (e.g. quota, mp->m_quotainfo) may not be
> + * set up. Drop any attached dquots and make the inode reclaimable,
> + * the same way xfs_inode_mark_reclaimable() does when it sends an
> + * inode straight to reclaim.
> + */
> + if (!xfs_is_shutdown(ip->i_mount)) {
> + error = xfs_inactive(ip);
> + } else {
> + /* Going straight to reclaim, so drop the dquots. */
> + xfs_qm_dqdetach(ip);
> + }
It might be easier to just move the shutdown check and xfs_qm_dqdetach
cal into the beginning of xfs_inactive as:
if (xfs_is_shutdown(mp)
goto out;
after initializing mp at declaration time at the top of the function.
But this is also still missing my other comment: xfs_qm_dqdetach
will still cause a NULL pointer dereference if quotas haven't been
set up yet or torn down already. So we'll probably want another
patch to exist early in xfs_qm_dqdetach for that case.
More information about the lvc-project
mailing list