generic: test for file fsync after moving it to a new parent directory
[xfstests-dev.git] / tests / generic / 380
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 380
6 #
7 # To test out pv#940675 crash in xfs_trans_brelse + quotas
8 # Without the fix, this will create an ASSERT failure in debug kernels
9 # and crash a non-debug kernel.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22     cd /
23     rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/quota
30
31 # real QA test starts here
32
33 # Modify as appropriate.
34 _supported_fs generic
35 _supported_os Linux
36
37 _require_scratch
38 _require_quota
39 _require_xfs_quota_foreign
40
41 _chowning_file()
42 {
43         file=file.chown
44         let start=$1
45         let limit=$2
46         let delta=$3
47
48         cd $SCRATCH_MNT
49         let count=$start
50         while (( count < limit )); do
51             touch $file
52             chown $count.$count $file
53             echo -n "."
54             let count=count+delta
55         done
56         echo ""
57 }
58
59 echo "mkfs on scratch"
60 _scratch_mkfs >$seqres.full 2>&1
61
62 echo "mount with quotas"
63 export MOUNT_OPTIONS="-o usrquota"
64 _scratch_mount
65
66 echo "creating quota file with holes"
67 _chowning_file 1000 2000 100
68
69 echo "now fill in the holes"
70 _chowning_file 1000 2000 1
71
72 echo "look at the final file ownership for fun"
73 ls -l $SCRATCH_MNT/* \
74 | $AWK_PROG 'NF > 2 {print $3, $4, $NF}' \
75 | sed "s#$SCRATCH_MNT#SCRATCH_MNT#g"
76
77 # success, all done
78 status=0
79 exit