Skip to content

Commit e1ead23

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: fold xfs_rtallocate_extent into xfs_bmap_rtalloc
There isn't really much left in xfs_rtallocate_extent now, fold it into the only caller. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
1 parent b6bb345 commit e1ead23

File tree

1 file changed

+18
-49
lines changed

1 file changed

+18
-49
lines changed

fs/xfs/xfs_rtalloc.c

Lines changed: 18 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,53 +1069,6 @@ xfs_growfs_rt(
10691069
return error;
10701070
}
10711071

1072-
/*
1073-
* Allocate an extent in the realtime subvolume, with the usual allocation
1074-
* parameters. The length units are all in realtime extents, as is the
1075-
* result block number.
1076-
*/
1077-
static int
1078-
xfs_rtallocate_extent(
1079-
struct xfs_trans *tp,
1080-
xfs_rtxnum_t start, /* starting rtext number to allocate */
1081-
xfs_rtxlen_t minlen, /* minimum length to allocate */
1082-
xfs_rtxlen_t maxlen, /* maximum length to allocate */
1083-
xfs_rtxlen_t *len, /* out: actual length allocated */
1084-
int wasdel, /* was a delayed allocation extent */
1085-
xfs_rtxlen_t prod, /* extent product factor */
1086-
xfs_rtxnum_t *rtx) /* out: start rtext allocated */
1087-
{
1088-
struct xfs_rtalloc_args args = {
1089-
.mp = tp->t_mountp,
1090-
.tp = tp,
1091-
};
1092-
int error; /* error value */
1093-
1094-
ASSERT(xfs_isilocked(args.mp->m_rbmip, XFS_ILOCK_EXCL));
1095-
ASSERT(minlen > 0 && minlen <= maxlen);
1096-
1097-
if (start == 0) {
1098-
error = xfs_rtallocate_extent_size(&args, minlen,
1099-
maxlen, len, prod, rtx);
1100-
} else {
1101-
error = xfs_rtallocate_extent_near(&args, start, minlen,
1102-
maxlen, len, prod, rtx);
1103-
}
1104-
xfs_rtbuf_cache_relse(&args);
1105-
if (error)
1106-
return error;
1107-
1108-
/*
1109-
* If it worked, update the superblock.
1110-
*/
1111-
ASSERT(*len >= minlen && *len <= maxlen);
1112-
if (wasdel)
1113-
xfs_trans_mod_sb(tp, XFS_TRANS_SB_RES_FREXTENTS, -(long)*len);
1114-
else
1115-
xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS, -(long)*len);
1116-
return 0;
1117-
}
1118-
11191072
/*
11201073
* Initialize realtime fields in the mount structure.
11211074
*/
@@ -1380,6 +1333,10 @@ xfs_bmap_rtalloc(
13801333
xfs_rtxlen_t raminlen;
13811334
bool rtlocked = false;
13821335
bool ignore_locality = false;
1336+
struct xfs_rtalloc_args args = {
1337+
.mp = mp,
1338+
.tp = ap->tp,
1339+
};
13831340
int error;
13841341

13851342
align = xfs_get_extsz_hint(ap->ip);
@@ -1412,6 +1369,8 @@ xfs_bmap_rtalloc(
14121369
*/
14131370
ralen = xfs_extlen_to_rtxlen(mp, min(ap->length, XFS_MAX_BMBT_EXTLEN));
14141371
raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen));
1372+
ASSERT(raminlen > 0);
1373+
ASSERT(raminlen <= ralen);
14151374

14161375
/*
14171376
* Lock out modifications to both the RT bitmap and summary inodes
@@ -1453,8 +1412,15 @@ xfs_bmap_rtalloc(
14531412
xfs_rtalloc_align_minmax(&raminlen, &ralen, &prod);
14541413
}
14551414

1456-
error = xfs_rtallocate_extent(ap->tp, start, raminlen, ralen, &ralen,
1457-
ap->wasdel, prod, &rtx);
1415+
if (start) {
1416+
error = xfs_rtallocate_extent_near(&args, start, raminlen,
1417+
ralen, &ralen, prod, &rtx);
1418+
} else {
1419+
error = xfs_rtallocate_extent_size(&args, raminlen,
1420+
ralen, &ralen, prod, &rtx);
1421+
}
1422+
xfs_rtbuf_cache_relse(&args);
1423+
14581424
if (error == -ENOSPC) {
14591425
if (align > mp->m_sb.sb_rextsize) {
14601426
/*
@@ -1486,6 +1452,9 @@ xfs_bmap_rtalloc(
14861452
if (error)
14871453
return error;
14881454

1455+
xfs_trans_mod_sb(ap->tp, ap->wasdel ?
1456+
XFS_TRANS_SB_RES_FREXTENTS : XFS_TRANS_SB_FREXTENTS,
1457+
-(long)ralen);
14891458
ap->blkno = xfs_rtx_to_rtb(mp, rtx);
14901459
ap->length = xfs_rtxlen_to_extlen(mp, ralen);
14911460
xfs_bmap_alloc_account(ap);

0 commit comments

Comments
 (0)