]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_repair: stop preallocating blocks in mk_rbmino and mk_rsumino
authorChristoph Hellwig <hch@lst.de>
Tue, 29 Oct 2024 00:03:34 +0000 (17:03 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 31 Oct 2024 22:45:05 +0000 (15:45 -0700)
Now that repair is using libxfs_rtfile_initialize_blocks to write to the
rtbitmap and rtsummary inodes, space allocation is already taken care of
that helper and there is no need to preallocate it.  Remove the code to
do so.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
repair/phase6.c

index 310a2b9c07bff0ba87cfcc2c411d815136dec714..630617ef8ab8fe589e7940fc29f20366bef87977 100644 (file)
@@ -475,24 +475,16 @@ reset_sbroot_ino(
 }
 
 static void
-mk_rbmino(xfs_mount_t *mp)
+mk_rbmino(
+       struct xfs_mount        *mp)
 {
-       xfs_trans_t     *tp;
-       xfs_inode_t     *ip;
-       xfs_bmbt_irec_t *ep;
-       int             i;
-       int             nmap;
-       int             error;
-       xfs_fileoff_t   bno;
-       xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
-       uint            blocks;
+       struct xfs_trans        *tp;
+       struct xfs_inode        *ip;
+       int                     error;
 
-       /*
-        * first set up inode
-        */
-       i = -libxfs_trans_alloc_rollable(mp, 10, &tp);
-       if (i)
-               res_failed(i);
+       error = -libxfs_trans_alloc_rollable(mp, 10, &tp);
+       if (error)
+               res_failed(error);
 
        error = -libxfs_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip);
        if (error) {
@@ -508,42 +500,6 @@ mk_rbmino(xfs_mount_t *mp)
        error = -libxfs_trans_commit(tp);
        if (error)
                do_error(_("%s: commit failed, error %d\n"), __func__, error);
-
-       /*
-        * then allocate blocks for file and fill with zeroes (stolen
-        * from mkfs)
-        */
-       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, ip, 0);
-       bno = 0;
-       while (bno < mp->m_sb.sb_rbmblocks) {
-               nmap = XFS_BMAP_MAX_NMAP;
-               error = -libxfs_bmapi_write(tp, ip, bno,
-                         (xfs_extlen_t)(mp->m_sb.sb_rbmblocks - bno),
-                         0, mp->m_sb.sb_rbmblocks, map, &nmap);
-               if (error) {
-                       do_error(
-                       _("couldn't allocate realtime bitmap, error = %d\n"),
-                               error);
-               }
-               for (i = 0, ep = map; i < nmap; i++, ep++) {
-                       libxfs_device_zero(mp->m_ddev_targp,
-                               XFS_FSB_TO_DADDR(mp, ep->br_startblock),
-                               XFS_FSB_TO_BB(mp, ep->br_blockcount));
-                       bno += ep->br_blockcount;
-               }
-       }
-       error = -libxfs_trans_commit(tp);
-       if (error) {
-               do_error(
-               _("allocation of the realtime bitmap failed, error = %d\n"),
-                       error);
-       }
        libxfs_irele(ip);
 }
 
@@ -606,22 +562,13 @@ _("couldn't re-initialize realtime summary inode, error %d\n"), error);
 static void
 mk_rsumino(xfs_mount_t *mp)
 {
-       xfs_trans_t     *tp;
-       xfs_inode_t     *ip;
-       xfs_bmbt_irec_t *ep;
-       int             i;
-       int             nmap;
-       int             error;
-       xfs_fileoff_t   bno;
-       xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP];
-       uint            blocks;
+       struct xfs_trans        *tp;
+       struct xfs_inode        *ip;
+       int                     error;
 
-       /*
-        * first set up inode
-        */
-       i = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 10, 0, 0, &tp);
-       if (i)
-               res_failed(i);
+       error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 10, 0, 0, &tp);
+       if (error)
+               res_failed(error);
 
        error = -libxfs_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip);
        if (error) {
@@ -637,41 +584,6 @@ mk_rsumino(xfs_mount_t *mp)
        error = -libxfs_trans_commit(tp);
        if (error)
                do_error(_("%s: commit failed, error %d\n"), __func__, error);
-
-       /*
-        * then allocate blocks for file and fill with zeroes (stolen
-        * from mkfs)
-        */
-       blocks = mp->m_rsumblocks + 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, ip, 0);
-       bno = 0;
-       while (bno < mp->m_rsumblocks) {
-               nmap = XFS_BMAP_MAX_NMAP;
-               error = -libxfs_bmapi_write(tp, ip, bno,
-                         (xfs_extlen_t)(mp->m_rsumblocks - bno),
-                         0, mp->m_rsumblocks, map, &nmap);
-               if (error) {
-                       do_error(
-               _("couldn't allocate realtime summary inode, error = %d\n"),
-                               error);
-               }
-               for (i = 0, ep = map; i < nmap; i++, ep++) {
-                       libxfs_device_zero(mp->m_ddev_targp,
-                                     XFS_FSB_TO_DADDR(mp, ep->br_startblock),
-                                     XFS_FSB_TO_BB(mp, ep->br_blockcount));
-                       bno += ep->br_blockcount;
-               }
-       }
-       error = -libxfs_trans_commit(tp);
-       if (error) {
-               do_error(
-       _("allocation of the realtime summary ino failed, error = %d\n"),
-                       error);
-       }
        libxfs_irele(ip);
 }