hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/xfs/scrub/inode.c
....@@ -9,27 +9,17 @@
99 #include "xfs_format.h"
1010 #include "xfs_trans_resv.h"
1111 #include "xfs_mount.h"
12
-#include "xfs_defer.h"
1312 #include "xfs_btree.h"
14
-#include "xfs_bit.h"
1513 #include "xfs_log_format.h"
16
-#include "xfs_trans.h"
17
-#include "xfs_sb.h"
1814 #include "xfs_inode.h"
19
-#include "xfs_icache.h"
20
-#include "xfs_inode_buf.h"
21
-#include "xfs_inode_fork.h"
2215 #include "xfs_ialloc.h"
2316 #include "xfs_da_format.h"
2417 #include "xfs_reflink.h"
2518 #include "xfs_rmap.h"
26
-#include "xfs_bmap.h"
2719 #include "xfs_bmap_util.h"
28
-#include "scrub/xfs_scrub.h"
2920 #include "scrub/scrub.h"
3021 #include "scrub/common.h"
3122 #include "scrub/btree.h"
32
-#include "scrub/trace.h"
3323
3424 /*
3525 * Grab total control of the inode metadata. It doesn't matter here if
....@@ -199,9 +189,28 @@
199189 if ((flags2 & XFS_DIFLAG2_DAX) && (flags2 & XFS_DIFLAG2_REFLINK))
200190 goto bad;
201191
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
+
202197 return;
203198 bad:
204199 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);
205214 }
206215
207216 /* Scrub all the ondisk inode fields. */
....@@ -302,12 +311,9 @@
302311 }
303312
304313 /* 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);
311317
312318 /*
313319 * di_size. xfs_dinode_verify checks for things that screw up
....@@ -412,8 +418,7 @@
412418 }
413419
414420 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);
417422 xchk_inode_flags2(sc, dip, ino, mode, flags, flags2);
418423 xchk_inode_cowextsize(sc, dip, ino, mode, flags,
419424 flags2);
....@@ -508,7 +513,6 @@
508513 xfs_ino_t ino,
509514 struct xfs_dinode *dip)
510515 {
511
- struct xfs_owner_info oinfo;
512516 xfs_agnumber_t agno;
513517 xfs_agblock_t agbno;
514518 int error;
....@@ -525,8 +529,7 @@
525529
526530 xchk_xref_is_used_space(sc, agbno, 1);
527531 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);
530533 xchk_xref_is_not_shared(sc, agbno, 1);
531534 xchk_inode_xref_bmap(sc, dip);
532535