@@ -673,28 +673,16 @@ parse_proto(
parseproto(mp, NULL, fsx, pp, NULL);
}
-/*
- * Allocate the realtime bitmap and summary inodes, and fill in data if any.
- */
+/* Create the realtime bitmap inode. */
static void
-rtinit(
+rtbitmap_create(
struct xfs_mount *mp)
{
struct xfs_imeta_update upd;
- struct xfs_bmbt_irec map[XFS_BMAP_MAX_NMAP];
+ struct xfs_trans *tp;
struct xfs_inode *rbmip;
- struct xfs_inode *rsumip;
- struct xfs_trans *tp;
- struct xfs_bmbt_irec *ep;
- xfs_fileoff_t bno;
- xfs_fileoff_t ebno;
- xfs_extlen_t nsumblocks;
- uint blocks;
- int i;
- int nmap;
int error;
- /* Create the realtime bitmap inode. */
error = -libxfs_imeta_start_update(mp, &XFS_IMETA_RTBITMAP, &upd);
if (error)
res_failed(error);
@@ -719,8 +707,18 @@ rtinit(
error);
mp->m_rbmip = rbmip;
libxfs_imeta_end_update(mp, &upd, 0);
+}
+
+/* Create the realtime summary inode. */
+static void
+rtsummary_create(
+ struct xfs_mount *mp)
+{
+ struct xfs_imeta_update upd;
+ struct xfs_trans *tp;
+ struct xfs_inode *rsumip;
+ int error;
- /* Create the realtime summary inode. */
error = -libxfs_imeta_start_update(mp, &XFS_IMETA_RTSUMMARY, &upd);
if (error)
res_failed(error);
@@ -743,19 +741,33 @@ rtinit(
error);
mp->m_rsumip = rsumip;
libxfs_imeta_end_update(mp, &upd, 0);
+}
+
+/* Zero the realtime bitmap. */
+static void
+rtbitmap_init(
+ struct xfs_mount *mp)
+{
+ struct xfs_bmbt_irec map[XFS_BMAP_MAX_NMAP];
+ struct xfs_trans *tp;
+ struct xfs_bmbt_irec *ep;
+ xfs_fileoff_t bno;
+ uint blocks;
+ int i;
+ int nmap;
+ int error;
- /* Zero the realtime bitmap. */
blocks = mp->m_sb.sb_rbmblocks +
XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1;
error = -libxfs_trans_alloc_rollable(mp, blocks, &tp);
if (error)
res_failed(error);
- libxfs_trans_ijoin(tp, rbmip, 0);
+ libxfs_trans_ijoin(tp, mp->m_rbmip, 0);
bno = 0;
while (bno < mp->m_sb.sb_rbmblocks) {
nmap = XFS_BMAP_MAX_NMAP;
- error = -libxfs_bmapi_write(tp, rbmip, bno,
+ error = -libxfs_bmapi_write(tp, mp->m_rbmip, bno,
(xfs_extlen_t)(mp->m_sb.sb_rbmblocks - bno),
0, mp->m_sb.sb_rbmblocks, map, &nmap);
if (error)
@@ -774,19 +786,34 @@ rtinit(
if (error)
fail(_("Block allocation of the realtime bitmap inode failed"),
error);
+}
+
+/* Zero the realtime summary file. */
+static void
+rtsummary_init(
+ struct xfs_mount *mp)
+{
+ struct xfs_bmbt_irec map[XFS_BMAP_MAX_NMAP];
+ struct xfs_trans *tp;
+ struct xfs_bmbt_irec *ep;
+ xfs_fileoff_t bno;
+ xfs_extlen_t nsumblocks;
+ uint blocks;
+ int i;
+ int nmap;
+ int error;
- /* Zero the summary file. */
nsumblocks = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
blocks = nsumblocks + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1;
error = -libxfs_trans_alloc_rollable(mp, blocks, &tp);
if (error)
res_failed(error);
- libxfs_trans_ijoin(tp, rsumip, 0);
+ libxfs_trans_ijoin(tp, mp->m_rsumip, 0);
bno = 0;
while (bno < nsumblocks) {
nmap = XFS_BMAP_MAX_NMAP;
- error = -libxfs_bmapi_write(tp, rsumip, bno,
+ error = -libxfs_bmapi_write(tp, mp->m_rsumip, bno,
(xfs_extlen_t)(nsumblocks - bno),
0, nsumblocks, map, &nmap);
if (error)
@@ -805,18 +832,28 @@ rtinit(
if (error)
fail(_("Block allocation of the realtime summary inode failed"),
error);
+}
+
+/*
+ * 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_fileoff_t bno;
+ xfs_fileoff_t ebno;
+ int error;
- /*
- * Free the whole area using transactions.
- * Do one transaction per bitmap block.
- */
for (bno = 0; bno < mp->m_sb.sb_rextents; bno = ebno) {
error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
0, 0, 0, &tp);
if (error)
res_failed(error);
- libxfs_trans_ijoin(tp, rbmip, 0);
+ libxfs_trans_ijoin(tp, mp->m_rbmip, 0);
ebno = XFS_RTMIN(mp->m_sb.sb_rextents,
bno + NBBY * mp->m_sb.sb_blocksize);
@@ -832,6 +869,21 @@ rtinit(
}
}
+/*
+ * Allocate the realtime bitmap and summary inodes, and fill in data if any.
+ */
+static void
+rtinit(
+ struct xfs_mount *mp)
+{
+ rtbitmap_create(mp);
+ rtsummary_create(mp);
+
+ rtbitmap_init(mp);
+ rtsummary_init(mp);
+ rtfreesp_init(mp);
+}
+
static long
filesize(
int fd)