xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / xfs / 160
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 160
6 #
7 # Check that we can upgrade a filesystem to support bigtime and that inode
8 # timestamps work properly after the upgrade.
9
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30 _supported_fs xfs
31 _require_command "$XFS_ADMIN_PROG" "xfs_admin"
32 _require_scratch_xfs_bigtime
33 _require_xfs_repair_upgrade bigtime
34
35 date --date='Jan 1 00:00:00 UTC 2040' > /dev/null 2>&1 || \
36         _notrun "Userspace does not support dates past 2038."
37
38 rm -f $seqres.full
39
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
44
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
48
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
52
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
57
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
61
62 echo before upgrade:
63 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
64 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
65
66 _scratch_unmount
67 _check_scratch_fs
68
69 # Now upgrade to bigtime support
70 _scratch_xfs_admin -O bigtime=1 2>> $seqres.full
71 _check_scratch_xfs_features BIGTIME
72 _check_scratch_fs
73 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
74
75 # Mount again, look at our files
76 _scratch_mount >> $seqres.full
77 ls -la $SCRATCH_MNT/* >> $seqres.full
78
79 echo after upgrade:
80 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
81 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
82
83 # Bump one of the timestamps but stay under 2038
84 touch -d 'Jan 10 19:19:19 UTC 1999' $SCRATCH_MNT/a
85
86 echo after upgrade and bump:
87 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
88 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
89
90 _scratch_cycle_mount
91
92 # Did the bumped timestamp survive the remount?
93 ls -la $SCRATCH_MNT/* >> $seqres.full
94
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
98
99 # Modify the other timestamp to stretch beyond 2038
100 touch -d 'Feb 22 22:22:22 UTC 2222' $SCRATCH_MNT/b
101
102 echo after upgrade and extension:
103 TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
104 TZ=UTC stat -c '%Y' $SCRATCH_MNT/b
105
106 _scratch_cycle_mount
107
108 # Did the timestamp survive the remount?
109 ls -la $SCRATCH_MNT/* >> $seqres.full
110
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
114
115 # success, all done
116 status=0
117 exit