/* Set up to repair the realtime bitmap for this group. */ int
xrep_setup_rtbitmap( struct xfs_scrub *sc, struct xchk_rtbitmap *rtb)
{ struct xfs_mount *mp = sc->mp; char *descr; unsignedlonglong blocks = mp->m_sb.sb_rbmblocks; int error;
error = xrep_tempfile_create(sc, S_IFREG); if (error) return error;
/* Create an xfile to hold our reconstructed bitmap. */
descr = xchk_xfile_rtgroup_descr(sc, "bitmap file");
error = xfile_create(descr, blocks * mp->m_sb.sb_blocksize, &sc->xfile);
kfree(descr); if (error) return error;
/* Perform a logical OR operation on an rtword in the incore bitmap. */ staticint
xrep_rtbitmap_or( struct xchk_rtbitmap *rtb,
xrep_wordoff_t wordoff,
xfs_rtword_t mask)
{
xfs_rtword_t word; int error;
error = xfbmp_load(rtb, wordoff, &word); if (error) return error;
/* Must not be shared or CoW staging. */ if (sr->refc_cur) {
error = xfs_refcount_has_records(sr->refc_cur,
XFS_REFC_DOMAIN_SHARED, rtb->next_rgbno,
rgbno - rtb->next_rgbno, &outcome); if (error) return error; if (outcome != XBTREE_RECPACKING_EMPTY) return -EFSCORRUPTED;
error = xfs_refcount_has_records(sr->refc_cur,
XFS_REFC_DOMAIN_COW, rtb->next_rgbno,
rgbno - rtb->next_rgbno, &outcome); if (error) return error; if (outcome != XBTREE_RECPACKING_EMPTY) return -EFSCORRUPTED;
}
/* Set bits as needed to round startrtx up to the nearest word. */
bit = startrtx & XREP_RTBMP_WORDMASK; if (bit) {
xfs_rtblock_t len = nextrtx - startrtx; unsignedint lastbit;
/* Set bits as needed to round nextrtx down to the nearest word. */
bit = nextrtx & XREP_RTBMP_WORDMASK; if (bit) {
mask = ((xfs_rtword_t)1 << bit) - 1;
error = xrep_rtbitmap_or(rtb, rtx_to_wordoff(mp, nextrtx),
mask); if (error || startrtx + bit == nextrtx) return error;
nextrtx -= bit;
}
/* Set all the words in between, up to a whole fs block at once. */
wordoff = rtx_to_wordoff(mp, startrtx);
nextwordoff = rtx_to_wordoff(mp, nextrtx);
bufwsize = mp->m_sb.sb_blocksize >> XFS_WORDLOG;
while (wordoff < nextwordoff) {
xrep_wordoff_t rem;
xrep_wordcnt_t wordcnt;
/* *Trytokeepusalignedtothertwordsbuffertoreducethe *numberofxfilewrites.
*/
rem = wordoff & (bufwsize - 1); if (rem)
wordcnt = min_t(xrep_wordcnt_t, wordcnt,
bufwsize - rem);
error = xfbmp_copyin(rtb, wordoff, rtb->words, wordcnt); if (error) return error;
wordoff += wordcnt;
}
return0;
}
/* Set free space in the rtbitmap based on rtrmapbt records. */ STATICint
xrep_rtbitmap_walk_rtrmap( struct xfs_btree_cur *cur, conststruct xfs_rmap_irec *rec, void *priv)
{ struct xchk_rtbitmap *rtb = priv; int error = 0;
if (xchk_should_terminate(rtb->sc, &error)) return error;
if (rtb->next_rgbno < rec->rm_startblock) {
error = xrep_rtbitmap_mark_free(rtb, rec->rm_startblock); if (error) return error;
}
/* We require the realtime rmapbt to rebuild anything. */ if (!xfs_has_rtrmapbt(sc->mp)) return -EOPNOTSUPP; /* We require atomic file exchange range to rebuild anything. */ if (!xfs_has_exchange_range(sc->mp)) return -EOPNOTSUPP;
/* Impossibly large rtbitmap means we can't touch the filesystem. */ if (rtb->rbmblocks > U32_MAX) return0;
/* *Ifthesizeofthertbitmapfileislargerthanwhatwereserved, *figureoutifweneedtoadjusttheblockreservationinthe *transaction.
*/
blocks = xfs_bmbt_calc_size(mp, rtb->rbmblocks); if (blocks > UINT_MAX) return -EOPNOTSUPP; if (blocks > rtb->resblks) {
error = xfs_trans_reserve_more(sc->tp, blocks, 0); if (error) return error;
rtb->resblks += blocks;
}
/* Fix inode core and forks. */
error = xrep_metadata_inode_forks(sc); if (error) return error;
xfs_trans_ijoin(sc->tp, sc->ip, 0);
/* Ensure no unwritten extents. */
error = xrep_rtbitmap_data_mappings(sc, rtb->rbmblocks); if (error) return error;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.