2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Check that we can upgrade a filesystem to support bigtime and that inode
8 # timestamps work properly after the upgrade.
11 _begin_fstest auto quick bigtime
13 # Import common functions.
16 # real QA test starts here
18 _require_command "$XFS_ADMIN_PROG" "xfs_admin"
19 _require_scratch_xfs_bigtime
20 _require_xfs_repair_upgrade bigtime
22 date --date='Jan 1 00:00:00 UTC 2040' > /dev/null 2>&1 || \
23 _notrun "Userspace does not support dates past 2038."
25 # Make sure we can't upgrade a V4 filesystem
26 _scratch_mkfs -m crc=0 >> $seqres.full
27 _scratch_xfs_admin -O bigtime=1 2>> $seqres.full
28 _check_scratch_xfs_features BIGTIME
30 # Make sure we're required to specify a feature status
31 _scratch_mkfs -m crc=1,bigtime=0,inobtcount=0 >> $seqres.full
32 _scratch_xfs_admin -O bigtime 2>> $seqres.full
34 # Can we add bigtime and inobtcount at the same time?
35 _scratch_mkfs -m crc=1,bigtime=0,inobtcount=0 >> $seqres.full
36 _scratch_xfs_admin -O bigtime=1,inobtcount=1 2>> $seqres.full
38 # Format V5 filesystem without bigtime support and populate it
39 _scratch_mkfs -m crc=1,bigtime=0 >> $seqres.full
40 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
41 _scratch_mount >> $seqres.full
43 touch -d 'Jan 9 19:19:19 UTC 1999' $SCRATCH_MNT/a
44 touch -d 'Jan 9 19:19:19 UTC 1999' $SCRATCH_MNT/b
45 ls -la $SCRATCH_MNT/* >> $seqres.full
48 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
49 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
54 # Now upgrade to bigtime support
55 _scratch_xfs_admin -O bigtime=1 2>> $seqres.full
56 _check_scratch_xfs_features BIGTIME
58 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
60 # Mount again, look at our files
61 _scratch_mount >> $seqres.full
62 ls -la $SCRATCH_MNT/* >> $seqres.full
65 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
66 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
68 # Bump one of the timestamps but stay under 2038
69 touch -d 'Jan 10 19:19:19 UTC 1999' $SCRATCH_MNT/a
71 echo after upgrade and bump:
72 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
73 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
77 # Did the bumped timestamp survive the remount?
78 ls -la $SCRATCH_MNT/* >> $seqres.full
80 echo after upgrade, bump, and remount:
81 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
82 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
84 # Modify the other timestamp to stretch beyond 2038
85 touch -d 'Feb 22 22:22:22 UTC 2222' $SCRATCH_MNT/b
87 echo after upgrade and extension:
88 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
89 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
93 # Did the timestamp survive the remount?
94 ls -la $SCRATCH_MNT/* >> $seqres.full
96 echo after upgrade, extension, and remount:
97 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
98 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b