Re: [PATCH 04/11] xfs: ensure EFD trans aborts on log recovery extent free failure

Christoph Hellwig
2015-08-09T07:53:13Z

> + /*
> + * Log the EFD before error handling to ensure the EFD aborts
> + * (and releases the EFI) on error.
> + */
> error = xfs_free_extent(tp, extp->ext_start, extp->ext_len);
> xfs_trans_log_efd_extent(tp, efdp, extp->ext_start,
> extp->ext_len);

Given that we now always need to log the extents in the EFD even on
error maybe it's time to move the call to xfs_free_extent into
xfs_trans_log_efd_extent and rename it to xfs_trans_free_extent?

Or even better convert xfs_bmap_finish to also walk the extents in the
EFI instead of xfs_bmap_free list and have a xfs_trans_free_extents helper
ala:

int
xfs_trans_free_extents(
struct xfs_trans *tp,
struct xfs_efi_log_item *efip)
{
struct xfs_efd_log_item *efdp;
int error = 0, i;

efdp = xfs_trans_get_efd(tp, efip, efip->efi_format.efi_nextents);
for (i = 0; i < efip->efi_format.efi_nextents; i++) {
struct xfs_extent *extp = &efip->efi_format.efi_extents[i];

error = xfs_free_extent(tp, extp->ext_start, extp->ext_len);
xfs_trans_log_efd_extent(tp, efdp, extp->ext_start,
extp->ext_len);

if (error)
break;
}

return error;
}