Lines Matching +full:scrubber +full:- +full:done

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2017-2023 Oracle. All Rights Reserved.
70 if (!xfs_dir2_namecheck(name->name, name->len)) in xchk_parent_actor()
71 error = -EFSCORRUPTED; in xchk_parent_actor()
75 if (sc->ip->i_ino == ino) in xchk_parent_actor()
76 spc->nlink++; in xchk_parent_actor()
78 if (xchk_should_terminate(spc->sc, &error)) in xchk_parent_actor()
95 if (!xfs_need_iread_extents(&dp->i_df)) in xchk_parent_ilock_dir()
109 * back to the inode being scrubbed. Returns -EAGAIN if we need to revalidate
121 struct xfs_mount *mp = sc->mp; in xchk_parent_validate()
128 if (sc->ip == mp->m_rootip) { in xchk_parent_validate()
129 if (sc->ip->i_ino != mp->m_sb.sb_rootino || in xchk_parent_validate()
130 sc->ip->i_ino != parent_ino) in xchk_parent_validate()
136 if (sc->ip == mp->m_metadirip) { in xchk_parent_validate()
137 if (sc->ip->i_ino != mp->m_sb.sb_metadirino || in xchk_parent_validate()
138 sc->ip->i_ino != parent_ino) in xchk_parent_validate()
144 if (sc->ip->i_ino == parent_ino) { in xchk_parent_validate()
153 expected_nlink = VFS_I(sc->ip)->i_nlink == 0 ? 0 : 1; in xchk_parent_validate()
159 * If _iget returns -EINVAL or -ENOENT then the parent inode number is in xchk_parent_validate()
161 * -EFSCORRUPTED or -EFSBADCRC then the parent is corrupt which is a in xchk_parent_validate()
165 if (error == -EINVAL || error == -ENOENT) { in xchk_parent_validate()
166 error = -EFSCORRUPTED; in xchk_parent_validate()
172 if (dp == sc->ip || xrep_is_tempfile(dp) || in xchk_parent_validate()
173 !S_ISDIR(VFS_I(dp)->i_mode)) { in xchk_parent_validate()
182 error = -EAGAIN; in xchk_parent_validate()
191 error = -EBUSY; in xchk_parent_validate()
197 if (xfs_is_metadir_inode(dp) != xfs_is_metadir_inode(sc->ip)) { in xchk_parent_validate()
252 /* Fixed-size array of xchk_pptr structures. */
288 error = xfs_parent_from_attr(sc->mp, attr_flags, name, namelen, value, in xchk_parent_scan_dotdot()
293 if (pp->parent_ino == parent_ino) in xchk_parent_scan_dotdot()
294 return -ECANCELED; in xchk_parent_scan_dotdot()
304 struct xfs_scrub *sc = pp->sc; in xchk_parent_pptr_and_dotdot()
308 error = xchk_dir_lookup(sc, sc->ip, &xfs_name_dotdot, &pp->parent_ino); in xchk_parent_pptr_and_dotdot()
311 if (!xfs_verify_dir_ino(sc->mp, pp->parent_ino)) { in xchk_parent_pptr_and_dotdot()
317 if (xchk_inode_is_dirtree_root(sc->ip)) { in xchk_parent_pptr_and_dotdot()
318 if (sc->ip->i_ino != pp->parent_ino) in xchk_parent_pptr_and_dotdot()
327 if (VFS_I(sc->ip)->i_nlink == 0) in xchk_parent_pptr_and_dotdot()
330 if (pp->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_parent_pptr_and_dotdot()
334 error = xchk_xattr_walk(sc, sc->ip, xchk_parent_scan_dotdot, NULL, pp); in xchk_parent_pptr_and_dotdot()
335 if (error == -ECANCELED) { in xchk_parent_pptr_and_dotdot()
339 if (!error || error == -EFSCORRUPTED) { in xchk_parent_pptr_and_dotdot()
364 if (!xfs_need_iread_extents(&dp->i_df)) in xchk_parent_lock_dir()
384 struct xfs_scrub *sc = pp->sc; in xchk_parent_dirent()
393 if (error == -ENOENT) { in xchk_parent_dirent()
401 if (child_ino != sc->ip->i_ino) { in xchk_parent_dirent()
416 struct xfs_scrub *sc = pp->sc; in xchk_parent_iget()
418 xfs_ino_t parent_ino = be64_to_cpu(pptr->p_ino); in xchk_parent_iget()
422 error = xfs_dir_ino_validate(sc->mp, parent_ino); in xchk_parent_iget()
425 return -ECANCELED; in xchk_parent_iget()
429 if (error == -EINVAL || error == -ENOENT) { in xchk_parent_iget()
431 return -ECANCELED; in xchk_parent_iget()
437 if (!S_ISDIR(VFS_I(ip)->i_mode)) { in xchk_parent_iget()
443 if (VFS_I(ip)->i_generation != be32_to_cpu(pptr->p_gen)) { in xchk_parent_iget()
485 error = xfs_parent_from_attr(sc->mp, attr_flags, name, namelen, value, in xchk_parent_scan_attr()
492 /* No self-referential parent pointers. */ in xchk_parent_scan_attr()
493 if (parent_ino == sc->ip->i_ino) { in xchk_parent_scan_attr()
495 return -ECANCELED; in xchk_parent_scan_attr()
498 pp->pptrs_found++; in xchk_parent_scan_attr()
515 trace_xchk_parent_defer(sc->ip, &xname, dp->i_ino); in xchk_parent_scan_attr()
517 error = xfblob_storename(pp->pptr_names, &save_pp.name_cookie, in xchk_parent_scan_attr()
523 error = xfarray_append(pp->pptr_entries, &save_pp); in xchk_parent_scan_attr()
545 * -ENOENT if it has gone away on us, or a negative errno.
553 struct xfs_scrub *sc = pp->sc; in xchk_parent_revalidate_pptr()
556 error = xfs_parent_lookup(sc->tp, sc->ip, xname, pptr, &pp->pptr_args); in xchk_parent_revalidate_pptr()
557 if (error == -ENOATTR) { in xchk_parent_revalidate_pptr()
559 return -ENOENT; in xchk_parent_revalidate_pptr()
567 * and put up with revalidation until we get it done.
575 struct xfs_scrub *sc = pp->sc; in xchk_parent_slow_pptr()
581 if (pp->need_revalidate) { in xchk_parent_slow_pptr()
583 if (error == -ENOENT) in xchk_parent_slow_pptr()
602 trace_xchk_parent_slowpath(sc->ip, xname, dp->i_ino); in xchk_parent_slow_pptr()
610 xchk_iunlock(sc, sc->ilock_flags); in xchk_parent_slow_pptr()
611 pp->need_revalidate = true; in xchk_parent_slow_pptr()
613 trace_xchk_parent_ultraslowpath(sc->ip, xname, dp->i_ino); in xchk_parent_slow_pptr()
621 if (error == -ENOENT) { in xchk_parent_slow_pptr()
645 foreach_xfarray_idx(pp->pptr_entries, array_cur) { in xchk_parent_finish_slow_pptrs()
648 if (pp->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_parent_finish_slow_pptrs()
651 error = xfarray_load(pp->pptr_entries, array_cur, &pptr); in xchk_parent_finish_slow_pptrs()
655 error = xfblob_loadname(pp->pptr_names, pptr.name_cookie, in xchk_parent_finish_slow_pptrs()
656 &pp->xname, pptr.namelen); in xchk_parent_finish_slow_pptrs()
660 error = xchk_parent_slow_pptr(pp, &pp->xname, &pptr.pptr_rec); in xchk_parent_finish_slow_pptrs()
666 xfarray_truncate(pp->pptr_entries); in xchk_parent_finish_slow_pptrs()
667 xfblob_truncate(pp->pptr_names); in xchk_parent_finish_slow_pptrs()
689 error = xfs_parent_from_attr(sc->mp, attr_flags, name, namelen, value, in xchk_parent_count_pptr()
694 pp->pptrs_found++; in xchk_parent_count_pptr()
700 * non-directories these should be the same. For unlinked directories the
707 struct xfs_scrub *sc = pp->sc; in xchk_parent_count_pptrs()
711 * If we cycled the ILOCK while cross-checking parent pointers with in xchk_parent_count_pptrs()
714 if (pp->need_revalidate) { in xchk_parent_count_pptrs()
715 pp->pptrs_found = 0; in xchk_parent_count_pptrs()
716 error = xchk_xattr_walk(sc, sc->ip, xchk_parent_count_pptr, in xchk_parent_count_pptrs()
718 if (error == -EFSCORRUPTED) { in xchk_parent_count_pptrs()
727 if (S_ISDIR(VFS_I(sc->ip)->i_mode)) { in xchk_parent_count_pptrs()
728 if (xchk_inode_is_dirtree_root(sc->ip)) in xchk_parent_count_pptrs()
729 pp->pptrs_found++; in xchk_parent_count_pptrs()
731 if (VFS_I(sc->ip)->i_nlink == 0 && pp->pptrs_found > 0) in xchk_parent_count_pptrs()
732 xchk_ino_set_corrupt(sc, sc->ip->i_ino); in xchk_parent_count_pptrs()
733 else if (VFS_I(sc->ip)->i_nlink > 0 && in xchk_parent_count_pptrs()
734 pp->pptrs_found == 0) in xchk_parent_count_pptrs()
735 xchk_ino_set_corrupt(sc, sc->ip->i_ino); in xchk_parent_count_pptrs()
739 * of non-directory files that are children of the superblock. in xchk_parent_count_pptrs()
742 if (xfs_has_metadir(sc->mp) && xchk_inode_is_sb_rooted(sc->ip)) in xchk_parent_count_pptrs()
743 pp->pptrs_found++; in xchk_parent_count_pptrs()
745 if (VFS_I(sc->ip)->i_nlink != pp->pptrs_found) in xchk_parent_count_pptrs()
746 xchk_ino_set_corrupt(sc, sc->ip->i_ino); in xchk_parent_count_pptrs()
763 return -ENOMEM; in xchk_parent_pptr()
764 pp->sc = sc; in xchk_parent_pptr()
765 pp->xname.name = pp->namebuf; in xchk_parent_pptr()
773 &pp->pptr_entries); in xchk_parent_pptr()
779 error = xfblob_create(descr, &pp->pptr_names); in xchk_parent_pptr()
784 error = xchk_xattr_walk(sc, sc->ip, xchk_parent_scan_attr, NULL, pp); in xchk_parent_pptr()
785 if (error == -ECANCELED) { in xchk_parent_pptr()
793 if (error == -ETIMEDOUT) { in xchk_parent_pptr()
801 if (pp->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_parent_pptr()
817 if (S_ISDIR(VFS_I(sc->ip)->i_mode)) { in xchk_parent_pptr()
823 if (pp->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_parent_pptr()
836 xfblob_destroy(pp->pptr_names); in xchk_parent_pptr()
838 xfarray_destroy(pp->pptr_entries); in xchk_parent_pptr()
849 struct xfs_mount *mp = sc->mp; in xchk_parent()
860 if (!S_ISDIR(VFS_I(sc->ip)->i_mode)) in xchk_parent()
861 return -ENOENT; in xchk_parent()
864 if (!xfs_verify_dir_ino(mp, sc->ip->i_ino)) { in xchk_parent()
874 error = xchk_dir_lookup(sc, sc->ip, &xfs_name_dotdot, in xchk_parent()
888 } while (error == -EAGAIN); in xchk_parent()
889 if (error == -EBUSY) { in xchk_parent()
912 ASSERT(xfs_has_parent(ip->i_mount)); in xchk_pptr_looks_zapped()
918 if (inode->i_nlink == 0 && !(inode->i_state & I_LINKABLE)) in xchk_pptr_looks_zapped()
938 * Linked and linkable non-rootdir files should always have an in xchk_pptr_looks_zapped()
952 * scrubber to reconstruct the block mappings. The extended attribute in xchk_pptr_looks_zapped()
956 return ip->i_af.if_format == XFS_DINODE_FMT_EXTENTS && in xchk_pptr_looks_zapped()
957 ip->i_af.if_nextents == 0; in xchk_pptr_looks_zapped()