Lines Matching defs:sc

107 	struct xfs_scrub	*sc;
149 struct xfs_scrub *sc,
154 sc->buf = kzalloc(sizeof(struct xrep_inode), XCHK_GFP_FLAGS);
155 if (!sc->buf)
158 ri = sc->buf;
160 ri->sc = sc;
170 struct xfs_scrub *sc,
175 struct xfs_trans *tp = sc->tp;
176 struct xfs_mount *mp = sc->mp;
213 struct xfs_scrub *sc,
216 struct xfs_mount *mp = sc->mp;
222 xrep_dinode_buf_core(sc, bp, i << mp->m_sb.sb_inodelog);
228 struct xfs_scrub *sc,
231 trace_xrep_dinode_header(sc, dip);
234 if (!xfs_dinode_good_version(sc->mp, dip->di_version))
236 dip->di_ino = cpu_to_be64(sc->sm->sm_ino);
237 uuid_copy(&dip->di_uuid, &sc->mp->m_sb.sb_meta_uuid);
238 dip->di_gen = cpu_to_be32(sc->sm->sm_gen);
247 struct xfs_scrub *sc,
257 if (xchk_should_terminate(ri->sc, &error))
260 if (ino != sc->sm->sm_ino)
278 trace_xrep_dinode_findmode_dirent_inval(ri->sc, dp, name->type,
284 trace_xrep_dinode_findmode_dirent(ri->sc, dp, name->type);
318 if (xchk_should_terminate(ri->sc, &error))
343 struct xfs_scrub *sc = ri->sc;
379 error = xchk_dir_walk(sc, dp, xrep_dinode_findmode_dirent, ri);
397 struct xfs_scrub *sc = ri->sc;
402 if (!xfs_has_ftype(sc->mp)) {
413 xchk_iscan_start(sc, 5000, 100, &ri->ftype_iscan);
415 ri->ftype_iscan.skip_ino = sc->sm->sm_ino;
421 xchk_irele(sc, dp);
424 if (xchk_should_terminate(sc, &error))
439 } else if (!(sc->flags & XCHK_TRY_HARDER)) {
488 struct xfs_scrub *sc = ri->sc;
492 trace_xrep_dinode_mode(sc, dip);
543 struct xfs_scrub *sc,
547 struct xfs_mount *mp = sc->mp;
552 trace_xrep_dinode_flags(sc, dip);
580 fa = xfs_dinode_verify_metadir(sc->mp, dip, mode, flags,
599 struct xfs_scrub *sc = ri->sc;
602 trace_xrep_dinode_zap_symlink(sc, dip);
622 struct xfs_scrub *sc = ri->sc;
623 struct xfs_mount *mp = sc->mp;
627 trace_xrep_dinode_zap_dir(sc, dip);
645 struct xfs_scrub *sc = ri->sc;
649 trace_xrep_dinode_size(sc, dip);
693 struct xfs_scrub *sc,
696 struct xfs_mount *mp = sc->mp;
703 trace_xrep_dinode_extsize_hints(sc, dip);
714 (xfs_has_zoned(sc->mp) &&
736 if (xchk_should_terminate(ri->sc, &error))
740 if (rec->rm_owner != ri->sc->sm->sm_ino)
768 error = xfs_alloc_read_agf(pag, ri->sc->tp, 0, &agf);
772 cur = xfs_rmapbt_init_cursor(ri->sc->mp, ri->sc->tp, agf, pag);
775 xfs_trans_brelse(ri->sc->tp, agf);
789 if (xchk_should_terminate(ri->sc, &error))
793 if (rec->rm_owner != ri->sc->sm->sm_ino)
810 struct xfs_scrub *sc = ri->sc;
813 error = xrep_rtgroup_init(sc, rtg, &sc->sr, XFS_RTGLOCK_RMAP);
817 error = xfs_rmap_query_all(sc->sr.rmap_cur, xrep_dinode_walk_rtrmap,
819 xchk_rtgroup_btcur_free(&sc->sr);
820 xchk_rtgroup_free(sc, &sc->sr);
833 if (!xfs_has_rmapbt(ri->sc->mp))
836 while ((rtg = xfs_rtgroup_next(ri->sc->mp, rtg))) {
844 while ((pag = xfs_perag_next(ri->sc->mp, pag))) {
856 trace_xrep_dinode_count_rmaps(ri->sc,
865 struct xfs_scrub *sc,
887 fa = xfs_bmap_validate_extent_raw(sc->mp, isrt, whichfork,
899 struct xfs_scrub *sc,
924 if (level == 0 || level >= XFS_BM_MAXLEVELS(sc->mp, whichfork))
936 if (!xfs_verify_fileoff(sc->mp, fileoff))
941 if (!xfs_verify_fsbno(sc->mp, fsbno))
951 struct xfs_scrub *sc,
966 if (level > sc->mp->m_rtrmap_maxlevels)
979 struct xfs_scrub *sc,
994 if (level > sc->mp->m_rtrefc_maxlevels)
1007 struct xfs_scrub *sc,
1017 return xrep_dinode_bad_rtrmapbt_fork(sc, dip, dfork_size);
1019 return xrep_dinode_bad_rtrefcountbt_fork(sc, dip, dfork_size);
1033 struct xfs_scrub *sc,
1086 dfork_size = XFS_DFORK_SIZE(dip, sc->mp, XFS_DATA_FORK);
1098 xfs_dir2_sf_verify(sc->mp, dfork_ptr, data_size) != NULL)
1106 if (xrep_dinode_bad_extents_fork(sc, dip, dfork_size,
1111 if (xrep_dinode_bad_bmbt_fork(sc, dip, dfork_size,
1116 if (xrep_dinode_bad_metabt_fork(sc, dip, dfork_size,
1156 struct xfs_scrub *sc = ri->sc;
1158 trace_xrep_dinode_zap_dfork(sc, dip);
1203 struct xfs_scrub *sc,
1214 afork_size = XFS_DFORK_SIZE(dip, sc->mp, XFS_ATTR_FORK);
1231 if (xrep_dinode_bad_extents_fork(sc, dip, afork_size,
1236 if (xrep_dinode_bad_bmbt_fork(sc, dip, afork_size,
1241 if (xrep_dinode_bad_metabt_fork(sc, dip, afork_size,
1262 struct xfs_scrub *sc = ri->sc;
1264 trace_xrep_dinode_zap_afork(sc, dip);
1294 struct xfs_scrub *sc = ri->sc;
1297 unsigned int lit_sz = XFS_LITINO(sc->mp);
1300 trace_xrep_dinode_ensure_forkoff(sc, dip);
1319 afork_min = XFS_DFORK_SIZE(dip, sc->mp, XFS_ATTR_FORK);
1348 afork_min = xfs_bmap_broot_space(sc->mp, bmdr);
1398 dfork_min = xfs_bmap_broot_space(sc->mp, bmdr);
1404 dfork_min = xfs_rtrmap_broot_space(sc->mp, rmdr);
1408 dfork_min = xfs_rtrefcount_broot_space(sc->mp, rcdr);
1438 bmdr_minsz > XFS_DFORK_DSIZE(dip, sc->mp)) {
1453 memmove(after, before, XFS_DFORK_ASIZE(dip, sc->mp));
1464 bmdr_minsz > XFS_DFORK_ASIZE(dip, sc->mp)) {
1498 struct xfs_scrub *sc = ri->sc;
1506 trace_xrep_dinode_zap_forks(sc, dip);
1523 zap_datafork = xrep_dinode_check_dfork(sc, dip, mode);
1525 zap_attrfork = xrep_dinode_check_afork(sc, dip);
1549 struct xfs_scrub *sc = ri->sc;
1552 xfs_ino_t ino = sc->sm->sm_ino;
1562 error = xfs_trans_read_buf(sc->mp, sc->tp, sc->mp->m_ddev_targp,
1568 xrep_dinode_buf(sc, bp);
1573 xrep_dinode_header(sc, dip);
1578 xrep_dinode_flags(sc, dip, ri->rt_extents > 0);
1580 xrep_dinode_extsize_hints(sc, dip);
1585 trace_xrep_dinode_fixed(sc, dip);
1586 xfs_dinode_calc_crc(sc->mp, dip);
1587 xfs_trans_buf_set_type(sc->tp, bp, XFS_BLFT_DINO_BUF);
1588 xfs_trans_log_buf(sc->tp, bp, ri->imap.im_boffset,
1589 ri->imap.im_boffset + sc->mp->m_sb.sb_inodesize - 1);
1600 iget_error = xchk_iget(sc, ino, &sc->ip);
1602 xchk_ilock(sc, XFS_IOLOCK_EXCL);
1609 error = xrep_trans_commit(sc);
1616 error = xchk_trans_alloc(sc, 0);
1620 error = xrep_ino_dqattach(sc);
1624 xchk_ilock(sc, XFS_ILOCK_EXCL);
1626 xfs_inode_mark_sick(sc->ip, ri->ino_sick_mask);
1635 struct xfs_scrub *sc = ri->sc;
1643 if (XFS_IS_UQUOTA_ON(sc->mp))
1644 xrep_force_quotacheck(sc, XFS_DQTYPE_USER);
1645 if (XFS_IS_GQUOTA_ON(sc->mp))
1646 xrep_force_quotacheck(sc, XFS_DQTYPE_GROUP);
1647 if (XFS_IS_PQUOTA_ON(sc->mp))
1648 xrep_force_quotacheck(sc, XFS_DQTYPE_PROJ);
1662 struct xfs_scrub *sc)
1670 trace_xrep_inode_blockcounts(sc);
1673 error = xchk_inode_count_blocks(sc, XFS_DATA_FORK, &nextents, &count);
1676 if (xfs_is_reflink_inode(sc->ip)) {
1682 } else if (XFS_IS_REALTIME_INODE(sc->ip)) {
1683 if (count >= sc->mp->m_sb.sb_rblocks)
1686 if (count >= sc->mp->m_sb.sb_dblocks)
1689 error = xrep_ino_ensure_extent_count(sc, XFS_DATA_FORK, nextents);
1692 sc->ip->i_df.if_nextents = nextents;
1695 ifp = xfs_ifork_ptr(sc->ip, XFS_ATTR_FORK);
1697 error = xchk_inode_count_blocks(sc, XFS_ATTR_FORK, &nextents,
1701 if (count >= sc->mp->m_sb.sb_dblocks)
1703 error = xrep_ino_ensure_extent_count(sc, XFS_ATTR_FORK,
1712 sc->ip->i_nblocks = count + acount;
1719 struct xfs_scrub *sc)
1723 trace_xrep_inode_ids(sc);
1725 if (!uid_valid(VFS_I(sc->ip)->i_uid)) {
1726 i_uid_write(VFS_I(sc->ip), 0);
1728 if (XFS_IS_UQUOTA_ON(sc->mp))
1729 xrep_force_quotacheck(sc, XFS_DQTYPE_USER);
1732 if (!gid_valid(VFS_I(sc->ip)->i_gid)) {
1733 i_gid_write(VFS_I(sc->ip), 0);
1735 if (XFS_IS_GQUOTA_ON(sc->mp))
1736 xrep_force_quotacheck(sc, XFS_DQTYPE_GROUP);
1739 if (sc->ip->i_projid == -1U) {
1740 sc->ip->i_projid = 0;
1742 if (XFS_IS_PQUOTA_ON(sc->mp))
1743 xrep_force_quotacheck(sc, XFS_DQTYPE_PROJ);
1748 VFS_I(sc->ip)->i_mode &= ~(S_ISUID | S_ISGID);
1786 struct xfs_scrub *sc)
1790 trace_xrep_inode_flags(sc);
1792 mode = VFS_I(sc->ip)->i_mode;
1795 if (sc->ip->i_diflags & ~XFS_DIFLAG_ANY)
1796 sc->ip->i_diflags &= ~XFS_DIFLAG_ANY;
1799 if (sc->ip->i_ino == sc->mp->m_sb.sb_rbmino)
1800 sc->ip->i_diflags |= XFS_DIFLAG_NEWRTBM;
1802 sc->ip->i_diflags &= ~XFS_DIFLAG_NEWRTBM;
1806 sc->ip->i_diflags &= ~(XFS_DIFLAG_RTINHERIT |
1813 sc->ip->i_diflags &= ~(XFS_DIFLAG_REALTIME |
1817 if (sc->ip->i_diflags & XFS_DIFLAG_REALTIME)
1818 sc->ip->i_diflags &= ~XFS_DIFLAG_FILESTREAM;
1821 if ((sc->ip->i_diflags & XFS_DIFLAG_IMMUTABLE) &&
1822 (sc->ip->i_diflags & XFS_DIFLAG_APPEND))
1823 sc->ip->i_diflags &= ~XFS_DIFLAG_APPEND;
1826 if (sc->ip->i_diflags2 & ~XFS_DIFLAG2_ANY)
1827 sc->ip->i_diflags2 &= ~XFS_DIFLAG2_ANY;
1830 if (!xfs_has_reflink(sc->mp) || !S_ISREG(mode))
1831 sc->ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
1835 sc->ip->i_diflags2 &= ~XFS_DIFLAG2_DAX;
1845 struct xfs_scrub *sc)
1853 trace_xrep_inode_blockdir_size(sc);
1855 error = xfs_iread_extents(sc->tp, sc->ip, XFS_DATA_FORK);
1860 ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK);
1861 off = XFS_B_TO_FSB(sc->mp, XFS_DIR2_SPACE_SIZE);
1862 if (!xfs_iext_lookup_extent_before(sc->ip, ifp, &off, &icur, &got)) {
1868 sc->ip->i_disk_size = min_t(loff_t, XFS_DIR2_SPACE_SIZE,
1869 XFS_FSB_TO_B(sc->mp, off));
1875 struct xfs_scrub *sc)
1879 trace_xrep_inode_sfdir_size(sc);
1881 ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK);
1882 sc->ip->i_disk_size = ifp->if_bytes;
1891 struct xfs_scrub *sc)
1893 trace_xrep_inode_dir_size(sc);
1895 switch (sc->ip->i_df.if_format) {
1898 xrep_inode_blockdir_size(sc);
1901 xrep_inode_sfdir_size(sc);
1909 struct xfs_scrub *sc)
1912 if ((sc->ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
1913 (sc->ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) &&
1914 xfs_extlen_to_rtxmod(sc->mp, sc->ip->i_extsize) > 0) {
1915 sc->ip->i_extsize = 0;
1916 sc->ip->i_diflags &= ~XFS_DIFLAG_EXTSZINHERIT;
1923 struct xfs_scrub *sc)
1925 struct xfs_mount *mp = sc->mp;
1926 struct xfs_inode *ip = sc->ip;
1947 return xfs_bmap_add_attrfork(sc->tp, ip,
1954 struct xfs_scrub *sc)
1957 if ((sc->ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
1958 (sc->ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) &&
1959 sc->ip->i_extsize % sc->mp->m_sb.sb_rextsize > 0) {
1960 sc->ip->i_cowextsize = 0;
1961 sc->ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE;
1968 struct xfs_scrub *sc)
1972 error = xrep_inode_blockcounts(sc);
1975 error = xrep_inode_pptr(sc);
1978 xrep_inode_timestamps(sc->ip);
1979 xrep_inode_flags(sc);
1980 xrep_inode_ids(sc);
1985 if (S_ISDIR(VFS_I(sc->ip)->i_mode))
1986 xrep_inode_dir_size(sc);
1987 xrep_inode_extsize(sc);
1988 xrep_inode_cowextsize(sc);
1990 trace_xrep_inode_fixed(sc);
1991 xfs_trans_log_inode(sc->tp, sc->ip, XFS_ILOG_CORE);
1992 return xrep_roll_trans(sc);
2001 struct xfs_scrub *sc)
2003 unsigned int nlink = VFS_I(sc->ip)->i_nlink;
2010 if (nlink > 0 && xfs_inode_on_unlinked_list(sc->ip)) {
2014 pag = xfs_perag_get(sc->mp,
2015 XFS_INO_TO_AGNO(sc->mp, sc->ip->i_ino));
2016 error = xfs_iunlink_remove(sc->tp, pag, sc->ip);
2026 if (nlink == 0 && !xfs_inode_on_unlinked_list(sc->ip)) {
2027 error = xfs_iunlink(sc->tp, sc->ip);
2038 struct xfs_scrub *sc)
2046 if (!sc->ip) {
2047 struct xrep_inode *ri = sc->buf;
2063 if (!sc->ip)
2067 xfs_trans_ijoin(sc->tp, sc->ip, 0);
2070 if ((sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) ||
2071 (sc->sm->sm_flags & XFS_SCRUB_OFLAG_XCORRUPT)) {
2072 error = xrep_inode_problems(sc);
2078 if (xfs_is_reflink_inode(sc->ip)) {
2079 error = xfs_reflink_clear_inode_flag(sc->ip, &sc->tp);
2085 error = xrep_inode_unlinked(sc);
2089 return xrep_defer_finish(sc);