On Thu, Dec 12, 2024 at 11:29:16PM -0800, Christoph Hellwig wrote: > > Repair the realtime rmap btree while mounted. > > And actual description of how this repair works, and the changes to the > non-repair code required for it would be kinda useful. How about: "Repair the realtime rmap btree while mounted. Similar to the regular rmap btree repair code, we walk the data fork mappings of every realtime file in the filesystem to collect reverse-mapping records in an xfarray. Then we sort the xfarray, and use the btree bulk loader to create a new rtrmap btree ondisk. Finally, we swap the btree roots, and reap the old blocks in the usual way." > > xchk_setup_rt( > > struct xfs_scrub *sc) > > { > > - return xchk_trans_alloc(sc, 0); > > + uint resblks; > > + > > + resblks = xrep_calc_rtgroup_resblks(sc); > > + return xchk_trans_alloc(sc, resblks); > > This would be a tad cleaner without the local variable. > > > + > > + if (!(sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)) > > + return 0; > > + > > + rtg = xfs_rtgroup_get(mp, sm->sm_agno); > > + usedlen = rtg->rtg_extents * mp->m_sb.sb_rextsize; > > + xfs_rtgroup_put(rtg); > > Couldn't this use xfs_rtgroup_extents to avoid the rtg lookup? > If not it should probable use rtg_blocks(). > > > + struct xfs_scrub *sc, > > + int64_t new_blocks) > > +{ > > + int64_t delta; > > + > > + delta = new_blocks - sc->ip->i_nblocks; > > int64_6 delta = new_blocks - sc->ip->i_nblocks; > > ? Yes to all three. --D