inode.c (5a0bb066f60fa02f453d7721844eae59f505c06e) inode.c (f93e5436f0ee5a85eaa3a86d2614d215873fb18b)
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2017 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
5 */
6#include "xfs.h"
7#include "xfs_fs.h"
8#include "xfs_shared.h"

--- 176 unchanged lines hidden (view full) ---

185 /* realtime and reflink make no sense, currently */
186 if ((flags & XFS_DIFLAG_REALTIME) && (flags2 & XFS_DIFLAG2_REFLINK))
187 goto bad;
188
189 /* dax and reflink make no sense, currently */
190 if ((flags2 & XFS_DIFLAG2_DAX) && (flags2 & XFS_DIFLAG2_REFLINK))
191 goto bad;
192
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2017 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
5 */
6#include "xfs.h"
7#include "xfs_fs.h"
8#include "xfs_shared.h"

--- 176 unchanged lines hidden (view full) ---

185 /* realtime and reflink make no sense, currently */
186 if ((flags & XFS_DIFLAG_REALTIME) && (flags2 & XFS_DIFLAG2_REFLINK))
187 goto bad;
188
189 /* dax and reflink make no sense, currently */
190 if ((flags2 & XFS_DIFLAG2_DAX) && (flags2 & XFS_DIFLAG2_REFLINK))
191 goto bad;
192
193 /* no bigtime iflag without the bigtime feature */
194 if (xfs_dinode_has_bigtime(dip) &&
195 !xfs_sb_version_hasbigtime(&mp->m_sb))
196 goto bad;
197
193 return;
194bad:
195 xchk_ino_set_corrupt(sc, ino);
196}
197
198static inline void
199xchk_dinode_nsec(
200 struct xfs_scrub *sc,
201 xfs_ino_t ino,
198 return;
199bad:
200 xchk_ino_set_corrupt(sc, ino);
201}
202
203static inline void
204xchk_dinode_nsec(
205 struct xfs_scrub *sc,
206 xfs_ino_t ino,
207 struct xfs_dinode *dip,
202 const xfs_timestamp_t ts)
203{
204 struct timespec64 tv;
205
208 const xfs_timestamp_t ts)
209{
210 struct timespec64 tv;
211
206 tv = xfs_inode_from_disk_ts(ts);
212 tv = xfs_inode_from_disk_ts(dip, ts);
207 if (tv.tv_nsec < 0 || tv.tv_nsec >= NSEC_PER_SEC)
208 xchk_ino_set_corrupt(sc, ino);
209}
210
211/* Scrub all the ondisk inode fields. */
212STATIC void
213xchk_dinode(
214 struct xfs_scrub *sc,

--- 86 unchanged lines hidden (view full) ---

301 break;
302 case XFS_DINODE_FMT_UUID:
303 default:
304 xchk_ino_set_corrupt(sc, ino);
305 break;
306 }
307
308 /* di_[amc]time.nsec */
213 if (tv.tv_nsec < 0 || tv.tv_nsec >= NSEC_PER_SEC)
214 xchk_ino_set_corrupt(sc, ino);
215}
216
217/* Scrub all the ondisk inode fields. */
218STATIC void
219xchk_dinode(
220 struct xfs_scrub *sc,

--- 86 unchanged lines hidden (view full) ---

307 break;
308 case XFS_DINODE_FMT_UUID:
309 default:
310 xchk_ino_set_corrupt(sc, ino);
311 break;
312 }
313
314 /* di_[amc]time.nsec */
309 xchk_dinode_nsec(sc, ino, dip->di_atime);
310 xchk_dinode_nsec(sc, ino, dip->di_mtime);
311 xchk_dinode_nsec(sc, ino, dip->di_ctime);
315 xchk_dinode_nsec(sc, ino, dip, dip->di_atime);
316 xchk_dinode_nsec(sc, ino, dip, dip->di_mtime);
317 xchk_dinode_nsec(sc, ino, dip, dip->di_ctime);
312
313 /*
314 * di_size. xfs_dinode_verify checks for things that screw up
315 * the VFS such as the upper bit being set and zero-length
316 * symlinks/directories, but we can do more here.
317 */
318 isize = be64_to_cpu(dip->di_size);
319 if (isize & (1ULL << 63))

--- 88 unchanged lines hidden (view full) ---

408 xchk_ino_set_corrupt(sc, ino);
409 break;
410 default:
411 if (nextents != 0)
412 xchk_ino_set_corrupt(sc, ino);
413 }
414
415 if (dip->di_version >= 3) {
318
319 /*
320 * di_size. xfs_dinode_verify checks for things that screw up
321 * the VFS such as the upper bit being set and zero-length
322 * symlinks/directories, but we can do more here.
323 */
324 isize = be64_to_cpu(dip->di_size);
325 if (isize & (1ULL << 63))

--- 88 unchanged lines hidden (view full) ---

414 xchk_ino_set_corrupt(sc, ino);
415 break;
416 default:
417 if (nextents != 0)
418 xchk_ino_set_corrupt(sc, ino);
419 }
420
421 if (dip->di_version >= 3) {
416 xchk_dinode_nsec(sc, ino, dip->di_crtime);
422 xchk_dinode_nsec(sc, ino, dip, dip->di_crtime);
417 xchk_inode_flags2(sc, dip, ino, mode, flags, flags2);
418 xchk_inode_cowextsize(sc, dip, ino, mode, flags,
419 flags2);
420 }
421}
422
423/*
424 * Make sure the finobt doesn't think this inode is free.

--- 174 unchanged lines hidden ---
423 xchk_inode_flags2(sc, dip, ino, mode, flags, flags2);
424 xchk_inode_cowextsize(sc, dip, ino, mode, flags,
425 flags2);
426 }
427}
428
429/*
430 * Make sure the finobt doesn't think this inode is free.

--- 174 unchanged lines hidden ---