/* Uhoh, more than one parent for a dir? */ if (fpi->found_parent != NULLFSINO &&
!(fpi->parent_tentative && fpi->found_parent == fpi->dp->i_ino)) {
trace_xrep_findparent_dirent(fpi->sc->ip, 0); return -EFSCORRUPTED;
}
/* We found a potential parent; remember this. */
trace_xrep_findparent_dirent(fpi->sc->ip, fpi->dp->i_ino);
fpi->found_parent = fpi->dp->i_ino;
fpi->parent_tentative = false;
if (fpi->parent_scan)
xrep_findparent_scan_found(fpi->parent_scan, fpi->dp->i_ino);
while ((ret = xchk_iscan_iter(&pscan->iscan, &fpi.dp)) == 1) { if (S_ISDIR(VFS_I(fpi.dp)->i_mode))
ret = xrep_findparent_walk_directory(&fpi); else
ret = 0;
xchk_iscan_mark_visited(&pscan->iscan, fpi.dp);
xchk_irele(sc, fpi.dp); if (ret) break;
if (xchk_should_terminate(sc, &ret)) break;
}
xchk_iscan_iter_finish(&pscan->iscan);
return ret;
}
/* Tear down a parent scan. */ void
xrep_findparent_scan_teardown( struct xrep_parent_scan_info *pscan)
{
xfs_dir_hook_del(pscan->sc->mp, &pscan->dhook);
xchk_iscan_teardown(&pscan->iscan);
mutex_destroy(&pscan->lock);
}
/* The root directory always points to itself. */ if (sc->ip == sc->mp->m_rootip) {
*parent_ino = sc->mp->m_sb.sb_rootino; return0;
}
/* The metadata root directory always points to itself. */ if (sc->ip == sc->mp->m_metadirip) {
*parent_ino = sc->mp->m_sb.sb_metadirino; return0;
}
/* Unlinked dirs can point anywhere; point them up to the root dir. */ if (VFS_I(sc->ip)->i_nlink == 0) {
*parent_ino = xchk_inode_rootdir_inum(sc->ip); return0;
}
/* Reject garbage parent inode numbers and self-referential parents. */ if (*parent_ino == NULLFSINO) return0; if (!xfs_verify_dir_ino(sc->mp, *parent_ino) ||
*parent_ino == sc->ip->i_ino) {
*parent_ino = NULLFSINO; return0;
}
error = xchk_iget(sc, *parent_ino, &fpi.dp); if (error) return error;
if (!S_ISDIR(VFS_I(fpi.dp)->i_mode)) {
*parent_ino = NULLFSINO; goto out_rele;
}
error = xrep_findparent_walk_directory(&fpi); if (error) goto out_rele;
if (sc->ip->i_ino == sc->mp->m_sb.sb_metadirino) return sc->mp->m_sb.sb_metadirino;
if (VFS_I(sc->ip)->i_nlink == 0) return xchk_inode_rootdir_inum(sc->ip);
return NULLFSINO;
}
/* Check the dentry cache to see if knows of a parent for the scrub target. */
xfs_ino_t
xrep_findparent_from_dcache( struct xfs_scrub *sc)
{ struct inode *pip = NULL; struct dentry *dentry, *parent;
xfs_ino_t ret = NULLFSINO;
dentry = d_find_alias(VFS_I(sc->ip)); if (!dentry) goto out;
parent = dget_parent(dentry); if (!parent) goto out_dput;
ASSERT(parent->d_sb == sc->ip->i_mount->m_super);
pip = igrab(d_inode(parent));
dput(parent);
if (S_ISDIR(pip->i_mode)) {
trace_xrep_findparent_from_dcache(sc->ip, XFS_I(pip)->i_ino);
ret = XFS_I(pip)->i_ino;
}
xchk_irele(sc, XFS_I(pip));
out_dput:
dput(dentry);
out: return ret;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-09-30)
¤
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.