]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
repair: move rt file block allocation to fill_rtino xfs-rt-cleanups
authorChristoph Hellwig <hch@lst.de>
Thu, 18 Jul 2024 13:22:29 +0000 (15:22 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 18 Jul 2024 13:22:49 +0000 (15:22 +0200)
Move the block allocation to fill_rtino to be next to writing to the
files.  That also makes it clear that there is no need to zero the
blocks as we are writing data to all of them.  If repair is interrupted
before finishing to write the blocks it will detect a mismatch on the
next run and regenerate the bitmaps anyway, and a random pattern in
the remaining blocks isn't any worse than zeros.

What really should happen is to write the data to a new file first and
link it in when done, but that's a totally separate project.

Signed-off-by: Christoph Hellwig <hch@lst.de>
repair/phase6.c
repair/rt.c

index 04c4f18b3e3039f03462aedfd5fcc8c58c426e0d..fa28ddab194ffbc90363b5dbb9b883e021ad80df 100644 (file)
@@ -543,21 +543,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)
-        */
-       if (mp->m_sb.sb_rbmblocks) {
-               error = -libxfs_alloc_file_space(ip, 0,
-                               mp->m_sb.sb_rbmblocks << mp->m_sb.sb_blocklog,
-                               XFS_BMAPI_ZERO);
-               if (error) {
-                       do_error(
-       _("allocation of the realtime bitmap failed, error = %d\n"),
-                               error);
-               }
-       }
        libxfs_irele(ip);
 }
 
@@ -589,20 +574,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)
-        */
-       if (mp->m_rsumsize) {
-               error = -libxfs_alloc_file_space(ip, 0, mp->m_rsumsize,
-                               XFS_BMAPI_ZERO);
-               if (error) {
-                       do_error(
-       _("allocation of the realtime summary ino failed, error = %d\n"),
-                               error);
-               }
-       }
        libxfs_irele(ip);
 }
 
index b0f0c0df361c4af4ba504f81e1227381ef5d4756..052cbcdcc1899a80348b7d6189dfa5c0cb501e10 100644 (file)
@@ -326,18 +326,28 @@ fill_rtino(
        if (!end_bno)
                return;
 
-       error = -libxfs_trans_alloc_rollable(mp, 10, &tp);
+       error = -libxfs_trans_alloc_empty(mp, &tp);
        if (error)
-               do_error(_("xfs_trans_reserve returned %d\n"), error);
-
+               do_error(_("xfs_trans_alloc_empty returned %d\n"), error);
        error = -libxfs_iget(mp, tp, ino, 0, &ip);
+       libxfs_trans_cancel(tp);
        if (error) {
                do_error(
                _("couldn't iget realtime %s inode -- error - %d\n"),
                        name, error);
        }
 
+       error = -libxfs_alloc_file_space(ip, 0, XFS_FSB_TO_B(mp, end_bno), 0);
+       if (error)
+               do_error(
+       _("allocation of the realtime %s inode failed, error - %d\n"),
+                       name, error);
+
+       error = -libxfs_trans_alloc_rollable(mp, 10, &tp);
+       if (error)
+               do_error(_("xfs_trans_reserve returned %d\n"), error);
        libxfs_trans_ijoin(tp, ip, 0);
+
        while (bno < end_bno)  {
                struct xfs_buf          *bp;
                struct xfs_bmbt_irec    map;