@@ -259,9 +259,9 @@ xfs_rtallocate_extent_block(
/*
* i for maxlen is all free, allocate and return that.
*/
- bestlen = maxlen;
- besti = i;
- goto allocate;
+ *len = maxlen;
+ *rtx = i;
+ return 0;
}
/*
@@ -312,12 +312,8 @@ xfs_rtallocate_extent_block(
}
/*
- * Allocate besti for bestlen & return that.
+ * Pick besti for bestlen & return that.
*/
-allocate:
- error = xfs_rtallocate_range(args, besti, bestlen);
- if (error)
- return error;
*len = bestlen;
*rtx = besti;
return 0;
@@ -371,12 +367,6 @@ xfs_rtallocate_extent_exact(
}
}
- /*
- * Allocate what we can and return it.
- */
- error = xfs_rtallocate_range(args, start, maxlen);
- if (error)
- return error;
*len = maxlen;
*rtx = start;
return 0;
@@ -429,7 +419,6 @@ xfs_rtallocate_extent_near(
if (error != -ENOSPC)
return error;
-
bbno = xfs_rtx_to_rbmblock(mp, start);
i = 0;
j = -1;
@@ -552,11 +541,11 @@ xfs_rtalloc_sumlevel(
xfs_rtxnum_t *rtx) /* out: start rtext allocated */
{
xfs_fileoff_t i; /* bitmap block number */
+ int error;
for (i = 0; i < args->mp->m_sb.sb_rbmblocks; i++) {
xfs_suminfo_t sum; /* summary information for extents */
xfs_rtxnum_t n; /* next rtext to be tried */
- int error;
error = xfs_rtget_summary(args, l, i, &sum);
if (error)
@@ -1467,9 +1456,12 @@ xfs_bmap_rtalloc(
error = xfs_rtallocate_extent_size(&args, raminlen,
ralen, &ralen, prod, &rtx);
}
- xfs_rtbuf_cache_relse(&args);
- if (error == -ENOSPC) {
+ if (error) {
+ xfs_rtbuf_cache_relse(&args);
+ if (error != -ENOSPC)
+ return error;
+
if (align > mp->m_sb.sb_rextsize) {
/*
* We previously enlarged the request length to try to
@@ -1497,14 +1489,20 @@ xfs_bmap_rtalloc(
ap->length = 0;
return 0;
}
+
+ error = xfs_rtallocate_range(&args, rtx, ralen);
if (error)
- return error;
+ goto out_release;
xfs_trans_mod_sb(ap->tp, ap->wasdel ?
XFS_TRANS_SB_RES_FREXTENTS : XFS_TRANS_SB_FREXTENTS,
-(long)ralen);
+
ap->blkno = xfs_rtx_to_rtb(mp, rtx);
ap->length = xfs_rtxlen_to_extlen(mp, ralen);
xfs_bmap_alloc_account(ap);
- return 0;
+
+out_release:
+ xfs_rtbuf_cache_relse(&args);
+ return error;
}