xfs: prevent extsize alignment from exceeding maximum extent size

When doing delayed allocation, if the allocation size is for a
maximally sized extent, extent size alignment can push it over this
limit. This results in an assert failure in xfs_bmbt_set_allf() as
the extent length is too large to find in the extent record.

Fix this by ensuring that we allow for space that extent size
alignment requires (up to 2 * (extsize -1) blocks as we have to
handle both head and tail alignment) when limiting the maximum size
of the extent.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>

authored by Dave Chinner and committed by Alex Elder 4ce15989 14b064ce

+10
+10
fs/xfs/xfs_bmap.c
··· 4487 /* Figure out the extent size, adjust alen */ 4488 extsz = xfs_get_extsz_hint(ip); 4489 if (extsz) { 4490 error = xfs_bmap_extsize_align(mp, 4491 &got, &prev, extsz, 4492 rt, eof,
··· 4487 /* Figure out the extent size, adjust alen */ 4488 extsz = xfs_get_extsz_hint(ip); 4489 if (extsz) { 4490 + /* 4491 + * make sure we don't exceed a single 4492 + * extent length when we align the 4493 + * extent by reducing length we are 4494 + * going to allocate by the maximum 4495 + * amount extent size aligment may 4496 + * require. 4497 + */ 4498 + alen = XFS_FILBLKS_MIN(len, 4499 + MAXEXTLEN - (2 * extsz - 1)); 4500 error = xfs_bmap_extsize_align(mp, 4501 &got, &prev, extsz, 4502 rt, eof,