From: Christoph Hellwig Date: Thu, 18 Jul 2024 13:22:29 +0000 (+0200) Subject: repair: move rt file block allocation to fill_rtino X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fxfs-rt-cleanups;p=users%2Fhch%2Fxfsprogs.git repair: move rt file block allocation to fill_rtino 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 --- diff --git a/repair/phase6.c b/repair/phase6.c index 04c4f18b3..fa28ddab1 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -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); } diff --git a/repair/rt.c b/repair/rt.c index b0f0c0df3..052cbcdcc 100644 --- a/repair/rt.c +++ b/repair/rt.c @@ -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;