Lines Matching full:sc
104 struct xfs_scrub *sc; member
146 struct xfs_scrub *sc, in xrep_setup_inode() argument
151 sc->buf = kzalloc(sizeof(struct xrep_inode), XCHK_GFP_FLAGS); in xrep_setup_inode()
152 if (!sc->buf) in xrep_setup_inode()
155 ri = sc->buf; in xrep_setup_inode()
157 ri->sc = sc; in xrep_setup_inode()
167 struct xfs_scrub *sc, in xrep_dinode_buf_core() argument
172 struct xfs_trans *tp = sc->tp; in xrep_dinode_buf_core()
173 struct xfs_mount *mp = sc->mp; in xrep_dinode_buf_core()
210 struct xfs_scrub *sc, in xrep_dinode_buf() argument
213 struct xfs_mount *mp = sc->mp; in xrep_dinode_buf()
219 xrep_dinode_buf_core(sc, bp, i << mp->m_sb.sb_inodelog); in xrep_dinode_buf()
225 struct xfs_scrub *sc, in xrep_dinode_header() argument
228 trace_xrep_dinode_header(sc, dip); in xrep_dinode_header()
231 if (!xfs_dinode_good_version(sc->mp, dip->di_version)) in xrep_dinode_header()
233 dip->di_ino = cpu_to_be64(sc->sm->sm_ino); in xrep_dinode_header()
234 uuid_copy(&dip->di_uuid, &sc->mp->m_sb.sb_meta_uuid); in xrep_dinode_header()
235 dip->di_gen = cpu_to_be32(sc->sm->sm_gen); in xrep_dinode_header()
244 struct xfs_scrub *sc, in xrep_dinode_findmode_dirent() argument
254 if (xchk_should_terminate(ri->sc, &error)) in xrep_dinode_findmode_dirent()
257 if (ino != sc->sm->sm_ino) in xrep_dinode_findmode_dirent()
275 trace_xrep_dinode_findmode_dirent_inval(ri->sc, dp, name->type, in xrep_dinode_findmode_dirent()
281 trace_xrep_dinode_findmode_dirent(ri->sc, dp, name->type); in xrep_dinode_findmode_dirent()
315 if (xchk_should_terminate(ri->sc, &error)) in xrep_dinode_trylock_directory()
340 struct xfs_scrub *sc = ri->sc; in xrep_dinode_findmode_walk_directory() local
376 error = xchk_dir_walk(sc, dp, xrep_dinode_findmode_dirent, ri); in xrep_dinode_findmode_walk_directory()
394 struct xfs_scrub *sc = ri->sc; in xrep_dinode_find_mode() local
399 if (!xfs_has_ftype(sc->mp)) { in xrep_dinode_find_mode()
410 xchk_iscan_start(sc, 5000, 100, &ri->ftype_iscan); in xrep_dinode_find_mode()
412 ri->ftype_iscan.skip_ino = sc->sm->sm_ino; in xrep_dinode_find_mode()
418 xchk_irele(sc, dp); in xrep_dinode_find_mode()
421 if (xchk_should_terminate(sc, &error)) in xrep_dinode_find_mode()
436 } else if (!(sc->flags & XCHK_TRY_HARDER)) { in xrep_dinode_find_mode()
485 struct xfs_scrub *sc = ri->sc; in xrep_dinode_mode() local
489 trace_xrep_dinode_mode(sc, dip); in xrep_dinode_mode()
533 struct xfs_scrub *sc, in xrep_dinode_flags() argument
537 struct xfs_mount *mp = sc->mp; in xrep_dinode_flags()
542 trace_xrep_dinode_flags(sc, dip); in xrep_dinode_flags()
581 struct xfs_scrub *sc = ri->sc; in xrep_dinode_zap_symlink() local
584 trace_xrep_dinode_zap_symlink(sc, dip); in xrep_dinode_zap_symlink()
604 struct xfs_scrub *sc = ri->sc; in xrep_dinode_zap_dir() local
605 struct xfs_mount *mp = sc->mp; in xrep_dinode_zap_dir()
609 trace_xrep_dinode_zap_dir(sc, dip); in xrep_dinode_zap_dir()
627 struct xfs_scrub *sc = ri->sc; in xrep_dinode_size() local
631 trace_xrep_dinode_size(sc, dip); in xrep_dinode_size()
675 struct xfs_scrub *sc, in xrep_dinode_extsize_hints() argument
678 struct xfs_mount *mp = sc->mp; in xrep_dinode_extsize_hints()
685 trace_xrep_dinode_extsize_hints(sc, dip); in xrep_dinode_extsize_hints()
716 if (xchk_should_terminate(ri->sc, &error)) in xrep_dinode_walk_rmap()
720 if (rec->rm_owner != ri->sc->sm->sm_ino) in xrep_dinode_walk_rmap()
748 error = xfs_alloc_read_agf(pag, ri->sc->tp, 0, &agf); in xrep_dinode_count_ag_rmaps()
752 cur = xfs_rmapbt_init_cursor(ri->sc->mp, ri->sc->tp, agf, pag); in xrep_dinode_count_ag_rmaps()
755 xfs_trans_brelse(ri->sc->tp, agf); in xrep_dinode_count_ag_rmaps()
768 if (!xfs_has_rmapbt(ri->sc->mp) || xfs_has_realtime(ri->sc->mp)) in xrep_dinode_count_rmaps()
771 for_each_perag(ri->sc->mp, agno, pag) { in xrep_dinode_count_rmaps()
783 trace_xrep_dinode_count_rmaps(ri->sc, in xrep_dinode_count_rmaps()
792 struct xfs_scrub *sc, in xrep_dinode_bad_extents_fork() argument
814 fa = xfs_bmap_validate_extent_raw(sc->mp, isrt, whichfork, in xrep_dinode_bad_extents_fork()
826 struct xfs_scrub *sc, in xrep_dinode_bad_bmbt_fork() argument
851 if (level == 0 || level >= XFS_BM_MAXLEVELS(sc->mp, whichfork)) in xrep_dinode_bad_bmbt_fork()
863 if (!xfs_verify_fileoff(sc->mp, fileoff)) in xrep_dinode_bad_bmbt_fork()
868 if (!xfs_verify_fsbno(sc->mp, fsbno)) in xrep_dinode_bad_bmbt_fork()
881 struct xfs_scrub *sc, in xrep_dinode_check_dfork() argument
926 dfork_size = XFS_DFORK_SIZE(dip, sc->mp, XFS_DATA_FORK); in xrep_dinode_check_dfork()
938 xfs_dir2_sf_verify(sc->mp, dfork_ptr, data_size) != NULL) in xrep_dinode_check_dfork()
946 if (xrep_dinode_bad_extents_fork(sc, dip, dfork_size, in xrep_dinode_check_dfork()
951 if (xrep_dinode_bad_bmbt_fork(sc, dip, dfork_size, in xrep_dinode_check_dfork()
991 struct xfs_scrub *sc = ri->sc; in xrep_dinode_zap_dfork() local
993 trace_xrep_dinode_zap_dfork(sc, dip); in xrep_dinode_zap_dfork()
1038 struct xfs_scrub *sc, in xrep_dinode_check_afork() argument
1049 afork_size = XFS_DFORK_SIZE(dip, sc->mp, XFS_ATTR_FORK); in xrep_dinode_check_afork()
1066 if (xrep_dinode_bad_extents_fork(sc, dip, afork_size, in xrep_dinode_check_afork()
1071 if (xrep_dinode_bad_bmbt_fork(sc, dip, afork_size, in xrep_dinode_check_afork()
1092 struct xfs_scrub *sc = ri->sc; in xrep_dinode_zap_afork() local
1094 trace_xrep_dinode_zap_afork(sc, dip); in xrep_dinode_zap_afork()
1122 struct xfs_scrub *sc = ri->sc; in xrep_dinode_ensure_forkoff() local
1125 unsigned int lit_sz = XFS_LITINO(sc->mp); in xrep_dinode_ensure_forkoff()
1128 trace_xrep_dinode_ensure_forkoff(sc, dip); in xrep_dinode_ensure_forkoff()
1147 afork_min = XFS_DFORK_SIZE(dip, sc->mp, XFS_ATTR_FORK); in xrep_dinode_ensure_forkoff()
1176 afork_min = xfs_bmap_broot_space(sc->mp, bmdr); in xrep_dinode_ensure_forkoff()
1226 dfork_min = xfs_bmap_broot_space(sc->mp, bmdr); in xrep_dinode_ensure_forkoff()
1251 bmdr_minsz > XFS_DFORK_DSIZE(dip, sc->mp)) { in xrep_dinode_ensure_forkoff()
1266 memmove(after, before, XFS_DFORK_ASIZE(dip, sc->mp)); in xrep_dinode_ensure_forkoff()
1277 bmdr_minsz > XFS_DFORK_ASIZE(dip, sc->mp)) { in xrep_dinode_ensure_forkoff()
1311 struct xfs_scrub *sc = ri->sc; in xrep_dinode_zap_forks() local
1319 trace_xrep_dinode_zap_forks(sc, dip); in xrep_dinode_zap_forks()
1336 zap_datafork = xrep_dinode_check_dfork(sc, dip, mode); in xrep_dinode_zap_forks()
1338 zap_attrfork = xrep_dinode_check_afork(sc, dip); in xrep_dinode_zap_forks()
1362 struct xfs_scrub *sc = ri->sc; in xrep_dinode_core() local
1365 xfs_ino_t ino = sc->sm->sm_ino; in xrep_dinode_core()
1375 error = xfs_trans_read_buf(sc->mp, sc->tp, sc->mp->m_ddev_targp, in xrep_dinode_core()
1382 xrep_dinode_buf(sc, bp); in xrep_dinode_core()
1387 xrep_dinode_header(sc, dip); in xrep_dinode_core()
1392 xrep_dinode_flags(sc, dip, ri->rt_extents > 0); in xrep_dinode_core()
1394 xrep_dinode_extsize_hints(sc, dip); in xrep_dinode_core()
1399 trace_xrep_dinode_fixed(sc, dip); in xrep_dinode_core()
1400 xfs_dinode_calc_crc(sc->mp, dip); in xrep_dinode_core()
1401 xfs_trans_buf_set_type(sc->tp, bp, XFS_BLFT_DINO_BUF); in xrep_dinode_core()
1402 xfs_trans_log_buf(sc->tp, bp, ri->imap.im_boffset, in xrep_dinode_core()
1403 ri->imap.im_boffset + sc->mp->m_sb.sb_inodesize - 1); in xrep_dinode_core()
1414 iget_error = xchk_iget(sc, ino, &sc->ip); in xrep_dinode_core()
1416 xchk_ilock(sc, XFS_IOLOCK_EXCL); in xrep_dinode_core()
1423 error = xrep_trans_commit(sc); in xrep_dinode_core()
1430 error = xchk_trans_alloc(sc, 0); in xrep_dinode_core()
1434 error = xrep_ino_dqattach(sc); in xrep_dinode_core()
1438 xchk_ilock(sc, XFS_ILOCK_EXCL); in xrep_dinode_core()
1440 xfs_inode_mark_sick(sc->ip, ri->ino_sick_mask); in xrep_dinode_core()
1449 struct xfs_scrub *sc = ri->sc; in xrep_dinode_problems() local
1457 if (XFS_IS_UQUOTA_ON(sc->mp)) in xrep_dinode_problems()
1458 xrep_force_quotacheck(sc, XFS_DQTYPE_USER); in xrep_dinode_problems()
1459 if (XFS_IS_GQUOTA_ON(sc->mp)) in xrep_dinode_problems()
1460 xrep_force_quotacheck(sc, XFS_DQTYPE_GROUP); in xrep_dinode_problems()
1461 if (XFS_IS_PQUOTA_ON(sc->mp)) in xrep_dinode_problems()
1462 xrep_force_quotacheck(sc, XFS_DQTYPE_PROJ); in xrep_dinode_problems()
1476 struct xfs_scrub *sc) in xrep_inode_blockcounts() argument
1484 trace_xrep_inode_blockcounts(sc); in xrep_inode_blockcounts()
1487 error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_DATA_FORK, in xrep_inode_blockcounts()
1491 if (xfs_is_reflink_inode(sc->ip)) { in xrep_inode_blockcounts()
1497 } else if (XFS_IS_REALTIME_INODE(sc->ip)) { in xrep_inode_blockcounts()
1498 if (count >= sc->mp->m_sb.sb_rblocks) in xrep_inode_blockcounts()
1501 if (count >= sc->mp->m_sb.sb_dblocks) in xrep_inode_blockcounts()
1504 error = xrep_ino_ensure_extent_count(sc, XFS_DATA_FORK, nextents); in xrep_inode_blockcounts()
1507 sc->ip->i_df.if_nextents = nextents; in xrep_inode_blockcounts()
1510 ifp = xfs_ifork_ptr(sc->ip, XFS_ATTR_FORK); in xrep_inode_blockcounts()
1512 error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_ATTR_FORK, in xrep_inode_blockcounts()
1516 if (count >= sc->mp->m_sb.sb_dblocks) in xrep_inode_blockcounts()
1518 error = xrep_ino_ensure_extent_count(sc, XFS_ATTR_FORK, in xrep_inode_blockcounts()
1527 sc->ip->i_nblocks = count + acount; in xrep_inode_blockcounts()
1534 struct xfs_scrub *sc) in xrep_inode_ids() argument
1538 trace_xrep_inode_ids(sc); in xrep_inode_ids()
1540 if (!uid_valid(VFS_I(sc->ip)->i_uid)) { in xrep_inode_ids()
1541 i_uid_write(VFS_I(sc->ip), 0); in xrep_inode_ids()
1543 if (XFS_IS_UQUOTA_ON(sc->mp)) in xrep_inode_ids()
1544 xrep_force_quotacheck(sc, XFS_DQTYPE_USER); in xrep_inode_ids()
1547 if (!gid_valid(VFS_I(sc->ip)->i_gid)) { in xrep_inode_ids()
1548 i_gid_write(VFS_I(sc->ip), 0); in xrep_inode_ids()
1550 if (XFS_IS_GQUOTA_ON(sc->mp)) in xrep_inode_ids()
1551 xrep_force_quotacheck(sc, XFS_DQTYPE_GROUP); in xrep_inode_ids()
1554 if (sc->ip->i_projid == -1U) { in xrep_inode_ids()
1555 sc->ip->i_projid = 0; in xrep_inode_ids()
1557 if (XFS_IS_PQUOTA_ON(sc->mp)) in xrep_inode_ids()
1558 xrep_force_quotacheck(sc, XFS_DQTYPE_PROJ); in xrep_inode_ids()
1563 VFS_I(sc->ip)->i_mode &= ~(S_ISUID | S_ISGID); in xrep_inode_ids()
1601 struct xfs_scrub *sc) in xrep_inode_flags() argument
1605 trace_xrep_inode_flags(sc); in xrep_inode_flags()
1607 mode = VFS_I(sc->ip)->i_mode; in xrep_inode_flags()
1610 if (sc->ip->i_diflags & ~XFS_DIFLAG_ANY) in xrep_inode_flags()
1611 sc->ip->i_diflags &= ~XFS_DIFLAG_ANY; in xrep_inode_flags()
1614 if (sc->ip->i_ino == sc->mp->m_sb.sb_rbmino) in xrep_inode_flags()
1615 sc->ip->i_diflags |= XFS_DIFLAG_NEWRTBM; in xrep_inode_flags()
1617 sc->ip->i_diflags &= ~XFS_DIFLAG_NEWRTBM; in xrep_inode_flags()
1621 sc->ip->i_diflags &= ~(XFS_DIFLAG_RTINHERIT | in xrep_inode_flags()
1628 sc->ip->i_diflags &= ~(XFS_DIFLAG_REALTIME | in xrep_inode_flags()
1632 if (sc->ip->i_diflags & XFS_DIFLAG_REALTIME) in xrep_inode_flags()
1633 sc->ip->i_diflags &= ~XFS_DIFLAG_FILESTREAM; in xrep_inode_flags()
1636 if ((sc->ip->i_diflags & XFS_DIFLAG_IMMUTABLE) && in xrep_inode_flags()
1637 (sc->ip->i_diflags & XFS_DIFLAG_APPEND)) in xrep_inode_flags()
1638 sc->ip->i_diflags &= ~XFS_DIFLAG_APPEND; in xrep_inode_flags()
1641 if (sc->ip->i_diflags2 & ~XFS_DIFLAG2_ANY) in xrep_inode_flags()
1642 sc->ip->i_diflags2 &= ~XFS_DIFLAG2_ANY; in xrep_inode_flags()
1645 if (!xfs_has_reflink(sc->mp) || !S_ISREG(mode)) in xrep_inode_flags()
1646 sc->ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; in xrep_inode_flags()
1650 sc->ip->i_diflags2 &= ~XFS_DIFLAG2_DAX; in xrep_inode_flags()
1653 if (sc->ip->i_diflags & XFS_DIFLAG_REALTIME) in xrep_inode_flags()
1654 sc->ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; in xrep_inode_flags()
1664 struct xfs_scrub *sc) in xrep_inode_blockdir_size() argument
1672 trace_xrep_inode_blockdir_size(sc); in xrep_inode_blockdir_size()
1674 error = xfs_iread_extents(sc->tp, sc->ip, XFS_DATA_FORK); in xrep_inode_blockdir_size()
1679 ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK); in xrep_inode_blockdir_size()
1680 off = XFS_B_TO_FSB(sc->mp, XFS_DIR2_SPACE_SIZE); in xrep_inode_blockdir_size()
1681 if (!xfs_iext_lookup_extent_before(sc->ip, ifp, &off, &icur, &got)) { in xrep_inode_blockdir_size()
1687 sc->ip->i_disk_size = min_t(loff_t, XFS_DIR2_SPACE_SIZE, in xrep_inode_blockdir_size()
1688 XFS_FSB_TO_B(sc->mp, off)); in xrep_inode_blockdir_size()
1694 struct xfs_scrub *sc) in xrep_inode_sfdir_size() argument
1698 trace_xrep_inode_sfdir_size(sc); in xrep_inode_sfdir_size()
1700 ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK); in xrep_inode_sfdir_size()
1701 sc->ip->i_disk_size = ifp->if_bytes; in xrep_inode_sfdir_size()
1710 struct xfs_scrub *sc) in xrep_inode_dir_size() argument
1712 trace_xrep_inode_dir_size(sc); in xrep_inode_dir_size()
1714 switch (sc->ip->i_df.if_format) { in xrep_inode_dir_size()
1717 xrep_inode_blockdir_size(sc); in xrep_inode_dir_size()
1720 xrep_inode_sfdir_size(sc); in xrep_inode_dir_size()
1728 struct xfs_scrub *sc) in xrep_inode_extsize() argument
1731 if ((sc->ip->i_diflags & XFS_DIFLAG_RTINHERIT) && in xrep_inode_extsize()
1732 (sc->ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) && in xrep_inode_extsize()
1733 xfs_extlen_to_rtxmod(sc->mp, sc->ip->i_extsize) > 0) { in xrep_inode_extsize()
1734 sc->ip->i_extsize = 0; in xrep_inode_extsize()
1735 sc->ip->i_diflags &= ~XFS_DIFLAG_EXTSZINHERIT; in xrep_inode_extsize()
1742 struct xfs_scrub *sc) in xrep_inode_pptr() argument
1744 struct xfs_mount *mp = sc->mp; in xrep_inode_pptr()
1745 struct xfs_inode *ip = sc->ip; in xrep_inode_pptr()
1773 return xfs_bmap_add_attrfork(sc->tp, ip, in xrep_inode_pptr()
1780 struct xfs_scrub *sc) in xrep_inode_problems() argument
1784 error = xrep_inode_blockcounts(sc); in xrep_inode_problems()
1787 error = xrep_inode_pptr(sc); in xrep_inode_problems()
1790 xrep_inode_timestamps(sc->ip); in xrep_inode_problems()
1791 xrep_inode_flags(sc); in xrep_inode_problems()
1792 xrep_inode_ids(sc); in xrep_inode_problems()
1797 if (S_ISDIR(VFS_I(sc->ip)->i_mode)) in xrep_inode_problems()
1798 xrep_inode_dir_size(sc); in xrep_inode_problems()
1799 xrep_inode_extsize(sc); in xrep_inode_problems()
1801 trace_xrep_inode_fixed(sc); in xrep_inode_problems()
1802 xfs_trans_log_inode(sc->tp, sc->ip, XFS_ILOG_CORE); in xrep_inode_problems()
1803 return xrep_roll_trans(sc); in xrep_inode_problems()
1812 struct xfs_scrub *sc) in xrep_inode_unlinked() argument
1814 unsigned int nlink = VFS_I(sc->ip)->i_nlink; in xrep_inode_unlinked()
1821 if (nlink > 0 && xfs_inode_on_unlinked_list(sc->ip)) { in xrep_inode_unlinked()
1825 pag = xfs_perag_get(sc->mp, in xrep_inode_unlinked()
1826 XFS_INO_TO_AGNO(sc->mp, sc->ip->i_ino)); in xrep_inode_unlinked()
1827 error = xfs_iunlink_remove(sc->tp, pag, sc->ip); in xrep_inode_unlinked()
1837 if (nlink == 0 && !xfs_inode_on_unlinked_list(sc->ip)) { in xrep_inode_unlinked()
1838 error = xfs_iunlink(sc->tp, sc->ip); in xrep_inode_unlinked()
1849 struct xfs_scrub *sc) in xrep_inode() argument
1857 if (!sc->ip) { in xrep_inode()
1858 struct xrep_inode *ri = sc->buf; in xrep_inode()
1874 if (!sc->ip) in xrep_inode()
1878 xfs_trans_ijoin(sc->tp, sc->ip, 0); in xrep_inode()
1881 if ((sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) || in xrep_inode()
1882 (sc->sm->sm_flags & XFS_SCRUB_OFLAG_XCORRUPT)) { in xrep_inode()
1883 error = xrep_inode_problems(sc); in xrep_inode()
1889 if (xfs_is_reflink_inode(sc->ip)) { in xrep_inode()
1890 error = xfs_reflink_clear_inode_flag(sc->ip, &sc->tp); in xrep_inode()
1896 error = xrep_inode_unlinked(sc); in xrep_inode()
1900 return xrep_defer_finish(sc); in xrep_inode()