summaryrefslogtreecommitdiff
path: root/tests/xfs/160
blob: d11eaba3c82cb76b2de3529eff31092e258b75c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2021 Oracle.  All Rights Reserved.
#
# FS QA Test No. 160
#
# Check that we can upgrade a filesystem to support bigtime and that inode
# timestamps work properly after the upgrade.

. ./common/preamble
_begin_fstest auto quick bigtime

# Import common functions.
. ./common/filter

# real QA test starts here
_supported_fs xfs
_require_command "$XFS_ADMIN_PROG" "xfs_admin"
_require_scratch_xfs_bigtime
_require_xfs_repair_upgrade bigtime

date --date='Jan 1 00:00:00 UTC 2040' > /dev/null 2>&1 || \
	_notrun "Userspace does not support dates past 2038."

# Make sure we're required to specify a feature status
_scratch_mkfs -m crc=1,bigtime=0,inobtcount=0 >> $seqres.full
_scratch_xfs_admin -O bigtime 2>> $seqres.full

# Can we add bigtime and inobtcount at the same time?
_scratch_mkfs -m crc=1,bigtime=0,inobtcount=0 >> $seqres.full
_scratch_xfs_admin -O bigtime=1,inobtcount=1 2>> $seqres.full

# Format V5 filesystem without bigtime support and populate it
_scratch_mkfs -m crc=1,bigtime=0 >> $seqres.full
_scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
_scratch_mount >> $seqres.full

touch -d 'Jan 9 19:19:19 UTC 1999' $SCRATCH_MNT/a
touch -d 'Jan 9 19:19:19 UTC 1999' $SCRATCH_MNT/b
ls -la $SCRATCH_MNT/* >> $seqres.full

echo before upgrade:
TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
TZ=UTC stat -c '%Y' $SCRATCH_MNT/b

_scratch_unmount
_check_scratch_fs

# Now upgrade to bigtime support
_scratch_xfs_admin -O bigtime=1 2>> $seqres.full
_check_scratch_xfs_features BIGTIME
_check_scratch_fs
_scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full

# Mount again, look at our files
_scratch_mount >> $seqres.full
ls -la $SCRATCH_MNT/* >> $seqres.full

echo after upgrade:
TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
TZ=UTC stat -c '%Y' $SCRATCH_MNT/b

# Bump one of the timestamps but stay under 2038
touch -d 'Jan 10 19:19:19 UTC 1999' $SCRATCH_MNT/a

echo after upgrade and bump:
TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
TZ=UTC stat -c '%Y' $SCRATCH_MNT/b

_scratch_cycle_mount

# Did the bumped timestamp survive the remount?
ls -la $SCRATCH_MNT/* >> $seqres.full

echo after upgrade, bump, and remount:
TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
TZ=UTC stat -c '%Y' $SCRATCH_MNT/b

# Modify the other timestamp to stretch beyond 2038
touch -d 'Feb 22 22:22:22 UTC 2222' $SCRATCH_MNT/b

echo after upgrade and extension:
TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
TZ=UTC stat -c '%Y' $SCRATCH_MNT/b

_scratch_cycle_mount

# Did the timestamp survive the remount?
ls -la $SCRATCH_MNT/* >> $seqres.full

echo after upgrade, extension, and remount:
TZ=UTC stat -c '%Y' $SCRATCH_MNT/a
TZ=UTC stat -c '%Y' $SCRATCH_MNT/b

# success, all done
status=0
exit