[PATCH 0/4] xfs: fixes for 6.9-rcX

Dave Chinner
2024-04-02T22:11:33Z

Hi Chandan,

The following patches are fixes I consider necessary for the current
-rc cycle.

The first patch addresses a potential regression when allocating
temporary memory buffers for xattr block manipulations. It was found
during BS > PS development. While I don't think it can manifest on
existing kernels (because xattr block size is limited to page size),
it's better to fix it straight away so we don't leave a landmine
that will get stepped on sooner rather than later.

The second patch addresses a regression from the 6.6 kernels. It
removed ENOSPC detection from xfs_alloc_file_space() and replaced it
with an endless loop. This patch essentially reverts the commit
that caused the issue because it allows xfs_alloc_file_space() to
fall into an unkillable loop where it will endlessly retrying an
allocation that keeps failing. It will not making forwards progress,
and there is no way to break out of the loop. A reboot is needed to
fix the situation. This was found whilst triaging a bug that
corrupted free space accounting.

This was trying to address an issue with RT delalloc and the whacky
"delalloc does partial allocation but reports no allocation at all"
xfs_bmapi_write() semantics that was causing fallocate() to fail on
delalloc extents on RT devices. This was the wrong way to fix the
issue - we need to fix the whacky "partial progress was made but
tell the caller ENOSPC" behaviour so that callers can distinguish
between a hard ENOSPC error and a "keep allocating because we made
partial progress" condition.

The third addresses another problem found during triage of the same
free space accounting issue yesterday. A fchown() was run, leading
to a new dquot cluster being allocated. The transaction reservation
succeeded (because free space counter issues) and then the
allocation failed. This code does not handle allocation failure at
all - it has an ASSERT() that allocation succeeded - leading to it
trying to allocate a buffer over a disk address that was not
initialised and "access beyond EOFS" warnings from the buffer cache.
This patch handles the allocation failure in a manner that prevents
a shutdown from occurring and ensures -ENOSPC is returned to the
caller.

The last patch fixes the free space accounting issue that uncovered
the bugs fixes by the previous two patches. This can be triggered
from userspace, though it requires CAP_SYS_ADMIN and so requires
trust/privilege to be gained before it can be abused.

These have all passed through several fstests runs overnight without
introducing new regressions.

-Dave.