Re: [PATCH 3/4] xfs: handle allocation failure in xfs_dquot_disk_alloc()

Christoph Hellwig
2024-04-03T14:06:48Z

On Wed, Apr 03, 2024 at 08:38:18AM +1100, Dave Chinner wrote:
> @@ -356,6 +356,23 @@ xfs_dquot_disk_alloc(
> if (error)
> goto err_cancel;
>
> + if (nmaps == 0) {
> + /*
> + * Unexpected ENOSPC - the transaction reservation should have
> + * guaranteed that this allocation will succeed. We don't know
> + * why this happened, so just back out gracefully.

So looking at this code, xfs_dquot_disk_alloc allocates it's own
transaction, and does so without a space reservation. In other words:
an ENOSPC is entirely expected here in the current form. The code, just
like many other callers of xfs_bmapi_write, just fails to handle
the weird 0 return value and zero nmaps convention properly.