From: Darrick J. Wong Date: Mon, 15 Apr 2024 23:07:29 +0000 (-0700) Subject: mkfs: convert utility to use new rt extent helpers and types X-Git-Tag: v6.8.0~111 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d251bd115fd42645088486de2223ffa4f0a1a43f;p=thirdparty%2Fxfsprogs-dev.git mkfs: convert utility to use new rt extent helpers and types Convert the repair program to use the new realtime extent types and helper functions instead of open-coding them. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Bill O'Donnell --- diff --git a/mkfs/proto.c b/mkfs/proto.c index e9c633ed..f8e00c4b 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -20,6 +20,7 @@ static int newfile(xfs_trans_t *tp, xfs_inode_t *ip, int symlink, int logit, char *buf, int len); static char *newregfile(char **pp, int *len); static void rtinit(xfs_mount_t *mp); +static void rtfreesp_init(struct xfs_mount *mp); static long filesize(int fd); static int slashes_are_spaces; @@ -652,7 +653,6 @@ rtinit( xfs_mount_t *mp) { xfs_fileoff_t bno; - xfs_fileoff_t ebno; xfs_bmbt_irec_t *ep; int error; int i; @@ -770,19 +770,34 @@ rtinit( fail(_("Block allocation of the realtime summary inode failed"), error); - /* - * Free the whole area using transactions. - * Do one transaction per bitmap block. - */ - for (bno = 0; bno < mp->m_sb.sb_rextents; bno = ebno) { - i = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, + rtfreesp_init(mp); +} + +/* + * Free the whole realtime area using transactions. + * Do one transaction per bitmap block. + */ +static void +rtfreesp_init( + struct xfs_mount *mp) +{ + struct xfs_trans *tp; + xfs_rtxnum_t rtx; + xfs_rtxnum_t ertx; + int error; + + for (rtx = 0; rtx < mp->m_sb.sb_rextents; rtx = ertx) { + error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); - if (i) - res_failed(i); - libxfs_trans_ijoin(tp, rbmip, 0); - ebno = XFS_RTMIN(mp->m_sb.sb_rextents, - bno + NBBY * mp->m_sb.sb_blocksize); - error = -libxfs_rtfree_extent(tp, bno, (xfs_extlen_t)(ebno-bno)); + if (error) + res_failed(error); + + libxfs_trans_ijoin(tp, mp->m_rbmip, 0); + ertx = XFS_RTMIN(mp->m_sb.sb_rextents, + rtx + NBBY * mp->m_sb.sb_blocksize); + + error = -libxfs_rtfree_extent(tp, rtx, + (xfs_rtxlen_t)(ertx - rtx)); if (error) { fail(_("Error initializing the realtime space"), error);