Lines Matching +full:sense +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0+
38 * in raw mode. in xchk_setup_inode()
44 case -EFSCORRUPTED: in xchk_setup_inode()
45 case -EFSBADCRC: in xchk_setup_inode()
52 sc->ilock_flags = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL; in xchk_setup_inode()
53 xfs_ilock(sc->ip, sc->ilock_flags); in xchk_setup_inode()
57 sc->ilock_flags |= XFS_ILOCK_EXCL; in xchk_setup_inode()
58 xfs_ilock(sc->ip, XFS_ILOCK_EXCL); in xchk_setup_inode()
73 uint16_t mode, in xchk_inode_extsize() argument
78 fa = xfs_inode_validate_extsize(sc->mp, be32_to_cpu(dip->di_extsize), in xchk_inode_extsize()
79 mode, flags); in xchk_inode_extsize()
95 uint16_t mode, in xchk_inode_cowextsize() argument
101 fa = xfs_inode_validate_cowextsize(sc->mp, in xchk_inode_cowextsize()
102 be32_to_cpu(dip->di_cowextsize), mode, flags, in xchk_inode_cowextsize()
108 /* Make sure the di_flags make sense for the inode. */
114 uint16_t mode, in xchk_inode_flags() argument
117 struct xfs_mount *mp = sc->mp; in xchk_inode_flags()
124 if ((flags & XFS_DIFLAG_REALTIME) && !mp->m_rtdev_targp) in xchk_inode_flags()
128 if ((flags & XFS_DIFLAG_NEWRTBM) && ino != mp->m_sb.sb_rbmino) in xchk_inode_flags()
131 /* directory-only flags */ in xchk_inode_flags()
136 !S_ISDIR(mode)) in xchk_inode_flags()
139 /* file-only flags */ in xchk_inode_flags()
141 !S_ISREG(mode)) in xchk_inode_flags()
144 /* filestreams and rt make no sense */ in xchk_inode_flags()
153 /* Make sure the di_flags2 make sense for the inode. */
159 uint16_t mode, in xchk_inode_flags2() argument
163 struct xfs_mount *mp = sc->mp; in xchk_inode_flags2()
171 !xfs_sb_version_hasreflink(&mp->m_sb)) in xchk_inode_flags2()
174 /* cowextsize flag is checked w.r.t. mode separately */ in xchk_inode_flags2()
176 /* file/dir-only flags */ in xchk_inode_flags2()
177 if ((flags2 & XFS_DIFLAG2_DAX) && !(S_ISREG(mode) || S_ISDIR(mode))) in xchk_inode_flags2()
180 /* file-only flags */ in xchk_inode_flags2()
181 if ((flags2 & XFS_DIFLAG2_REFLINK) && !S_ISREG(mode)) in xchk_inode_flags2()
184 /* realtime and reflink make no sense, currently */ in xchk_inode_flags2()
188 /* dax and reflink make no sense, currently */ in xchk_inode_flags2()
194 !xfs_sb_version_hasbigtime(&mp->m_sb)) in xchk_inode_flags2()
223 struct xfs_mount *mp = sc->mp; in xchk_dinode()
229 uint16_t mode; in xchk_dinode() local
231 flags = be16_to_cpu(dip->di_flags); in xchk_dinode()
232 if (dip->di_version >= 3) in xchk_dinode()
233 flags2 = be64_to_cpu(dip->di_flags2); in xchk_dinode()
238 mode = be16_to_cpu(dip->di_mode); in xchk_dinode()
239 switch (mode & S_IFMT) { in xchk_dinode()
247 /* mode is recognized */ in xchk_dinode()
255 switch (dip->di_version) { in xchk_dinode()
265 if (dip->di_onlink != 0) in xchk_dinode()
268 if (dip->di_mode == 0 && sc->ip) in xchk_dinode()
271 if (dip->di_projid_hi != 0 && in xchk_dinode()
272 !xfs_sb_version_hasprojid32bit(&mp->m_sb)) in xchk_dinode()
281 * di_uid/di_gid -- -1 isn't invalid, but there's no way that in xchk_dinode()
284 if (dip->di_uid == cpu_to_be32(-1U) || in xchk_dinode()
285 dip->di_gid == cpu_to_be32(-1U)) in xchk_dinode()
289 switch (dip->di_format) { in xchk_dinode()
291 if (!S_ISCHR(mode) && !S_ISBLK(mode) && in xchk_dinode()
292 !S_ISFIFO(mode) && !S_ISSOCK(mode)) in xchk_dinode()
296 if (!S_ISDIR(mode) && !S_ISLNK(mode)) in xchk_dinode()
300 if (!S_ISREG(mode) && !S_ISDIR(mode) && !S_ISLNK(mode)) in xchk_dinode()
304 if (!S_ISREG(mode) && !S_ISDIR(mode)) in xchk_dinode()
314 xchk_dinode_nsec(sc, ino, dip, dip->di_atime); in xchk_dinode()
315 xchk_dinode_nsec(sc, ino, dip, dip->di_mtime); in xchk_dinode()
316 xchk_dinode_nsec(sc, ino, dip, dip->di_ctime); in xchk_dinode()
320 * the VFS such as the upper bit being set and zero-length in xchk_dinode()
323 isize = be64_to_cpu(dip->di_size); in xchk_dinode()
328 if (!S_ISDIR(mode) && !S_ISREG(mode) && !S_ISLNK(mode) && isize != 0) in xchk_dinode()
332 if (S_ISDIR(mode) && (isize == 0 || isize >= XFS_DIR2_SPACE_SIZE)) in xchk_dinode()
336 if (S_ISLNK(mode) && (isize == 0 || isize >= XFS_SYMLINK_MAXLEN)) in xchk_dinode()
345 if (isize >= mp->m_super->s_maxbytes) in xchk_dinode()
356 * best we can do without cross-referencing with the in xchk_dinode()
359 if (be64_to_cpu(dip->di_nblocks) >= in xchk_dinode()
360 mp->m_sb.sb_dblocks + mp->m_sb.sb_rblocks) in xchk_dinode()
363 if (be64_to_cpu(dip->di_nblocks) >= mp->m_sb.sb_dblocks) in xchk_dinode()
367 xchk_inode_flags(sc, dip, ino, mode, flags); in xchk_dinode()
369 xchk_inode_extsize(sc, dip, ino, mode, flags); in xchk_dinode()
372 nextents = be32_to_cpu(dip->di_nextents); in xchk_dinode()
374 switch (dip->di_format) { in xchk_dinode()
390 if (XFS_DFORK_APTR(dip) >= (char *)dip + mp->m_sb.sb_inodesize) in xchk_dinode()
392 if (dip->di_anextents != 0 && dip->di_forkoff == 0) in xchk_dinode()
394 if (dip->di_forkoff == 0 && dip->di_aformat != XFS_DINODE_FMT_EXTENTS) in xchk_dinode()
398 if (dip->di_aformat != XFS_DINODE_FMT_LOCAL && in xchk_dinode()
399 dip->di_aformat != XFS_DINODE_FMT_EXTENTS && in xchk_dinode()
400 dip->di_aformat != XFS_DINODE_FMT_BTREE) in xchk_dinode()
404 nextents = be16_to_cpu(dip->di_anextents); in xchk_dinode()
406 switch (dip->di_aformat) { in xchk_dinode()
420 if (dip->di_version >= 3) { in xchk_dinode()
421 xchk_dinode_nsec(sc, ino, dip, dip->di_crtime); in xchk_dinode()
422 xchk_inode_flags2(sc, dip, ino, mode, flags, flags2); in xchk_dinode()
423 xchk_inode_cowextsize(sc, dip, ino, mode, flags, in xchk_dinode()
443 if (!sc->sa.fino_cur || xchk_skip_xref(sc->sm)) in xchk_inode_xref_finobt()
446 agino = XFS_INO_TO_AGINO(sc->mp, ino); in xchk_inode_xref_finobt()
452 error = xfs_inobt_lookup(sc->sa.fino_cur, agino, XFS_LOOKUP_LE, in xchk_inode_xref_finobt()
454 if (!xchk_should_check_xref(sc, &error, &sc->sa.fino_cur) || in xchk_inode_xref_finobt()
458 error = xfs_inobt_get_rec(sc->sa.fino_cur, &rec, &has_record); in xchk_inode_xref_finobt()
459 if (!xchk_should_check_xref(sc, &error, &sc->sa.fino_cur) || in xchk_inode_xref_finobt()
471 if (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino)) in xchk_inode_xref_finobt()
472 xchk_btree_xref_set_corrupt(sc, sc->sa.fino_cur, 0); in xchk_inode_xref_finobt()
486 if (xchk_skip_xref(sc->sm)) in xchk_inode_xref_bmap()
490 error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_DATA_FORK, in xchk_inode_xref_bmap()
494 if (nextents < be32_to_cpu(dip->di_nextents)) in xchk_inode_xref_bmap()
495 xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); in xchk_inode_xref_bmap()
497 error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_ATTR_FORK, in xchk_inode_xref_bmap()
501 if (nextents != be16_to_cpu(dip->di_anextents)) in xchk_inode_xref_bmap()
502 xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); in xchk_inode_xref_bmap()
505 if (count + acount != be64_to_cpu(dip->di_nblocks)) in xchk_inode_xref_bmap()
506 xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); in xchk_inode_xref_bmap()
509 /* Cross-reference with the other btrees. */
520 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_inode_xref()
523 agno = XFS_INO_TO_AGNO(sc->mp, ino); in xchk_inode_xref()
524 agbno = XFS_INO_TO_AGBNO(sc->mp, ino); in xchk_inode_xref()
526 error = xchk_ag_init(sc, agno, &sc->sa); in xchk_inode_xref()
536 xchk_ag_free(sc, &sc->sa); in xchk_inode_xref()
550 struct xfs_mount *mp = sc->mp; in xchk_inode_check_reflink_iflag()
554 if (!xfs_sb_version_hasreflink(&mp->m_sb)) in xchk_inode_check_reflink_iflag()
557 error = xfs_reflink_inode_has_shared_extents(sc->tp, sc->ip, in xchk_inode_check_reflink_iflag()
562 if (xfs_is_reflink_inode(sc->ip) && !has_shared) in xchk_inode_check_reflink_iflag()
564 else if (!xfs_is_reflink_inode(sc->ip) && has_shared) in xchk_inode_check_reflink_iflag()
577 * If sc->ip is NULL, that means that the setup function called in xchk_inode()
581 if (!sc->ip) { in xchk_inode()
582 xchk_ino_set_corrupt(sc, sc->sm->sm_ino); in xchk_inode()
587 xfs_inode_to_disk(sc->ip, &di, 0); in xchk_inode()
588 xchk_dinode(sc, &di, sc->ip->i_ino); in xchk_inode()
589 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_inode()
594 * iflag. We already checked the iflag against the file mode when in xchk_inode()
597 if (S_ISREG(VFS_I(sc->ip)->i_mode)) in xchk_inode()
598 xchk_inode_check_reflink_iflag(sc, sc->ip->i_ino); in xchk_inode()
600 xchk_inode_xref(sc, sc->ip->i_ino, &di); in xchk_inode()