]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs_repair: stop preallocating blocks in mk_rbmino and mk_rsumino
authorChristoph Hellwig <hch@lst.de>
Tue, 30 Jul 2024 20:31:50 +0000 (13:31 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 1 Aug 2024 00:07:33 +0000 (17:07 -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 35d81b074e977067bc16b98f4a4a7fa7a7745b23..e0fd9b970130bffee4af048d16c3060133ea8b1d 100644 (file)
@@ -518,20 +518,11 @@ mk_rbmino(
 {
        struct xfs_trans        *tp;
        struct xfs_inode        *ip;
-       struct xfs_bmbt_irec    *ep;
-       int                     i;
-       int                     nmap;
        int                     error;
-       xfs_fileoff_t           bno;
-       struct xfs_bmbt_irec    map[XFS_BMAP_MAX_NMAP];
-       uint                    blocks;
 
-       /*
-        * 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);
 
        /* Reset the realtime bitmap inode. */
        error = ensure_rtino(tp, mp->m_sb.sb_rbmino, &ip);
@@ -545,42 +536,6 @@ mk_rbmino(
        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);
 }
 
@@ -647,21 +602,11 @@ mk_rsumino(
 {
        struct xfs_trans        *tp;
        struct xfs_inode        *ip;
-       struct xfs_bmbt_irec    *ep;
-       int                     i;
-       int                     nmap;
        int                     error;
-       int                     nsumblocks;
-       xfs_fileoff_t           bno;
-       struct xfs_bmbt_irec    map[XFS_BMAP_MAX_NMAP];
-       uint                    blocks;
 
-       /*
-        * 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);
 
        /* Reset the rt summary inode. */
        error = ensure_rtino(tp, mp->m_sb.sb_rsumino, &ip);
@@ -675,42 +620,6 @@ mk_rsumino(
        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)
-        */
-       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, ip, 0);
-       bno = 0;
-       while (bno < nsumblocks) {
-               nmap = XFS_BMAP_MAX_NMAP;
-               error = -libxfs_bmapi_write(tp, ip, bno,
-                         (xfs_extlen_t)(nsumblocks - bno),
-                         0, nsumblocks, 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);
 }