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 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
29 # real QA test starts here
31 _require_command "$XFS_ADMIN_PROG" "xfs_admin"
32 _require_scratch_xfs_bigtime
33 _require_xfs_repair_upgrade bigtime
35 date --date='Jan 1 00:00:00 UTC 2040' > /dev/null 2>&1 || \
36 _notrun "Userspace does not support dates past 2038."
40 # Make sure we can't upgrade a V4 filesystem
41 _scratch_mkfs -m crc=0 >> $seqres.full
42 _scratch_xfs_admin -O bigtime=1 2>> $seqres.full
43 _check_scratch_xfs_features BIGTIME
45 # Make sure we're required to specify a feature status
46 _scratch_mkfs -m crc=1,bigtime=0,inobtcount=0 >> $seqres.full
47 _scratch_xfs_admin -O bigtime 2>> $seqres.full
49 # Can we add bigtime and inobtcount at the same time?
50 _scratch_mkfs -m crc=1,bigtime=0,inobtcount=0 >> $seqres.full
51 _scratch_xfs_admin -O bigtime=1,inobtcount=1 2>> $seqres.full
53 # Format V5 filesystem without bigtime support and populate it
54 _scratch_mkfs -m crc=1,bigtime=0 >> $seqres.full
55 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
56 _scratch_mount >> $seqres.full
58 touch -d 'Jan 9 19:19:19 UTC 1999' $SCRATCH_MNT/a
59 touch -d 'Jan 9 19:19:19 UTC 1999' $SCRATCH_MNT/b
60 ls -la $SCRATCH_MNT/* >> $seqres.full
63 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
64 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
69 # Now upgrade to bigtime support
70 _scratch_xfs_admin -O bigtime=1 2>> $seqres.full
71 _check_scratch_xfs_features BIGTIME
73 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
75 # Mount again, look at our files
76 _scratch_mount >> $seqres.full
77 ls -la $SCRATCH_MNT/* >> $seqres.full
80 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
81 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
83 # Bump one of the timestamps but stay under 2038
84 touch -d 'Jan 10 19:19:19 UTC 1999' $SCRATCH_MNT/a
86 echo after upgrade and bump:
87 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
88 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
92 # Did the bumped timestamp survive the remount?
93 ls -la $SCRATCH_MNT/* >> $seqres.full
95 echo after upgrade, bump, and remount:
96 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
97 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
99 # Modify the other timestamp to stretch beyond 2038
100 touch -d 'Feb 22 22:22:22 UTC 2222' $SCRATCH_MNT/b
102 echo after upgrade and extension:
103 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
104 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
108 # Did the timestamp survive the remount?
109 ls -la $SCRATCH_MNT/* >> $seqres.full
111 echo after upgrade, extension, and remount:
112 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
113 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b