align = xfs_get_extsz_hint(ap->ip);
retry:
- prod = xfs_extlen_to_rtxlen(mp, align);
error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
align, 1, ap->eof, 0,
ap->conv, &ap->offset, &ap->length);
if (ap->offset != orig_offset)
minlen += orig_offset - ap->offset;
- /*
- * If the offset & length are not perfectly aligned
- * then kill prod, it will just get us in trouble.
- */
- div_u64_rem(ap->offset, align, &mod);
- if (mod || ap->length % align)
- prod = 1;
/*
* Set ralen to be the actual requested length in rtextents.
*
* adjust the starting point to match it.
*/
ralen = xfs_extlen_to_rtxlen(mp, min(ap->length, XFS_MAX_BMBT_EXTLEN));
+ raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen));
/*
* Lock out modifications to both the RT bitmap and summary inodes
start = 0;
}
- raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen));
+ /*
+ * Only bother calculating a real prod factor if offset & length are
+ * perfectly aligned, otherwise it will just get us in trouble.
+ */
+ div_u64_rem(ap->offset, align, &mod);
+ if (mod || ap->length % align)
+ prod = 1;
+ else
+ prod = xfs_extlen_to_rtxlen(mp, align);
+
error = xfs_rtallocate_extent(ap->tp, start, raminlen, ralen, &ralen,
ap->wasdel, prod, &rtx);
if (error == -ENOSPC) {