.. | .. |
---|
9 | 9 | #include "xfs_format.h" |
---|
10 | 10 | #include "xfs_trans_resv.h" |
---|
11 | 11 | #include "xfs_mount.h" |
---|
12 | | -#include "xfs_defer.h" |
---|
13 | 12 | #include "xfs_btree.h" |
---|
14 | | -#include "xfs_bit.h" |
---|
15 | 13 | #include "xfs_log_format.h" |
---|
16 | | -#include "xfs_trans.h" |
---|
17 | | -#include "xfs_sb.h" |
---|
18 | 14 | #include "xfs_inode.h" |
---|
19 | | -#include "xfs_icache.h" |
---|
20 | | -#include "xfs_inode_buf.h" |
---|
21 | | -#include "xfs_inode_fork.h" |
---|
22 | 15 | #include "xfs_ialloc.h" |
---|
23 | 16 | #include "xfs_da_format.h" |
---|
24 | 17 | #include "xfs_reflink.h" |
---|
25 | 18 | #include "xfs_rmap.h" |
---|
26 | | -#include "xfs_bmap.h" |
---|
27 | 19 | #include "xfs_bmap_util.h" |
---|
28 | | -#include "scrub/xfs_scrub.h" |
---|
29 | 20 | #include "scrub/scrub.h" |
---|
30 | 21 | #include "scrub/common.h" |
---|
31 | 22 | #include "scrub/btree.h" |
---|
32 | | -#include "scrub/trace.h" |
---|
33 | 23 | |
---|
34 | 24 | /* |
---|
35 | 25 | * Grab total control of the inode metadata. It doesn't matter here if |
---|
.. | .. |
---|
199 | 189 | if ((flags2 & XFS_DIFLAG2_DAX) && (flags2 & XFS_DIFLAG2_REFLINK)) |
---|
200 | 190 | goto bad; |
---|
201 | 191 | |
---|
| 192 | + /* no bigtime iflag without the bigtime feature */ |
---|
| 193 | + if (xfs_dinode_has_bigtime(dip) && |
---|
| 194 | + !xfs_sb_version_hasbigtime(&mp->m_sb)) |
---|
| 195 | + goto bad; |
---|
| 196 | + |
---|
202 | 197 | return; |
---|
203 | 198 | bad: |
---|
204 | 199 | xchk_ino_set_corrupt(sc, ino); |
---|
| 200 | +} |
---|
| 201 | + |
---|
| 202 | +static inline void |
---|
| 203 | +xchk_dinode_nsec( |
---|
| 204 | + struct xfs_scrub *sc, |
---|
| 205 | + xfs_ino_t ino, |
---|
| 206 | + struct xfs_dinode *dip, |
---|
| 207 | + const xfs_timestamp_t ts) |
---|
| 208 | +{ |
---|
| 209 | + struct timespec64 tv; |
---|
| 210 | + |
---|
| 211 | + tv = xfs_inode_from_disk_ts(dip, ts); |
---|
| 212 | + if (tv.tv_nsec < 0 || tv.tv_nsec >= NSEC_PER_SEC) |
---|
| 213 | + xchk_ino_set_corrupt(sc, ino); |
---|
205 | 214 | } |
---|
206 | 215 | |
---|
207 | 216 | /* Scrub all the ondisk inode fields. */ |
---|
.. | .. |
---|
302 | 311 | } |
---|
303 | 312 | |
---|
304 | 313 | /* di_[amc]time.nsec */ |
---|
305 | | - if (be32_to_cpu(dip->di_atime.t_nsec) >= NSEC_PER_SEC) |
---|
306 | | - xchk_ino_set_corrupt(sc, ino); |
---|
307 | | - if (be32_to_cpu(dip->di_mtime.t_nsec) >= NSEC_PER_SEC) |
---|
308 | | - xchk_ino_set_corrupt(sc, ino); |
---|
309 | | - if (be32_to_cpu(dip->di_ctime.t_nsec) >= NSEC_PER_SEC) |
---|
310 | | - xchk_ino_set_corrupt(sc, ino); |
---|
| 314 | + xchk_dinode_nsec(sc, ino, dip, dip->di_atime); |
---|
| 315 | + xchk_dinode_nsec(sc, ino, dip, dip->di_mtime); |
---|
| 316 | + xchk_dinode_nsec(sc, ino, dip, dip->di_ctime); |
---|
311 | 317 | |
---|
312 | 318 | /* |
---|
313 | 319 | * di_size. xfs_dinode_verify checks for things that screw up |
---|
.. | .. |
---|
412 | 418 | } |
---|
413 | 419 | |
---|
414 | 420 | if (dip->di_version >= 3) { |
---|
415 | | - if (be32_to_cpu(dip->di_crtime.t_nsec) >= NSEC_PER_SEC) |
---|
416 | | - xchk_ino_set_corrupt(sc, ino); |
---|
| 421 | + xchk_dinode_nsec(sc, ino, dip, dip->di_crtime); |
---|
417 | 422 | xchk_inode_flags2(sc, dip, ino, mode, flags, flags2); |
---|
418 | 423 | xchk_inode_cowextsize(sc, dip, ino, mode, flags, |
---|
419 | 424 | flags2); |
---|
.. | .. |
---|
508 | 513 | xfs_ino_t ino, |
---|
509 | 514 | struct xfs_dinode *dip) |
---|
510 | 515 | { |
---|
511 | | - struct xfs_owner_info oinfo; |
---|
512 | 516 | xfs_agnumber_t agno; |
---|
513 | 517 | xfs_agblock_t agbno; |
---|
514 | 518 | int error; |
---|
.. | .. |
---|
525 | 529 | |
---|
526 | 530 | xchk_xref_is_used_space(sc, agbno, 1); |
---|
527 | 531 | xchk_inode_xref_finobt(sc, ino); |
---|
528 | | - xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INODES); |
---|
529 | | - xchk_xref_is_owned_by(sc, agbno, 1, &oinfo); |
---|
| 532 | + xchk_xref_is_owned_by(sc, agbno, 1, &XFS_RMAP_OINFO_INODES); |
---|
530 | 533 | xchk_xref_is_not_shared(sc, agbno, 1); |
---|
531 | 534 | xchk_inode_xref_bmap(sc, dip); |
---|
532 | 535 | |
---|