generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 055
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 055
6 #
7 # * like 054 but want to create more/different kinds of metadata
8 #   and so will use fsstress
9 # * also can interrupt metadata with godown
10 #
11 . ./common/preamble
12 _begin_fstest shutdown log v2log auto quota stress
13
14 # Import common functions.
15 . ./common/filter
16 . ./common/log
17 . ./common/quota
18
19 _do_meta()
20 {
21     out=$SCRATCH_MNT/fsstress
22     count=10000
23     param="-p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 \
24            -f rename=30 -f stat=30 -f unlink=30 -f truncate=20"
25     _echofull "calling fsstress $param -m8 -n $count"
26     FSSTRESS_ARGS=`_scale_fsstress_args $param $FSSTRESS_AVOID -m 8 -n $count -d $out`
27     if ! $FSSTRESS_PROG $FSSTRESS_ARGS >>$seqres.full 2>&1
28     then
29         _echofull "fsstress failed"
30     fi
31 }
32
33 _get_quota_option()
34 {
35     case $FSTYP in
36     xfs)
37         _require_xfs_quota
38         echo "-o uquota"
39         ;;
40     *)
41         ;;
42     esac
43 }
44
45 # real QA test starts here
46 _supported_fs generic
47
48 _require_scratch
49 _require_scratch_shutdown
50 _require_logstate
51
52 QUOTA_OPTION=`_get_quota_option`
53
54 echo "*** init FS"
55 _scratch_unmount >/dev/null 2>&1
56
57 _scratch_mkfs >/dev/null 2>&1
58 _require_metadata_journaling $SCRATCH_DEV
59
60 _get_log_configs > $tmp.seq.params
61
62 cat $tmp.seq.params \
63 | while read mkfs mnt restofline
64 do
65     if [ "$mkfs" = "#" ]; then
66         continue
67     fi
68
69     echo "--- mkfs=$mkfs, mnt=$mnt ---" >> $seqres.full
70     export MKFS_OPTIONS="-l $mkfs"
71     export MOUNT_OPTIONS="-o $mnt"
72
73     # mkfs the FS
74     _echofull "mkfs"
75     _scratch_mkfs >>$seqres.full 2>&1
76     if [ $? -ne 0 ] ; then
77         _echofull "mkfs failed: $MKFS_OPTIONS"
78         continue
79     fi
80
81     # mount the FS
82     _echofull "mount"
83     if ! _try_scratch_mount $QUOTA_OPTION >>$seqres.full 2>&1; then
84         _echofull "mount failed: $MOUNT_OPTIONS"
85         continue
86     fi
87
88     # create the metadata
89     _do_meta
90
91     # check before on what FS should look like
92     _echofull "ls -RF SCRATCH_MNT"
93     ls -RF $SCRATCH_MNT >$tmp.ls1
94
95     _echofull "godown"
96     _scratch_shutdown -v -f >> $seqres.full
97
98     _echofull "unmount"
99     _scratch_unmount >>$seqres.full 2>&1 \
100         || _fail "umount failed"
101
102     _echofull "logprint after going down..."
103     _print_logstate
104
105     _full "logprint headers"
106     _scratch_xfs_logprint -n >>$seqres.full 2>&1
107
108     _echofull "mount with replay"
109     _try_scratch_mount $QUOTA_OPTION >>$seqres.full 2>&1 \
110         || _fail "mount failed: $MOUNT_OPTIONS"
111
112     # check on what FS looks like after log recovery
113     _echofull "ls -RF SCRATCH_MNT"
114     ls -RF $SCRATCH_MNT >$tmp.ls2
115
116     _echofull "diff ls before and after"
117     diff -us $tmp.ls1 $tmp.ls2 | sed "s#$tmp#TMP#g"
118
119     _echofull "unmount"
120     _scratch_unmount
121
122     _echofull "logprint after mount and replay..."
123     _print_logstate
124
125     if _check_scratch_fs; then
126         _echofull "filesystem is checked ok"
127     else
128         _echofull "filesystem is NOT ok"
129     fi
130 done
131
132 status=0
133 exit