return error;
}
-static int
-create_sb_metadata_file(
- struct xfs_trans **tpp,
- mode_t mode,
- struct xfs_inode **ipp)
-{
- struct xfs_icreate_args args = {
- .mode = mode,
- .flags = XFS_ICREATE_UNLINKABLE,
- };
- struct xfs_mount *mp = (*tpp)->t_mountp;
- xfs_ino_t ino;
- int error;
-
- /*
- * Call the space management code to pick the on-disk inode to be
- * allocated.
- */
- error = -libxfs_dialloc(tpp, &args, &ino);
- if (error)
- return error;
-
- error = -libxfs_icreate(*tpp, ino, &args, ipp);
- if (error)
- return error;
-
- if (xfs_has_metadir(mp))
- libxfs_imeta_set_iflag(*tpp, *ipp);
-
- return 0;
-}
-
/* Create the realtime bitmap inode. */
static void
rtbitmap_create(
- struct xfs_mount *mp)
+ struct xfs_inode *ip)
{
- struct xfs_trans *tp;
- struct xfs_inode *rbmip;
- int error;
-
- /* Create the realtime bitmap inode. */
- error = -libxfs_trans_alloc_rollable(mp, MKFS_BLOCKRES_INODE, &tp);
- if (error)
- res_failed(error);
-
- error = create_sb_metadata_file(&tp, S_IFREG, &rbmip);
- if (error)
- fail(_("Realtime bitmap inode allocation failed"), error);
+ struct xfs_mount *mp = ip->i_mount;
- mp->m_sb.sb_rbmino = rbmip->i_ino;
- rbmip->i_disk_size = mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize;
- rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
+ ip->i_disk_size = mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize;
+ ip->i_diflags |= XFS_DIFLAG_NEWRTBM;
if (!xfs_has_rtgroups(mp))
- inode_set_atime(VFS_I(rbmip), 0, 0);
- libxfs_trans_log_inode(tp, rbmip, XFS_ILOG_CORE);
- libxfs_log_sb(tp);
+ inode_set_atime(VFS_I(ip), 0, 0);
- error = -libxfs_trans_commit(tp);
- if (error)
- fail(_("Completion of the realtime bitmap inode failed"),
- error);
- mp->m_rbmip = rbmip;
+ mp->m_sb.sb_rbmino = ip->i_ino;
+ mp->m_rbmip = ip;
}
/* Create the realtime summary inode. */
static void
rtsummary_create(
- struct xfs_mount *mp)
+ struct xfs_inode *ip)
{
- struct xfs_trans *tp;
- struct xfs_inode *rsumip;
+ struct xfs_mount *mp = ip->i_mount;
+
+ ip->i_disk_size = mp->m_rsumsize;
+
+ mp->m_sb.sb_rsumino = ip->i_ino;
+ mp->m_rsumip = ip;
+}
+
+static void
+create_sb_metadata_file(
+ struct xfs_mount *mp,
+ void (*create)(struct xfs_inode *ip))
+{
+ struct xfs_icreate_args args = {
+ .mode = S_IFREG,
+ .flags = XFS_ICREATE_UNLINKABLE,
+ };
+ xfs_ino_t ino;
int error;
+ struct xfs_trans *tp;
+ struct xfs_inode *ip;
error = -libxfs_trans_alloc_rollable(mp, MKFS_BLOCKRES_INODE, &tp);
if (error)
res_failed(error);
- /* Create the realtime summary inode. */
- error = create_sb_metadata_file(&tp, S_IFREG, &rsumip);
+ error = -libxfs_dialloc(&tp, &args, &ino);
if (error)
- fail(_("Realtime summary inode allocation failed"), error);
+ goto fail;
- mp->m_sb.sb_rsumino = rsumip->i_ino;
- rsumip->i_disk_size = mp->m_rsumsize;
- libxfs_trans_log_inode(tp, rsumip, XFS_ILOG_CORE);
+ error = -libxfs_icreate(tp, ino, &args, &ip);
+ if (error)
+ goto fail;
+
+ if (xfs_has_metadir(mp))
+ libxfs_imeta_set_iflag(tp, ip);
+
+ create(ip);
+
+ libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
libxfs_log_sb(tp);
error = -libxfs_trans_commit(tp);
if (error)
- fail(_("Completion of the realtime summary inode failed"),
- error);
- mp->m_rsumip = rsumip;
+ goto fail;
+ return;
+fail:
+ if (error)
+ fail(_("Realtime inode allocation failed"), error);
}
/* Zero the realtime bitmap/summary file. */
xfs_rgnumber_t rgno;
int i;
- rtbitmap_create(mp);
- rtsummary_create(mp);
+ create_sb_metadata_file(mp, rtbitmap_create);
+ create_sb_metadata_file(mp, rtsummary_create);
if (xfs_has_rtgroups(mp)) {
int error;